Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Replacing 

Conditionals With

Polymorphism
@gpespn
“Any fool can write code that a
computer can understand.
Good programmers write code
that humans can understand.”



-- Ma...
@gpespn
But why?
• Easier to read
• Maintainability
• Extensibility
• Isolation of change
• Easier to test
@gpespn
B+
@gpespn
C-
@gpespn
New Feature!
Guest sessions
@gpespn
@gpespn
F-
@gpespn
I just want to
send a message
to an object
@gpespn
-W
oof!
-M
eow
!
@gpespn
Polymorphism
tell don't ask
@gpespn
@gpespn
@gpespn
@gpespn
still have conditional!
@gpespn
Create a high
level abstract
class
@gpespn
@gpespn
Abstract Subclass Subclass
@gpespn
Polymorphism
@gpespn
@gpespn
Whats the catch?
• Parallel interfaces
• Design patterns that are confusing to those unfamiliar
to them
• New word...
@gpespn
@gpespn
Questions?
Prochain SlideShare
Chargement dans…5
×

Polymorphism ruby

225 vues

Publié le

Replacing Conditionals With Polymorphism

Publié dans : Logiciels

Polymorphism ruby

  1. 1. Replacing Conditionals With Polymorphism @gpespn
  2. 2. “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” -- Martin Fowler @gpespn
  3. 3. @gpespn But why? • Easier to read • Maintainability • Extensibility • Isolation of change • Easier to test
  4. 4. @gpespn B+
  5. 5. @gpespn C-
  6. 6. @gpespn New Feature! Guest sessions
  7. 7. @gpespn
  8. 8. @gpespn F-
  9. 9. @gpespn I just want to send a message to an object
  10. 10. @gpespn -W oof! -M eow !
  11. 11. @gpespn Polymorphism tell don't ask
  12. 12. @gpespn
  13. 13. @gpespn
  14. 14. @gpespn
  15. 15. @gpespn still have conditional!
  16. 16. @gpespn Create a high level abstract class
  17. 17. @gpespn
  18. 18. @gpespn Abstract Subclass Subclass
  19. 19. @gpespn Polymorphism
  20. 20. @gpespn
  21. 21. @gpespn Whats the catch? • Parallel interfaces • Design patterns that are confusing to those unfamiliar to them • New words/vocabulary into application. LOC went up! • Increased big picture complexity in exchange for macro clarity • Too many Objects
  22. 22. @gpespn
  23. 23. @gpespn Questions?

×