Artwork

Kandungan disediakan oleh iteration podcast, John Jacob, and JP Sio - Web Developers. Semua kandungan podcast termasuk episod, grafik dan perihalan podcast dimuat naik dan disediakan terus oleh iteration podcast, John Jacob, and JP Sio - Web Developers atau rakan kongsi platform podcast mereka. Jika anda percaya seseorang menggunakan karya berhak cipta anda tanpa kebenaran anda, anda boleh mengikuti proses yang digariskan di sini https://ms.player.fm/legal.
Player FM - Aplikasi Podcast
Pergi ke luar talian dengan aplikasi Player FM !

Inheritance At Its Core

43:59
 
Kongsi
 

Manage episode 226071168 series 1900125
Kandungan disediakan oleh iteration podcast, John Jacob, and JP Sio - Web Developers. Semua kandungan podcast termasuk episod, grafik dan perihalan podcast dimuat naik dan disediakan terus oleh iteration podcast, John Jacob, and JP Sio - Web Developers atau rakan kongsi platform podcast mereka. Jika anda percaya seseorang menggunakan karya berhak cipta anda tanpa kebenaran anda, anda boleh mengikuti proses yang digariskan di sini https://ms.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 episod

Artwork

Inheritance At Its Core

iteration

96 subscribers

published

iconKongsi
 
Manage episode 226071168 series 1900125
Kandungan disediakan oleh iteration podcast, John Jacob, and JP Sio - Web Developers. Semua kandungan podcast termasuk episod, grafik dan perihalan podcast dimuat naik dan disediakan terus oleh iteration podcast, John Jacob, and JP Sio - Web Developers atau rakan kongsi platform podcast mereka. Jika anda percaya seseorang menggunakan karya berhak cipta anda tanpa kebenaran anda, anda boleh mengikuti proses yang digariskan di sini https://ms.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 episod

Alle afleveringen

×
 
Loading …

Selamat datang ke Player FM

Player FM mengimbas laman-laman web bagi podcast berkualiti tinggi untuk anda nikmati sekarang. Ia merupakan aplikasi podcast terbaik dan berfungsi untuk Android, iPhone, dan web. Daftar untuk melaraskan langganan merentasi peranti.

 

Panduan Rujukan Pantas

Podcast Teratas
Dengar rancangan ini semasa anda meneroka
Main