SlideShare a Scribd company logo
How Can Objects Be Accessed?
If objects can be accessed only through their public interface, how, then, is such
access permitted? One object accesses another object by sending it a message.
Such access, known as a message-send, is the only way one object should access
another. What is involved in message sending?
Message
A message consists of the name of an operation and any required arguments.
When one object sends a message to another object, the sender is requesting that
the receiver of the message perform the named operation and (possibly) return
some information. When the receiver receives the message, it performs the
requested operation in any manner it knows. The request does not specify how an
operation is to be performed. Such information is always hidden from the sender.
The set of messages to which an object can respond is known as the behaviour of
the object. Not all messages an object responds to, however, need to be part of its
publicly accessible interface. An object can send private messages to itself to
implement publicly accessible operations.
…
https://twitter.com/rebeccawb
@rebeccawb
Polymorphism
Limiting object access to a strictly defined interface such as the message-send allows
another use of abstraction known as polymorphism. Polymorphism is the ability of
two or more classes of object to respond to the same message, each in its own way.
This means that an object does not need to know to whom it is sending a message. It
just needs to know that many different kinds of objects have been defined to respond
to that particular message.
Objects of a variety of different, but similar, classes can recognize some of the same
messages and respond in similar, appropriate ways. A response appropriate for one
class of object might be thoroughly inappropriate for another class. The sender need
not be concerned with the method that executes as a result of its message-send.
Polymorphism allows us to recognize and exploit similarities between different
classes of objects. When we recognize that several different kinds of object could
respond to the same message, we recognize the distinction between the message
name and a method. An object sends a message: if the receiver implements a method
with the same signature, it will respond. Different responses are possible; therefore
different methods make sense for instances of different classes, but the sender can
simply send the message without being concerned with the class of the receiver.
…
https://twitter.com/rebeccawb
@rebeccawb
Imagine what software was like before a safe and convenient mechanism for polymorphism was available. In the
typical calling tree, main functions called high-level functions, which called mid-level functions, which called low-level
functions. In that calling tree, however, source code dependencies inexorably followed the flow of control
Source code dependencies versus flow of control
For main to call one of the high-level functions, it had to mention the name of the module that contained that function. In C,
this was a #include. In Java, it was an import statement. In C#, it was a using statement. Indeed, every caller was forced
to mention the name of the module that contained the callee.
This requirement presented the software architect with few, if any, options. The flow of control was dictated by the
behavior of the system, and the source code dependencies were dictated by that flow of control.
@unclebobmartin
When polymorphism is brought into play, however, something very different can happen:
Here, module HL1 calls the F() function in module ML1. The fact that it calls this function through an interface
is a source code contrivance. At runtime, the interface doesn’t exist. HL1 simply calls F() within ML1.
Note, however, that the source code dependency (the inheritance relationship) between ML1 and the interface I points in the opposite
direction compared to the flow of control. This is called dependency inversion, and its implications for the software architect are
profound.
The fact that OO languages provide safe and convenient polymorphism means that any source code dependency, no matter where it is,
can be inverted.
Dependency inversion
Now look back at that calling tree in and its many source code dependencies. Any
of those source code dependencies can be turned around by inserting an
interface between them.
With this approach, software architects working in systems written in OO
languages have absolute control over the direction of all source code
dependencies in the system. They are not constrained to align those
dependencies with the flow of control. No matter which module does the
calling and which module is called, the software architect can point the source
code dependency in either direction.
That is power! That is the power that OO provides. That’s what OO is
really all about—at least from the architect’s point of view.
@unclebobmartin
by Robert Martin
What can you do with that power? As an example, you can rearrange the source code dependencies of your system so that the
database and the user interface (UI) depend on the business rules, rather than the other way around.
This means that the UI and the database can be plugins to the business rules. It means that the source code of the
business rules never mentions the UI or the database.
As a consequence, the business rules, the UI, and the database can be compiled into three separate components or deployment
units (e.g., jar files, DLLs, or Gem files) that have the same dependencies as the source code. The component containing the
business rules will not depend on the components containing the UI and database.
In turn, the business rules can be deployed independently of the UI and the database. Changes to the UI or the
database need not have any effect on the business rules. Those components can be deployed separately and independently.
In short, when the source code in a component changes, only that component needs to be redeployed. This is independent
deployability.
If the modules in your system can be deployed independently, then they can be developed independently by different teams.
That’s independent developability.
The database and the user interface depend on the business rules
@unclebobmartin
by Robert Martin
Core idea driving and defining OO: using dynamic polymorphism to invert key architectural dependencies

More Related Content

PDF
L1803058388
DOCX
Mcs024
PPTX
OOP-Advanced Programming with c++
PPTX
Object modeling
PDF
Oos Short Q N
L1803058388
Mcs024
OOP-Advanced Programming with c++
Object modeling
Oos Short Q N

Similar to Core idea driving and defining OO: using dynamic polymorphism to invert key architectural dependencies (20)

DOCX
Question and answer Programming
PDF
L5
DOC
Abstract
PPTX
Basics of object oriented programming
PPTX
Introduction to OO, Java and Eclipse/WebSphere
PPTX
What is OOP_ (Object Oriented Programming) (1).pptx
PPTX
DOC-20210303-WA0017..pptx,coding stuff in c
PDF
Software Reuse and Object-Oriented Programming
PPTX
01. design pattern
PDF
PPTX
SKILLWISE - OOPS CONCEPT
PPT
Object Oriented Analysis and Design with UML2 part2
PPTX
OOPS – General Understanding in .NET
PPTX
Presentation.pptx
PDF
L03 Software Design
PPTX
C# .NET - Um overview da linguagem
PPTX
CSharp_03_Inheritance_introduction_with_examples
DOCX
Mca2030 object oriented programming – c++
PDF
CS305PC_C++_UNIT 1 notes jntuh third semester
DOCX
Ooad notes
Question and answer Programming
L5
Abstract
Basics of object oriented programming
Introduction to OO, Java and Eclipse/WebSphere
What is OOP_ (Object Oriented Programming) (1).pptx
DOC-20210303-WA0017..pptx,coding stuff in c
Software Reuse and Object-Oriented Programming
01. design pattern
SKILLWISE - OOPS CONCEPT
Object Oriented Analysis and Design with UML2 part2
OOPS – General Understanding in .NET
Presentation.pptx
L03 Software Design
C# .NET - Um overview da linguagem
CSharp_03_Inheritance_introduction_with_examples
Mca2030 object oriented programming – c++
CS305PC_C++_UNIT 1 notes jntuh third semester
Ooad notes
Ad

More from Philip Schwarz (20)

PDF
ApplicativeError functions handling and recovering from errors: A mnemonic to...
PDF
Folding Cheat Sheet Series Titles - a series of 9 decks
PDF
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
PDF
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
PDF
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
PDF
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
PDF
Drawing Heighway’s Dragon - Part 3 - Simplification Through Separation of Con...
PDF
The Open-Closed Principle - Part 2 - The Contemporary Version - An Introduction
PDF
The Open-Closed Principle - Part 1 - The Original Version
PDF
Drawing Heighway’s Dragon - Part II - Recursive Function Simplification - Fro...
PDF
Drawing Heighway’s Dragon - Recursive Function Rewrite - From Imperative Styl...
PDF
Fibonacci Function Gallery - Part 2 - One in a series
PDF
Fibonacci Function Gallery - Part 1 (of a series) - with minor corrections
PDF
Fibonacci Function Gallery - Part 1 (of a series)
PDF
The Debt Metaphor - Ward Cunningham in his 2009 YouTube video
PDF
Folding Cheat Sheet Series Titles (so far)
PDF
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism - An Example
PDF
Folding Cheat Sheet #8 - eighth in a series
PDF
Function Applicative for Great Good of Leap Year Function
PDF
Folding Cheat Sheet #7 - seventh in a series
ApplicativeError functions handling and recovering from errors: A mnemonic to...
Folding Cheat Sheet Series Titles - a series of 9 decks
Folding Cheat Sheet # 9 - List Unfolding 𝑢𝑛𝑓𝑜𝑙𝑑 as the Computational Dual of ...
List Unfolding - 'unfold' as the Computational Dual of 'fold', and how 'unfol...
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
Drawing Heighway’s Dragon - Part 3 - Simplification Through Separation of Con...
The Open-Closed Principle - Part 2 - The Contemporary Version - An Introduction
The Open-Closed Principle - Part 1 - The Original Version
Drawing Heighway’s Dragon - Part II - Recursive Function Simplification - Fro...
Drawing Heighway’s Dragon - Recursive Function Rewrite - From Imperative Styl...
Fibonacci Function Gallery - Part 2 - One in a series
Fibonacci Function Gallery - Part 1 (of a series) - with minor corrections
Fibonacci Function Gallery - Part 1 (of a series)
The Debt Metaphor - Ward Cunningham in his 2009 YouTube video
Folding Cheat Sheet Series Titles (so far)
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism - An Example
Folding Cheat Sheet #8 - eighth in a series
Function Applicative for Great Good of Leap Year Function
Folding Cheat Sheet #7 - seventh in a series
Ad

Recently uploaded (20)

PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Patient Appointment Booking in Odoo with online payment
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Download FL Studio Crack Latest version 2025 ?
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PPTX
assetexplorer- product-overview - presentation
PPTX
Computer Software and OS of computer science of grade 11.pptx
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
CHAPTER 2 - PM Management and IT Context
Patient Appointment Booking in Odoo with online payment
Salesforce Agentforce AI Implementation.pdf
Complete Guide to Website Development in Malaysia for SMEs
Designing Intelligence for the Shop Floor.pdf
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Internet Downloader Manager (IDM) Crack 6.42 Build 41
wealthsignaloriginal-com-DS-text-... (1).pdf
17 Powerful Integrations Your Next-Gen MLM Software Needs
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Weekly report ppt - harsh dattuprasad patel.pptx
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Design an Analysis of Algorithms I-SECS-1021-03
Oracle Fusion HCM Cloud Demo for Beginners
Download FL Studio Crack Latest version 2025 ?
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
assetexplorer- product-overview - presentation
Computer Software and OS of computer science of grade 11.pptx

Core idea driving and defining OO: using dynamic polymorphism to invert key architectural dependencies

  • 1. How Can Objects Be Accessed? If objects can be accessed only through their public interface, how, then, is such access permitted? One object accesses another object by sending it a message. Such access, known as a message-send, is the only way one object should access another. What is involved in message sending? Message A message consists of the name of an operation and any required arguments. When one object sends a message to another object, the sender is requesting that the receiver of the message perform the named operation and (possibly) return some information. When the receiver receives the message, it performs the requested operation in any manner it knows. The request does not specify how an operation is to be performed. Such information is always hidden from the sender. The set of messages to which an object can respond is known as the behaviour of the object. Not all messages an object responds to, however, need to be part of its publicly accessible interface. An object can send private messages to itself to implement publicly accessible operations. … https://twitter.com/rebeccawb @rebeccawb
  • 2. Polymorphism Limiting object access to a strictly defined interface such as the message-send allows another use of abstraction known as polymorphism. Polymorphism is the ability of two or more classes of object to respond to the same message, each in its own way. This means that an object does not need to know to whom it is sending a message. It just needs to know that many different kinds of objects have been defined to respond to that particular message. Objects of a variety of different, but similar, classes can recognize some of the same messages and respond in similar, appropriate ways. A response appropriate for one class of object might be thoroughly inappropriate for another class. The sender need not be concerned with the method that executes as a result of its message-send. Polymorphism allows us to recognize and exploit similarities between different classes of objects. When we recognize that several different kinds of object could respond to the same message, we recognize the distinction between the message name and a method. An object sends a message: if the receiver implements a method with the same signature, it will respond. Different responses are possible; therefore different methods make sense for instances of different classes, but the sender can simply send the message without being concerned with the class of the receiver. … https://twitter.com/rebeccawb @rebeccawb
  • 3. Imagine what software was like before a safe and convenient mechanism for polymorphism was available. In the typical calling tree, main functions called high-level functions, which called mid-level functions, which called low-level functions. In that calling tree, however, source code dependencies inexorably followed the flow of control Source code dependencies versus flow of control For main to call one of the high-level functions, it had to mention the name of the module that contained that function. In C, this was a #include. In Java, it was an import statement. In C#, it was a using statement. Indeed, every caller was forced to mention the name of the module that contained the callee. This requirement presented the software architect with few, if any, options. The flow of control was dictated by the behavior of the system, and the source code dependencies were dictated by that flow of control. @unclebobmartin
  • 4. When polymorphism is brought into play, however, something very different can happen: Here, module HL1 calls the F() function in module ML1. The fact that it calls this function through an interface is a source code contrivance. At runtime, the interface doesn’t exist. HL1 simply calls F() within ML1. Note, however, that the source code dependency (the inheritance relationship) between ML1 and the interface I points in the opposite direction compared to the flow of control. This is called dependency inversion, and its implications for the software architect are profound. The fact that OO languages provide safe and convenient polymorphism means that any source code dependency, no matter where it is, can be inverted. Dependency inversion Now look back at that calling tree in and its many source code dependencies. Any of those source code dependencies can be turned around by inserting an interface between them. With this approach, software architects working in systems written in OO languages have absolute control over the direction of all source code dependencies in the system. They are not constrained to align those dependencies with the flow of control. No matter which module does the calling and which module is called, the software architect can point the source code dependency in either direction. That is power! That is the power that OO provides. That’s what OO is really all about—at least from the architect’s point of view. @unclebobmartin by Robert Martin
  • 5. What can you do with that power? As an example, you can rearrange the source code dependencies of your system so that the database and the user interface (UI) depend on the business rules, rather than the other way around. This means that the UI and the database can be plugins to the business rules. It means that the source code of the business rules never mentions the UI or the database. As a consequence, the business rules, the UI, and the database can be compiled into three separate components or deployment units (e.g., jar files, DLLs, or Gem files) that have the same dependencies as the source code. The component containing the business rules will not depend on the components containing the UI and database. In turn, the business rules can be deployed independently of the UI and the database. Changes to the UI or the database need not have any effect on the business rules. Those components can be deployed separately and independently. In short, when the source code in a component changes, only that component needs to be redeployed. This is independent deployability. If the modules in your system can be deployed independently, then they can be developed independently by different teams. That’s independent developability. The database and the user interface depend on the business rules @unclebobmartin by Robert Martin