Artwork

Innhold levert av iteration podcast, John Jacob, and JP Sio - Web Developers. Alt podcastinnhold, inkludert episoder, grafikk og podcastbeskrivelser, lastes opp og leveres direkte av iteration podcast, John Jacob, and JP Sio - Web Developers eller deres podcastplattformpartner. Hvis du tror at noen bruker det opphavsrettsbeskyttede verket ditt uten din tillatelse, kan du følge prosessen skissert her https://no.player.fm/legal.
Player FM - Podcast-app
Gå frakoblet med Player FM -appen!

Composition Imposition

41:56
 
Del
 

Manage episode 227119986 series 1900125
Innhold levert av iteration podcast, John Jacob, and JP Sio - Web Developers. Alt podcastinnhold, inkludert episoder, grafikk og podcastbeskrivelser, lastes opp og leveres direkte av iteration podcast, John Jacob, and JP Sio - Web Developers eller deres podcastplattformpartner. Hvis du tror at noen bruker det opphavsrettsbeskyttede verket ditt uten din tillatelse, kan du følge prosessen skissert her https://no.player.fm/legal.

Combining Objects with Composition

Metz, Sandi. Practical Object-Oriented Design in Ruby

A weekly podcast about programming, development, and design through the lens of amazing books, chapter-by-chapter.

“Combining the qualities of two existing subclasses, something that inheritance cannot readily accommodate.”

We talked about inheritance, then modules, now this builds on top of the idea of modules and pushes it further.

Composing a bicycle of parts...

Bicycle > has A parts

Parts has subclasses of - RoadBikeParts and MountainBikeParts

Making the Parts Object More Like an Array - This part was freaky

Parts Factory

Different Configs within the parts factory > an array of all the keys and attributes - road_config - mountain_config

Using all this to make a recumbent bike:

Once this is all set up you have this incredibly powerful interface of a bicycle composed of parts:

Bicycle.new(

size: 'L',

parts: PartsFactory.build(recumbent_config))

Composition VS Aggregation

A Meal is composed of an appetizer - An appetizer does not survive outside of the meal. When the meal is gone by definition the appetizer is gone. A meal is composed of an appetizer.

A band is an aggregate of musicians - when the band breaks up the musicians don’t die.

“Composition” encompasses both aggregation and composition -

“This distinction between composition and aggregation may have a little practical effect on your code.”

Deciding Between Inheritance and Composition

“Think of it this way: For the cost of arranging objects in a hierarchy, you get message delegation for free.”

When in doubt use Composition over inheritance

“The general rule is that faced with a problem that composition can solve, you should be biased towards doing so. If you cannot explicitly defend inheritance as a better solution, use composition.”

John’s Pick: Book: "It Doesn’t Have To Be Crazy At Work" -> David Heinemeier Hansen and Jason Fried

JP: Kahn Academy - digging into math again

Next Week: Final Chapter - Designing Cost-Effective Tests

  continue reading

78 episoder

Artwork

Composition Imposition

iteration

113 subscribers

published

iconDel
 
Manage episode 227119986 series 1900125
Innhold levert av iteration podcast, John Jacob, and JP Sio - Web Developers. Alt podcastinnhold, inkludert episoder, grafikk og podcastbeskrivelser, lastes opp og leveres direkte av iteration podcast, John Jacob, and JP Sio - Web Developers eller deres podcastplattformpartner. Hvis du tror at noen bruker det opphavsrettsbeskyttede verket ditt uten din tillatelse, kan du følge prosessen skissert her https://no.player.fm/legal.

Combining Objects with Composition

Metz, Sandi. Practical Object-Oriented Design in Ruby

A weekly podcast about programming, development, and design through the lens of amazing books, chapter-by-chapter.

“Combining the qualities of two existing subclasses, something that inheritance cannot readily accommodate.”

We talked about inheritance, then modules, now this builds on top of the idea of modules and pushes it further.

Composing a bicycle of parts...

Bicycle > has A parts

Parts has subclasses of - RoadBikeParts and MountainBikeParts

Making the Parts Object More Like an Array - This part was freaky

Parts Factory

Different Configs within the parts factory > an array of all the keys and attributes - road_config - mountain_config

Using all this to make a recumbent bike:

Once this is all set up you have this incredibly powerful interface of a bicycle composed of parts:

Bicycle.new(

size: 'L',

parts: PartsFactory.build(recumbent_config))

Composition VS Aggregation

A Meal is composed of an appetizer - An appetizer does not survive outside of the meal. When the meal is gone by definition the appetizer is gone. A meal is composed of an appetizer.

A band is an aggregate of musicians - when the band breaks up the musicians don’t die.

“Composition” encompasses both aggregation and composition -

“This distinction between composition and aggregation may have a little practical effect on your code.”

Deciding Between Inheritance and Composition

“Think of it this way: For the cost of arranging objects in a hierarchy, you get message delegation for free.”

When in doubt use Composition over inheritance

“The general rule is that faced with a problem that composition can solve, you should be biased towards doing so. If you cannot explicitly defend inheritance as a better solution, use composition.”

John’s Pick: Book: "It Doesn’t Have To Be Crazy At Work" -> David Heinemeier Hansen and Jason Fried

JP: Kahn Academy - digging into math again

Next Week: Final Chapter - Designing Cost-Effective Tests

  continue reading

78 episoder

Todos los episodios

×
 
Loading …

Velkommen til Player FM!

Player FM scanner netter for høykvalitets podcaster som du kan nyte nå. Det er den beste podcastappen og fungerer på Android, iPhone og internett. Registrer deg for å synkronisere abonnement på flere enheter.

 

Hurtigreferanseguide

Copyright 2024 | Sitemap | Personvern | Vilkår for bruk | | opphavsrett