SlideShare ist ein Scribd-Unternehmen logo
1 von 19
AmirdhaGopalRajendran X-Conf  Thoughtworks, Chennai Patterns of assigning Responsibilities The critical design tool for software development is  a MIND well educated in DESIGN PRINCIPLES.  – Craig Larman
Setting the Context Pattern Responsibility Domain Model Patterns Creator Information Expert Pure Fabrication Indirection Polymorphism Protected Variation Related Patterns References Introduction Life can only be understood backwards, but it must be lived forwards. – Soren Kierkegaard
Pattern is an abstractsolution to a recurring problem, in a particular context. Larman: A good pattern is a named and well-knownproblem/solution pair that can be applied in new contexts. Design Pattern:  Notto express new design ideas.  Codify Existing tried-and-true knowledge, idioms and principles GRASP - General Responsibility Assignment Software Patterns or Principles.  Pattern One person’s pattern is another person’s primitive building block. – GoF
Responsibilities are obligations of an object in terms of its behaviour. Doing: Doing something itself, such as creating an object or doing a calculation Initiating action in other objects Controlling and coordinating activities in other objects. Knowing: Knowing about private encapsulated data Knowing about related objects Knowing about things it can derive or calculate Responsibility Understanding responsibilities is key to good object-oriented design.  -Martin Fowler
Domain Model It’s all very well in practice, but it will never work in theory. -Management Maxim
Who is responsible for creating SalesLineItem?
Who should be responsible for creating a new instance of some class? Assign class B the responsibility to create an instance of class A if one or more of the following is true: B aggregates A B contains A B records instance of A objects B closely use A objects B passes initializing data to A Delegate complex creation logic to Concrete Factory or Abstract Factory. Benefits Low Coupling Creator
How to determine the grandTotal?
What is the general principle of assigning responsibilities to objects? Assign a responsibility to the information expert – the class that has the information necessary to fulfill the responsibility. ContraIndication Undesirable in some situations, because of coupling and cohesion Benefits Information Encapsulation Distribution of behaviour – more cohesive “lightweight” class definitions Information Expert
How to Save the Sale to Database? SaleRepository Sale Load(intsaleId) void Save(Sale sale) …
What object should have the responsibility, when not to violate High Cohesion and Low Coupling? Assign a highly cohesive set of responsibilities to an artificial class, that does not represent a problem domain, in order to support high cohesion, low coupling, and reuse. Design of Objects Representational Decomposition – Domain Things Behavioral Decomposition – Algorithms ContraIndications Overuse – too many behavior objects. Benefits High Cohesion Reuse potential because of  fine-grained Pure Fabrication. Virtually, all design patterns are Pure Fabrications Pure Fabrication
How to avoid direct coupling between Sale and External Tax Systems?
Where to assign a responsibility, to avoid direct coupling between two things?  Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. Benefits Low Coupling Many pure fabrications are generated because of Indirection Many Existing design patterns are specialization of Indirection. Indirection Most problems in computer science can be solved by  another level of indirection. Most problems in performance can be solved by  removing another level of indirection .
How to handle multiple Payment Types?
How handle alternatives based on type?  When alternate behaviours are selected based on the type of an object, use polymorphic method call to select the behaviour, rather than using if statement to test the type. “Giving the same name to services in different objects” ContraIndications Speculative “future-proofing” – unnecessary effort Benefits: New variations are easy to add. Clients are not affected. Polymorphism
How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesirable impact on other elements? Identify points of predicted variation or instability; assign responsibilities to create a stable interface around them. Very important, fundamental principle of software design. Points of Change (Hot spots)   Variation Point, Evolution Point Mechanisms motivated by PV Service Lookups, Virtual Machines, Standard Languages, etc… Same as Information Hiding and Open-Closed Priciple. Protected Variation
Controller High Cohesion Low Coupling Law of Demeter Principle of Least Knowledge Only talk to your immediate friends Related Patterns Not everything that can be counted counts,  and not everything that counts can be counted. -Albert Einstein
References Measuring programming progress by lines of code  is like measuring aircraft building progress by weight -Bill Gates
Thank you Intelligence is the ability to avoid doing work,  yet getting the work done.  -LinusTorvalds

Weitere ähnliche Inhalte

Was ist angesagt?

Soft computing abstracts
Soft computing abstractsSoft computing abstracts
Soft computing abstracts
abctry
 
An Introduction to Soft Computing
An Introduction to Soft ComputingAn Introduction to Soft Computing
An Introduction to Soft Computing
Tameem Ahmad
 
soft-computing
 soft-computing soft-computing
soft-computing
student
 

Was ist angesagt? (17)

soft computing manoj
soft computing manojsoft computing manoj
soft computing manoj
 
Soft computing abstracts
Soft computing abstractsSoft computing abstracts
Soft computing abstracts
 
Basics of Soft Computing
Basics of Soft  Computing Basics of Soft  Computing
Basics of Soft Computing
 
Soft computing
Soft computing Soft computing
Soft computing
 
An Introduction to Soft Computing
An Introduction to Soft ComputingAn Introduction to Soft Computing
An Introduction to Soft Computing
 
Introduction to Soft Computing
Introduction to Soft Computing Introduction to Soft Computing
Introduction to Soft Computing
 
Introduction to Soft Computing
Introduction to Soft ComputingIntroduction to Soft Computing
Introduction to Soft Computing
 
Soft computing
Soft computingSoft computing
Soft computing
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
 
Soft computing01
Soft computing01Soft computing01
Soft computing01
 
Final grasp ASE
Final grasp ASEFinal grasp ASE
Final grasp ASE
 
Kiran computer
Kiran computerKiran computer
Kiran computer
 
Soft computing
Soft computingSoft computing
Soft computing
 
soft-computing
 soft-computing soft-computing
soft-computing
 
Application of soft computing techniques in electrical engineering
Application of soft computing techniques in electrical engineeringApplication of soft computing techniques in electrical engineering
Application of soft computing techniques in electrical engineering
 
SoftComputing1
SoftComputing1SoftComputing1
SoftComputing1
 
Knowledgebase vs Database
Knowledgebase vs DatabaseKnowledgebase vs Database
Knowledgebase vs Database
 

Ähnlich wie Patterns of Assigning Responsibilities

The Black Box: Interpretability, Reproducibility, and Data Management
The Black Box: Interpretability, Reproducibility, and Data ManagementThe Black Box: Interpretability, Reproducibility, and Data Management
The Black Box: Interpretability, Reproducibility, and Data Management
mark madsen
 
Four principles seminar manageware seminar
Four principles seminar   manageware seminarFour principles seminar   manageware seminar
Four principles seminar manageware seminar
Manageware
 
Algorithmic thinking and digital fabrication (1) (2)
Algorithmic thinking and digital fabrication (1) (2)Algorithmic thinking and digital fabrication (1) (2)
Algorithmic thinking and digital fabrication (1) (2)
Prabhat Kumar
 
Algorithmic thinking and digital fabrication
Algorithmic thinking and digital fabricationAlgorithmic thinking and digital fabrication
Algorithmic thinking and digital fabrication
harshit2013
 
Rapid software evolution
Rapid software evolutionRapid software evolution
Rapid software evolution
borislav
 

Ähnlich wie Patterns of Assigning Responsibilities (20)

CS8592 Object Oriented Analysis & Design - UNIT IV
CS8592 Object Oriented Analysis & Design - UNIT IV CS8592 Object Oriented Analysis & Design - UNIT IV
CS8592 Object Oriented Analysis & Design - UNIT IV
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
 
Oops Concepts
Oops ConceptsOops Concepts
Oops Concepts
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programming
 
Advanced OOP - Laws, Principles, Idioms
Advanced OOP - Laws, Principles, IdiomsAdvanced OOP - Laws, Principles, Idioms
Advanced OOP - Laws, Principles, Idioms
 
The Black Box: Interpretability, Reproducibility, and Data Management
The Black Box: Interpretability, Reproducibility, and Data ManagementThe Black Box: Interpretability, Reproducibility, and Data Management
The Black Box: Interpretability, Reproducibility, and Data Management
 
Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4
 
Four principles seminar manageware seminar
Four principles seminar   manageware seminarFour principles seminar   manageware seminar
Four principles seminar manageware seminar
 
Algorithmic thinking and digital fabrication (1) (2)
Algorithmic thinking and digital fabrication (1) (2)Algorithmic thinking and digital fabrication (1) (2)
Algorithmic thinking and digital fabrication (1) (2)
 
Algorithmic thinking and digital fabrication
Algorithmic thinking and digital fabricationAlgorithmic thinking and digital fabrication
Algorithmic thinking and digital fabrication
 
The Role Of Ontology In Modern Expert Systems Dallas 2008
The Role Of Ontology In Modern Expert Systems   Dallas   2008The Role Of Ontology In Modern Expert Systems   Dallas   2008
The Role Of Ontology In Modern Expert Systems Dallas 2008
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
 
Operationalizing Machine Learning in the Enterprise
Operationalizing Machine Learning in the EnterpriseOperationalizing Machine Learning in the Enterprise
Operationalizing Machine Learning in the Enterprise
 
Technology in financial services
Technology in financial servicesTechnology in financial services
Technology in financial services
 
Technology in financial services
Technology in financial servicesTechnology in financial services
Technology in financial services
 
Rapid software evolution
Rapid software evolutionRapid software evolution
Rapid software evolution
 
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
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 

Patterns of Assigning Responsibilities

  • 1. AmirdhaGopalRajendran X-Conf Thoughtworks, Chennai Patterns of assigning Responsibilities The critical design tool for software development is a MIND well educated in DESIGN PRINCIPLES. – Craig Larman
  • 2. Setting the Context Pattern Responsibility Domain Model Patterns Creator Information Expert Pure Fabrication Indirection Polymorphism Protected Variation Related Patterns References Introduction Life can only be understood backwards, but it must be lived forwards. – Soren Kierkegaard
  • 3. Pattern is an abstractsolution to a recurring problem, in a particular context. Larman: A good pattern is a named and well-knownproblem/solution pair that can be applied in new contexts. Design Pattern: Notto express new design ideas. Codify Existing tried-and-true knowledge, idioms and principles GRASP - General Responsibility Assignment Software Patterns or Principles. Pattern One person’s pattern is another person’s primitive building block. – GoF
  • 4. Responsibilities are obligations of an object in terms of its behaviour. Doing: Doing something itself, such as creating an object or doing a calculation Initiating action in other objects Controlling and coordinating activities in other objects. Knowing: Knowing about private encapsulated data Knowing about related objects Knowing about things it can derive or calculate Responsibility Understanding responsibilities is key to good object-oriented design. -Martin Fowler
  • 5. Domain Model It’s all very well in practice, but it will never work in theory. -Management Maxim
  • 6. Who is responsible for creating SalesLineItem?
  • 7. Who should be responsible for creating a new instance of some class? Assign class B the responsibility to create an instance of class A if one or more of the following is true: B aggregates A B contains A B records instance of A objects B closely use A objects B passes initializing data to A Delegate complex creation logic to Concrete Factory or Abstract Factory. Benefits Low Coupling Creator
  • 8. How to determine the grandTotal?
  • 9. What is the general principle of assigning responsibilities to objects? Assign a responsibility to the information expert – the class that has the information necessary to fulfill the responsibility. ContraIndication Undesirable in some situations, because of coupling and cohesion Benefits Information Encapsulation Distribution of behaviour – more cohesive “lightweight” class definitions Information Expert
  • 10. How to Save the Sale to Database? SaleRepository Sale Load(intsaleId) void Save(Sale sale) …
  • 11. What object should have the responsibility, when not to violate High Cohesion and Low Coupling? Assign a highly cohesive set of responsibilities to an artificial class, that does not represent a problem domain, in order to support high cohesion, low coupling, and reuse. Design of Objects Representational Decomposition – Domain Things Behavioral Decomposition – Algorithms ContraIndications Overuse – too many behavior objects. Benefits High Cohesion Reuse potential because of fine-grained Pure Fabrication. Virtually, all design patterns are Pure Fabrications Pure Fabrication
  • 12. How to avoid direct coupling between Sale and External Tax Systems?
  • 13. Where to assign a responsibility, to avoid direct coupling between two things? Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. Benefits Low Coupling Many pure fabrications are generated because of Indirection Many Existing design patterns are specialization of Indirection. Indirection Most problems in computer science can be solved by another level of indirection. Most problems in performance can be solved by removing another level of indirection .
  • 14. How to handle multiple Payment Types?
  • 15. How handle alternatives based on type? When alternate behaviours are selected based on the type of an object, use polymorphic method call to select the behaviour, rather than using if statement to test the type. “Giving the same name to services in different objects” ContraIndications Speculative “future-proofing” – unnecessary effort Benefits: New variations are easy to add. Clients are not affected. Polymorphism
  • 16. How to design objects, subsystems, and systems so that the variations or instability in these elements does not have an undesirable impact on other elements? Identify points of predicted variation or instability; assign responsibilities to create a stable interface around them. Very important, fundamental principle of software design. Points of Change (Hot spots) Variation Point, Evolution Point Mechanisms motivated by PV Service Lookups, Virtual Machines, Standard Languages, etc… Same as Information Hiding and Open-Closed Priciple. Protected Variation
  • 17. Controller High Cohesion Low Coupling Law of Demeter Principle of Least Knowledge Only talk to your immediate friends Related Patterns Not everything that can be counted counts, and not everything that counts can be counted. -Albert Einstein
  • 18. References Measuring programming progress by lines of code is like measuring aircraft building progress by weight -Bill Gates
  • 19. Thank you Intelligence is the ability to avoid doing work, yet getting the work done.  -LinusTorvalds

Hinweis der Redaktion

  1. Common Relationships - Composite aggregates Part - Container contains Content - Recorder records RecordedA composite object is an excellent candidate to make its parts.When creation requires significant complexity, delegate creation to a helper class called Concrete Factory or Abstract Factory.Benefits: Low coupling is supported
  2. Frequently used in the assignment of responsibilities.Undesirable in some situations, because of problems in coupling and cohesion.Eg: Who should be responsible for saving a sale in a database?By Expert, it should be in Sale class, which leads to cohesion, coupling and duplication problem.Benefits: - Information encapsulation is maintained, which supports low coupling. - Distribution of behaviour across the classes, thus encouraging more cohesive “lightweight” class definitions.
  3. What object should have the responsibility, when you do not wantto violate High Cohesion and Low Coupling, or other goals, but solutions offered by Expert (for example) are not appropriate?Pure Fabrication – Idiom – implies making something up.The responsibilities are shifted from the Expert class to the Pure Fabrication.Design of Objects:Representational Decomposition – Represents things in DomainBehavioral Decomposition - AlgorithmsPreserves low coupling and high cohesion.Virtually, all design patterns are Pure Fabrications.
  4. Where to assign a responsibility, to avoid direct coupling between two things? How to de-couple objects so that low coupling is supported and reuse potential remains higher?Pure Fabrications are generated because of Indirection.
  5. Very important, fundamental principle of software design.Eg:Data Driven DesignsService LookupUniform AccessStandard LanguagesTwo points of change: Variation Point Evolution PointInformation Hiding: Hide Information about the design from other modules, at the points of difficulty or likely change.Open Closed Principle: Modules should be both open (for extension; adaptable) and closed (the module is closed to modification in ways that affect clients.)ContraIndications and Benefits are same as Polymorphism.
  6. Controller:What first object beyond the UI layer receives and coordinates (“Controls”) a system operation?Assign the responsibility to an object representing one of these choicesRepresents the overall “system”, a “root object” (façade controller)Represents a use case scenario (session controller)Law of DemeterWithin a method, messages should only be sent to the following objectsThe this object (or self)A parameter of the methodAn attribute of thisAn element of a collection which is an attribute of this.An object created within the method.