Artwork

コンテンツは iteration podcast, John Jacob, and JP Sio - Web Developers によって提供されます。エピソード、グラフィック、ポッドキャストの説明を含むすべてのポッドキャスト コンテンツは、iteration podcast, John Jacob, and JP Sio - Web Developers またはそのポッドキャスト プラットフォーム パートナーによって直接アップロードされ、提供されます。誰かがあなたの著作物をあなたの許可なく使用していると思われる場合は、ここで概説されているプロセスに従うことができますhttps://ja.player.fm/legal
Player FM -ポッドキャストアプリ
Player FMアプリでオフラインにしPlayer FMう!

Inheritance At Its Core

43:59
 
シェア
 

Manage episode 226071168 series 1900125
コンテンツは iteration podcast, John Jacob, and JP Sio - Web Developers によって提供されます。エピソード、グラフィック、ポッドキャストの説明を含むすべてのポッドキャスト コンテンツは、iteration podcast, John Jacob, and JP Sio - Web Developers またはそのポッドキャスト プラットフォーム パートナーによって直接アップロードされ、提供されます。誰かがあなたの著作物をあなたの許可なく使用していると思われる場合は、ここで概説されているプロセスに従うことができますhttps://ja.player.fm/legal

Acquiring Behavior Through Inheritance

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

Sani Metz - Object-Oriented Design in Ruby

“Inheritance is, at its core, a mechanism for automatic message delegation. It defines a forwarding path for not-understood messages.”

Where to Use Inheritance

Objects that share a common parent -

The objects that you are modeling must truly have a generalization-specialization relationship.

Bicycle Touring Company - FastFeet

Bikes - Mountain and Road Bikes

Bikes have an overall size, a handlebar tape color, a tire size, and a chain type.

  • Only mountain bikes have shocks
  • Only Road bikes have handlebar tape

Create a new empty Bicycle Class

Let RoadBike > Bicycle

And MountainBike > Bicycle

When in doubt put less code in the parent, it’s easier to promote code later when you need a shared code.

“The general rule for refactoring into a new inheritance hierarchy is to arrange code so that you can promote abstractions rather than demote concretions.”

A superclass may have many subclasses, but each subclass is permitted only one superclass.

This family tree image is, however, a bit misleading. In many parts of the biological world, it’s common for descendants to have two ancestors.

It’s really useful to rails a NotImplementedError in the parent class in the methods that are required from their children, for example, default tire_size -

“Creating code that fails with reasonable error messages takes minor effort in the present but provides value forever.”

Initialize > Post Initialize to append any or overrode attributes from the parent initialize method.

Initialize + post_initialize

Closes with a mic drop - Initializing a new RecumbentBike is so DRY and painless!

“Inheritance solves the problem of related types that share a great deal of common behavior but differ across some dimension.”

“The best way to create an abstract superclass is by pushing code up from concrete subclasses.”

“When your problem is one of needing numerous specializations of a stable, common abstraction, inheritance can be an extremely low-cost solution.”

PICKS

  • JP: Machine Learning with JavaScript
  • John: Refactoring UI by Adam Wathan and Steve Schoger -
  • Hard Wired Internet - Ran a Cat 5 Cable from my router - SO WORTH IT.
  continue reading

78 つのエピソード

Artwork

Inheritance At Its Core

iteration

96 subscribers

published

iconシェア
 
Manage episode 226071168 series 1900125
コンテンツは iteration podcast, John Jacob, and JP Sio - Web Developers によって提供されます。エピソード、グラフィック、ポッドキャストの説明を含むすべてのポッドキャスト コンテンツは、iteration podcast, John Jacob, and JP Sio - Web Developers またはそのポッドキャスト プラットフォーム パートナーによって直接アップロードされ、提供されます。誰かがあなたの著作物をあなたの許可なく使用していると思われる場合は、ここで概説されているプロセスに従うことができますhttps://ja.player.fm/legal

Acquiring Behavior Through Inheritance

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

Sani Metz - Object-Oriented Design in Ruby

“Inheritance is, at its core, a mechanism for automatic message delegation. It defines a forwarding path for not-understood messages.”

Where to Use Inheritance

Objects that share a common parent -

The objects that you are modeling must truly have a generalization-specialization relationship.

Bicycle Touring Company - FastFeet

Bikes - Mountain and Road Bikes

Bikes have an overall size, a handlebar tape color, a tire size, and a chain type.

  • Only mountain bikes have shocks
  • Only Road bikes have handlebar tape

Create a new empty Bicycle Class

Let RoadBike > Bicycle

And MountainBike > Bicycle

When in doubt put less code in the parent, it’s easier to promote code later when you need a shared code.

“The general rule for refactoring into a new inheritance hierarchy is to arrange code so that you can promote abstractions rather than demote concretions.”

A superclass may have many subclasses, but each subclass is permitted only one superclass.

This family tree image is, however, a bit misleading. In many parts of the biological world, it’s common for descendants to have two ancestors.

It’s really useful to rails a NotImplementedError in the parent class in the methods that are required from their children, for example, default tire_size -

“Creating code that fails with reasonable error messages takes minor effort in the present but provides value forever.”

Initialize > Post Initialize to append any or overrode attributes from the parent initialize method.

Initialize + post_initialize

Closes with a mic drop - Initializing a new RecumbentBike is so DRY and painless!

“Inheritance solves the problem of related types that share a great deal of common behavior but differ across some dimension.”

“The best way to create an abstract superclass is by pushing code up from concrete subclasses.”

“When your problem is one of needing numerous specializations of a stable, common abstraction, inheritance can be an extremely low-cost solution.”

PICKS

  • JP: Machine Learning with JavaScript
  • John: Refactoring UI by Adam Wathan and Steve Schoger -
  • Hard Wired Internet - Ran a Cat 5 Cable from my router - SO WORTH IT.
  continue reading

78 つのエピソード

Tutti gli episodi

×
 
Loading …

プレーヤーFMへようこそ!

Player FMは今からすぐに楽しめるために高品質のポッドキャストをウェブでスキャンしています。 これは最高のポッドキャストアプリで、Android、iPhone、そしてWebで動作します。 全ての端末で購読を同期するためにサインアップしてください。

 

クイックリファレンスガイド

探検しながらこの番組を聞いてください
再生