loading...

Weeknotes - 04 Makers

ruthmoog profile image ruthmoog ใƒป2 min read

Makers weeknotes (16 Part Series)

1) Weeknotes - 01 Makers PreCourse 2) Weeknotes - 02 Makers PreCourse 3 ... 14 3) Weeknotes - 03 Makers PreCourse 4) Weeknotes - 04 Makers PreCourse 5) Weeknotes - 01 Makers 6) Weeknotes - 02 Makers 7) Weeknotes - 03 Makers 8) Weeknotes - 04 Makers 9) Weeknotes - 05 Makers 10) Weeknotes - 06 Makers 11) Weeknotes - 07 Makers 12) Weeknotes - 08 Makers 13) Weeknotes - 09 Makers 14) Weeknotes - 10 Makers 15) Weeknotes - 11 Makers 16) Weeknotes - 12 Makers

Weeknotes - 04 Makers

This week was about demonstrating full control over database content, and expanding our webapp knowledge to include data storage. Normally, if you want to store data you'd use a database where your data persists beyond shut-down and restart. The data persisted so strongly that I was dreaming about databases.

Class Responsibilty Collaborator Cards (CRCs)

CRCs are an aim to help programmers brainstorm the design of their software. In a workshop, we were given a user story, interpreted the objects into cards with responsibilties listed on the left and collaborator classes listed on the right. As we were given more user stories for the project we created more cards/responsbilities/collaborations.

As a milk maid(?!)
So that I can sell milk
I want to see if a cow is ready to be milked

...I want to dock a cow in the milking station

...I want to milk a cow

...I want to know how many cows I have

Here are these user stories represented as CRC cards:


The links made explicit in CRC cards are helpful for designing database tables and avoiding many-to-many relationships when modelling your data (avoid co-dependent cards, ie. if cow milking station has cow as collaborator, and cow has cow milking station as a collaborator too).

Here is a database model for these cow related scenarios:

Table: Cows ๐Ÿฎ

id needs milking milking station id
1 true 1

Table: Cow Milking Stations ๐Ÿผ

id
1

๐Ÿ’ก Where you have a many-to-many relationship, use a junction table to create a join between two one-to-many relationships instead.

Keeping CRC cards small (think index cards) helps you keep class responsbilities small and curb over-designing.

Testing Relationships

One of the coaches shared with me a couple of clues to spot when to seperate responsibilities (and use dependency injection).

  • If you describe a method or a class using the word "and" that's a clue there's more than one responsibility
  • Another is if you notice a method or class managing more than one state. For example Ruby's String class has many methods to change it's characters, but always with string characters. Adding a fixnum to a string "sting" + 2 would be handling more than one state (and if you try that in the repl you'll get an error...)
 TypeError (no implicit conversion of Integer into String)

Misc

๐Ÿ† I had my first stack overflow error!
๐ŸŒŠ How do you pronounce SQL: s-q-l or sequel? When someone suggested 'sea gull' I couldn't stop laughing!1
๐ŸŒฝ Fascinating to hear from Sainsbury's about their digital team: what they do with data, power generation, and cabbage tracking.
โš ๏ธI keep forgetting how to run VSC from the command line when I restart the terminal :Command + Shift + P then select Shell Command : Install 'code' in PATH
๐Ÿ“ everything comes back to hashes of arrays or arrays of hashes...


  1. sequel or s-q-l are both totally fine!ย โ†ฉ

Makers weeknotes (16 Part Series)

1) Weeknotes - 01 Makers PreCourse 2) Weeknotes - 02 Makers PreCourse 3 ... 14 3) Weeknotes - 03 Makers PreCourse 4) Weeknotes - 04 Makers PreCourse 5) Weeknotes - 01 Makers 6) Weeknotes - 02 Makers 7) Weeknotes - 03 Makers 8) Weeknotes - 04 Makers 9) Weeknotes - 05 Makers 10) Weeknotes - 06 Makers 11) Weeknotes - 07 Makers 12) Weeknotes - 08 Makers 13) Weeknotes - 09 Makers 14) Weeknotes - 10 Makers 15) Weeknotes - 11 Makers 16) Weeknotes - 12 Makers

Posted on by:

ruthmoog profile

ruthmoog

@ruthmoog

Developer โ€ข ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป๐Ÿ ๐Ÿ’ƒ๐Ÿพ๐Ÿ’ก๐Ÿฐ ๐Ÿˆ ๐Ÿ‡ช๐Ÿ‡บ

Discussion

markdown guide
 

Adding a fixnum to a string "sting" + 2 would be handling more than one state (and if you try that in the repl you'll get an error...)

JavaScript awaits you with hungry eyes...