SlideShare a Scribd company logo
You want to encapsulate at all times.



This initializer is focused on initialization. Setters
guard their respective attributes (e.g. in this case,
legal values for gender and status).


Hide direct attribute access even within the class.
Public API should be
useful without
having to view
implementation
details.



If this is not the
case, improve your
method signatures.
!
How often do you
look at public API
method
implementations
offered by Gems?
Why do you people
indent private and
protected methods?



When followed
consistently by a
team, developers
then know indented
code is likely the
implementation
details of a class.
Modules and
concerns seem
convenient, but
there are some
cons.



They require
reviewing an out of
view file to know the
API.
!
Spurious methods
can enter into the
API.
!
Alternative:
!
Consider class-based composition.
!
Needs no explanation. We’ve all done it.
Export coupling. FeedingTube is coupled to a receiver
role which is played by the SlaveHuman instance.
Nil coupling. No coupling, but you better have two
instances or your program is uninteresting.
!
Or consider String or Math classes as better examples
of nil coupling; the above example could be argued as
coupled. :)
Beware of methods on a class that seem
to be using accessors or methods of another
class and few of its own.
!
You may be writing a method that belongs on
that other class.
!
Changes there may break you here.
There could be some argument here if a SlaveHuman
is really just a role that a Human plays.
!
The decision hinges on new and different behavior.
This model implies that the Human doesn’t digest
food.



This is not true in the real world, but our model need
only apply to the problem domain.
Services
Really en vogue now. Extract it to a service!
A service should mediate between classes only when it
makes no sense for any one of them to do so
themselves. Consider whether one class has
authoritative knowledge before separating out to a
service.
Lots of services yield an anemic object model; classes
are stripped of behavior they should own.
Services are great, just be sure you’ve thought it through.
Problem
A room requires heat when its temperature is
greater than 72 and occupied.
!
How shall we code it?
Often seen. LeakyRoom leaks its details to allow
the GodFurnace to take on too much responsibility.
Well-place responsibilities. Did it all start with
discipline at the public API level?
God Classes
• There are two kinds of God classes:
• One that performs services by orchestrating
object collaborations. Less data, more
methods.
• One that contains data that others need.
Fewer methods, lots of data.
Sometimes the real world is the wrong thing to model
after.
!
In this case, the building is more authoritative on
targeting and damage, so the messaging is flipped.
!
The wonderful thing about O-O design is that you get
to create your own world which abides by your laws of
physics.
Down the rabbit hole of
Object thinking...
Free your mind
Tank, we need more
O-O KNOWLEDGE
programs...
Object Design
DDD
Code Patterns
10 Object-Oriented Design Heuristics for Rubyists

More Related Content

Viewers also liked

I Realize Lean Startup Hack-nov2010
I Realize Lean Startup Hack-nov2010I Realize Lean Startup Hack-nov2010
I Realize Lean Startup Hack-nov2010TOP-IX Consortium
 
Heuristics 101: Understanding and Applying Design Principles
Heuristics 101: Understanding and Applying Design PrinciplesHeuristics 101: Understanding and Applying Design Principles
Heuristics 101: Understanding and Applying Design Principles
Kamaria Campbell
 
Towards the Design of Heuristics by Means of Self-Assembly
Towards the Design of Heuristics by Means of Self-AssemblyTowards the Design of Heuristics by Means of Self-Assembly
Towards the Design of Heuristics by Means of Self-Assembly
German Terrazas
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
Kawsar Ahmed
 
User Experience Design Heuristics
User Experience Design HeuristicsUser Experience Design Heuristics
User Experience Design Heuristics
Nathanael Boehm
 
CS101- Introduction to Computing- Lecture 24
CS101- Introduction to Computing- Lecture 24CS101- Introduction to Computing- Lecture 24
CS101- Introduction to Computing- Lecture 24
Bilal Ahmed
 
Algorithm Design
Algorithm DesignAlgorithm Design
Algorithm Design
MD.ASHIQUZZAMAN KHONDAKER
 
Algorithm Design and Complexity - Course 4 - Heaps and Dynamic Progamming
Algorithm Design and Complexity - Course 4 - Heaps and Dynamic ProgammingAlgorithm Design and Complexity - Course 4 - Heaps and Dynamic Progamming
Algorithm Design and Complexity - Course 4 - Heaps and Dynamic Progamming
Traian Rebedea
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
kim.mens
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm designNahid Hasan
 

Viewers also liked (10)

I Realize Lean Startup Hack-nov2010
I Realize Lean Startup Hack-nov2010I Realize Lean Startup Hack-nov2010
I Realize Lean Startup Hack-nov2010
 
Heuristics 101: Understanding and Applying Design Principles
Heuristics 101: Understanding and Applying Design PrinciplesHeuristics 101: Understanding and Applying Design Principles
Heuristics 101: Understanding and Applying Design Principles
 
Towards the Design of Heuristics by Means of Self-Assembly
Towards the Design of Heuristics by Means of Self-AssemblyTowards the Design of Heuristics by Means of Self-Assembly
Towards the Design of Heuristics by Means of Self-Assembly
 
Algorithm Design Presentation
Algorithm Design PresentationAlgorithm Design Presentation
Algorithm Design Presentation
 
User Experience Design Heuristics
User Experience Design HeuristicsUser Experience Design Heuristics
User Experience Design Heuristics
 
CS101- Introduction to Computing- Lecture 24
CS101- Introduction to Computing- Lecture 24CS101- Introduction to Computing- Lecture 24
CS101- Introduction to Computing- Lecture 24
 
Algorithm Design
Algorithm DesignAlgorithm Design
Algorithm Design
 
Algorithm Design and Complexity - Course 4 - Heaps and Dynamic Progamming
Algorithm Design and Complexity - Course 4 - Heaps and Dynamic ProgammingAlgorithm Design and Complexity - Course 4 - Heaps and Dynamic Progamming
Algorithm Design and Complexity - Course 4 - Heaps and Dynamic Progamming
 
Object-Oriented Design Heuristics
Object-Oriented Design HeuristicsObject-Oriented Design Heuristics
Object-Oriented Design Heuristics
 
Our presentation on algorithm design
Our presentation on algorithm designOur presentation on algorithm design
Our presentation on algorithm design
 

Similar to 10 Object-Oriented Design Heuristics for Rubyists

Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
Özge Nur KOÇ
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
Metin Ogurlu
 
Six of the Best
Six of the BestSix of the Best
Six of the Best
Kevlin Henney
 
Zend Framework And Doctrine
Zend Framework And DoctrineZend Framework And Doctrine
Zend Framework And Doctrine
isaaczfoster
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
Jeroen Hildering
 
Dealing with Obese Models
Dealing with Obese ModelsDealing with Obese Models
Dealing with Obese Models
Ryan Brunner
 
Object oriented thinking
Object oriented thinkingObject oriented thinking
Object oriented thinking
Minal Maniar
 
Break the-rules
Break the-rulesBreak the-rules
Break the-rules
Gokul Nk
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
nofakeNews
 
How to fix bug or defects in software
How to fix bug or defects in software How to fix bug or defects in software
How to fix bug or defects in software
Rajasekar Subramanian
 
SAD05 - Encapsulation
SAD05 - EncapsulationSAD05 - Encapsulation
SAD05 - Encapsulation
Michael Heron
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
Sameh Deabes
 
Refactoring
RefactoringRefactoring
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
yassin elhadedy
 
Top 5 performance problems in .net applications application performance mon...
Top 5 performance problems in .net applications   application performance mon...Top 5 performance problems in .net applications   application performance mon...
Top 5 performance problems in .net applications application performance mon...
KennaaTol
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
TobiasGoeschel
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
Clint Edmonson
 
Where i put my business logic - Greach 2014, Madrid, Spain
Where i put my business logic  - Greach 2014, Madrid, SpainWhere i put my business logic  - Greach 2014, Madrid, Spain
Where i put my business logic - Greach 2014, Madrid, Spain
Antonio de la Torre Fernández
 
Rebecca parsons agile east
Rebecca parsons   agile eastRebecca parsons   agile east
Rebecca parsons agile eastKmanthei
 

Similar to 10 Object-Oriented Design Heuristics for Rubyists (20)

Bad Smells in Code
Bad Smells in CodeBad Smells in Code
Bad Smells in Code
 
Principled And Clean Coding
Principled And Clean CodingPrincipled And Clean Coding
Principled And Clean Coding
 
Six of the Best
Six of the BestSix of the Best
Six of the Best
 
Zend Framework And Doctrine
Zend Framework And DoctrineZend Framework And Doctrine
Zend Framework And Doctrine
 
Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
 
Dealing with Obese Models
Dealing with Obese ModelsDealing with Obese Models
Dealing with Obese Models
 
Object oriented thinking
Object oriented thinkingObject oriented thinking
Object oriented thinking
 
Break the-rules
Break the-rulesBreak the-rules
Break the-rules
 
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdfJAVA VIVA QUESTIONS_CODERS LODGE.pdf
JAVA VIVA QUESTIONS_CODERS LODGE.pdf
 
How to fix bug or defects in software
How to fix bug or defects in software How to fix bug or defects in software
How to fix bug or defects in software
 
SAD05 - Encapsulation
SAD05 - EncapsulationSAD05 - Encapsulation
SAD05 - Encapsulation
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Refactoring
RefactoringRefactoring
Refactoring
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Top 5 performance problems in .net applications application performance mon...
Top 5 performance problems in .net applications   application performance mon...Top 5 performance problems in .net applications   application performance mon...
Top 5 performance problems in .net applications application performance mon...
 
Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
 
Where i put my business logic - Greach 2014, Madrid, Spain
Where i put my business logic  - Greach 2014, Madrid, SpainWhere i put my business logic  - Greach 2014, Madrid, Spain
Where i put my business logic - Greach 2014, Madrid, Spain
 
Clean Code
Clean CodeClean Code
Clean Code
 
Rebecca parsons agile east
Rebecca parsons   agile eastRebecca parsons   agile east
Rebecca parsons agile east
 

Recently uploaded

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 

Recently uploaded (20)

Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 

10 Object-Oriented Design Heuristics for Rubyists

  • 1.
  • 2.
  • 3.
  • 4.
  • 5. You want to encapsulate at all times.
 
 This initializer is focused on initialization. Setters guard their respective attributes (e.g. in this case, legal values for gender and status). 
 Hide direct attribute access even within the class.
  • 6.
  • 7.
  • 8. Public API should be useful without having to view implementation details.
 
 If this is not the case, improve your method signatures. ! How often do you look at public API method implementations offered by Gems?
  • 9. Why do you people indent private and protected methods?
 
 When followed consistently by a team, developers then know indented code is likely the implementation details of a class.
  • 10. Modules and concerns seem convenient, but there are some cons.
 
 They require reviewing an out of view file to know the API. ! Spurious methods can enter into the API. ! Alternative: ! Consider class-based composition. !
  • 11.
  • 12. Needs no explanation. We’ve all done it.
  • 13.
  • 14. Export coupling. FeedingTube is coupled to a receiver role which is played by the SlaveHuman instance.
  • 15. Nil coupling. No coupling, but you better have two instances or your program is uninteresting. ! Or consider String or Math classes as better examples of nil coupling; the above example could be argued as coupled. :)
  • 16.
  • 17. Beware of methods on a class that seem to be using accessors or methods of another class and few of its own. ! You may be writing a method that belongs on that other class. ! Changes there may break you here.
  • 18.
  • 19. There could be some argument here if a SlaveHuman is really just a role that a Human plays. ! The decision hinges on new and different behavior. This model implies that the Human doesn’t digest food.
 
 This is not true in the real world, but our model need only apply to the problem domain.
  • 20.
  • 21. Services Really en vogue now. Extract it to a service! A service should mediate between classes only when it makes no sense for any one of them to do so themselves. Consider whether one class has authoritative knowledge before separating out to a service. Lots of services yield an anemic object model; classes are stripped of behavior they should own. Services are great, just be sure you’ve thought it through.
  • 22.
  • 23. Problem A room requires heat when its temperature is greater than 72 and occupied. ! How shall we code it?
  • 24. Often seen. LeakyRoom leaks its details to allow the GodFurnace to take on too much responsibility.
  • 25. Well-place responsibilities. Did it all start with discipline at the public API level?
  • 26.
  • 27. God Classes • There are two kinds of God classes: • One that performs services by orchestrating object collaborations. Less data, more methods. • One that contains data that others need. Fewer methods, lots of data.
  • 28.
  • 29. Sometimes the real world is the wrong thing to model after. ! In this case, the building is more authoritative on targeting and damage, so the messaging is flipped. ! The wonderful thing about O-O design is that you get to create your own world which abides by your laws of physics.
  • 30. Down the rabbit hole of Object thinking...
  • 32. Tank, we need more O-O KNOWLEDGE programs...
  • 34. DDD