SlideShare a Scribd company logo
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

More Related Content

What's hot

soft computing manoj
soft computing manojsoft computing manoj
soft computing manoj
Manoj Yadav
 
Soft computing abstracts
Soft computing abstractsSoft computing abstracts
Soft computing abstractsabctry
 
Basics of Soft Computing
Basics of Soft  Computing Basics of Soft  Computing
Basics of Soft Computing
Sangeetha Rajesh
 
Soft computing
Soft computing Soft computing
Soft computing
Arvind sahu
 
An Introduction to Soft Computing
An Introduction to Soft ComputingAn Introduction to Soft Computing
An Introduction to Soft ComputingTameem Ahmad
 
Introduction to Soft Computing
Introduction to Soft Computing Introduction to Soft Computing
Introduction to Soft Computing
Aakash Kumar
 
Introduction to Soft Computing
Introduction to Soft ComputingIntroduction to Soft Computing
Introduction to Soft Computing
Geethika Ramani Ravinutala
 
Soft computing
Soft computingSoft computing
Soft computing
PrathimaDS1
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
Dr. C.V. Suresh Babu
 
Final grasp ASE
Final grasp ASEFinal grasp ASE
Final grasp ASE
babak danyal
 
Kiran computer
Kiran computerKiran computer
Kiran computer
Kiran Gohil
 
Soft computing
Soft computingSoft computing
Soft computing
Nabarun Paul
 
soft-computing
 soft-computing soft-computing
soft-computingstudent
 
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
Souvik Dutta
 
SoftComputing1
SoftComputing1SoftComputing1
SoftComputing1
DrPrafullNarooka
 
Knowledgebase vs Database
Knowledgebase vs DatabaseKnowledgebase vs Database
Knowledgebase vs Database
CJ Jenkins
 

What's hot (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
 

Similar to Patterns of Assigning Responsibilities

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
pkaviya
 
Advanced oop laws, principles, idioms
Advanced oop laws, principles, idiomsAdvanced oop laws, principles, idioms
Advanced oop laws, principles, idioms
Clint Edmonson
 
Basics of object oriented programming
Basics of object oriented programmingBasics of object oriented programming
Basics of object oriented programming
Nitin Kumar Kashyap
 
Advanced OOP - Laws, Principles, Idioms
Advanced OOP - Laws, Principles, IdiomsAdvanced OOP - Laws, Principles, Idioms
Advanced OOP - Laws, Principles, Idioms
Clint Edmonson
 
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
 
Writing Quality Code
Writing Quality CodeWriting Quality Code
Writing Quality Code
indikaMaligaspe
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
agnes_crepet
 
CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4CS8592-OOAD Lecture Notes Unit-4
CS8592-OOAD Lecture Notes Unit-4
Gobinath Subramaniam
 
Four principles seminar manageware seminar
Four principles seminar   manageware seminarFour principles seminar   manageware seminar
Four principles seminar manageware seminarManageware
 
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 fabricationharshit2013
 
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
Jason Morris
 
Structured Software Design
Structured Software DesignStructured Software Design
Structured Software Design
Giorgio Zoppi
 
Bt8901 objective oriented systems1
Bt8901 objective oriented systems1Bt8901 objective oriented systems1
Bt8901 objective oriented systems1
Techglyphs
 
Operationalizing Machine Learning in the Enterprise
Operationalizing Machine Learning in the EnterpriseOperationalizing Machine Learning in the Enterprise
Operationalizing Machine Learning in the Enterprise
mark madsen
 
Technology in financial services
Technology in financial servicesTechnology in financial services
Technology in financial services
Luis Caldeira
 
Technology in financial services
Technology in financial servicesTechnology in financial services
Technology in financial services
Luis Caldeira
 
Rapid software evolution
Rapid software evolutionRapid software evolution
Rapid software evolutionborislav
 
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
 

Similar to 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
 

Recently uploaded

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

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

Editor's Notes

  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.