SlideShare a Scribd company logo
1 of 20
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Structural Design Patterns Online Training Classes 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Decorator Pattern 
 The Decorator Pattern is used for adding 
additional functionality to a particular object as 
opposed to a class of objects. 
 A Decorator, also known as a Wrapper, is an 
object that has an interface identical to an object 
that it contains. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
• Any calls that the decorator gets, it relays 
to the object that it contains, and adds its 
own functionality along the way, either 
before or after the call. 
• This gives you a lot of flexibility, since 
you can change what the decorator does 
at runtime, as opposed to having the 
change be static and determined at 
compile time by sub classing. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Decorator Pattern 
 A Decorator is a concrete instance of the 
abstract class and is indistinguishable from the 
object that it contains. 
 This can be used to great advantage, as you 
can recursively nest decorators without any 
other objects being able to tell the difference, 
allowing a near infinite amount of 
customization. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
• Decorators add the ability to dynamically 
alter the behavior of an object. 
• Good idea to use in a situation to change 
the behavior of an object repeatedly during 
runtime. 
• It helps to add behavior or responsibilities 
to an object. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Decorator Pattern 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Command pattern 
 A Command pattern is an object behavioral 
pattern used to achieve complete decoupling 
between the sender and the receiver. 
 A sender is an object that invokes an 
operation, and a receiver is an object that 
receives the request to execute a certain 
operation. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
• With decoupling, the sender has no 
knowledge of the Receiver's interface. 
• The term request here refers to the 
command that is to be executed. 
• The Command pattern allows to vary when 
and how a request is fulfilled thus providing 
flexibility as well as extensibility. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Command Pattern 
 Intent: 
 encapsulate a request in an object 
 allows the parameterization of clients with different 
requests 
 allows saving the requests in a queue 
 Implementation: 
 The Client asks for a command to be executed. 
 The Invoker takes the command, encapsulates it 
and places it in a queue, in case there is 
something else to do first, and the 
ConcreteCommand that is in charge of the 
requested info@command, quontrasolutions.sending co.its uk 
result to the
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Command Pattern 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Factory Pattern 
 Factory Method is a creational pattern which 
helps to model an interface for creating an 
object which at creation time can let its 
subclasses decide which class to instantiate. 
 Factory Pattern is responsible for 
"Manufacturing" an Object. 
 It helps to instantiate the appropriate Subclass 
by creating the right Object from a group of 
related classes. 
info@quontrasolutions.co.uk
• The Factory Pattern promotes loose coupling 
by eliminating the need to bind application-specific 
classes into the code. 
• The use of factories gives the programmer 
the opportunity to abstract the specific 
attributes of an Object into specific 
subclasses which create them. 
• Define an interface for creating an object, but 
let the subclasses decide which class to 
instantiate. The Factory method lets a class 
defer instantiation to subclasses.
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Factory Pattern 
info@quontrasolutions.co.uk
Singleton Pattern 
 Singleton involves only one class which is 
responsible to instantiate itself, to make sure it 
creates not more than one instance; in the 
same time it provides a global point of access 
to that instance. 
 The same instance can be used from 
everywhere, being impossible to invoke directly 
the constructor each time. 
 Intent: 
 Ensure that only one instance of a class is 
created. 
 Provide a global point of access to the object.
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Singleton Pattern 
 Implementation: 
 It involves a static member in the "Singleton" 
class, a private constructor and a static public 
method that returns a reference to the static 
member. 
 The Singleton Pattern defines a getInstance 
operation which exposes the unique instance 
which is accessed by the clients. 
 Constructor is not accessible from outside of 
the class. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Singleton: Specific Implementation 
issues 
 Thread-safe implementation: Singletons can be 
used specifically in multi-threaded application to 
make sure the reads/writes are synchronized. 
 Lazy instantiation: Synchronization can be very 
expensive considering the performance. When the 
singleton object is already created it should be 
returned without using any synchronized block. 
 Such optimization consist of checking in an 
unsynchronized block if the object is null and if not 
to check again and create it in an syncronized 
block. This is called double locking mechanism. 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Singleton: Specific Implementation 
issues 
 Early instantiation using static field: The 
singleton object is instantiated when the class 
is loaded and not when it is first used, due to 
the fact that the instance member is declared 
static. 
 Classes loaded by different classloaders: If 
a class(same name, same package) is loaded 
by 2 different classloaders they represents 2 
different clasess in memory. 
info@quontrasolutions.co.uk
• Serialization: If Singleton class implements 
java.io.Serializable interface, when a 
singleton is serialized and then deserialized 
more than once, there will be multiple 
instances of Singleton created. It can be 
avoided by implementing the readResolve 
method. 
• Abstract Factory and Factory Methods 
implemented as singletons: Having 2 
factories might have undesired effects when 
objects are created. Hence, to ensure that a 
factory is nique it should be implemented as 
a singleton, thus avoiding to instantiate the
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Singleton Pattern 
info@quontrasolutions.co.uk
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Visit: http://www.quontrasolutions.co.uk/ 
Email: info@quontrasolutions.co.uk 
Call Now : 20-3734-1498 
info@quontrasolutions.co.uk

More Related Content

Viewers also liked

Design Patterns
Design PatternsDesign Patterns
Design Patterns
soms_1
 
003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...
003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...
003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...
Cavanghetboi Cavangboihet
 

Viewers also liked (10)

Adapter Design Pattern
Adapter Design PatternAdapter Design Pattern
Adapter Design Pattern
 
Domain Driven Design Development Spring Portfolio
Domain Driven Design Development Spring PortfolioDomain Driven Design Development Spring Portfolio
Domain Driven Design Development Spring Portfolio
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...
003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...
003 obf600105 gpon ma5608 t basic operation and maintenance v8r15 issue1.02 (...
 
A Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation SlidesA Practical Guide to Domain Driven Design: Presentation Slides
A Practical Guide to Domain Driven Design: Presentation Slides
 
Domain Driven Design 101
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101
 
Domain Driven Design using Laravel
Domain Driven Design using LaravelDomain Driven Design using Laravel
Domain Driven Design using Laravel
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014Domain Driven Design with the F# type System -- F#unctional Londoners 2014
Domain Driven Design with the F# type System -- F#unctional Londoners 2014
 
Cfb boiler basic design, operation and maintenance
Cfb boiler basic design, operation and maintenanceCfb boiler basic design, operation and maintenance
Cfb boiler basic design, operation and maintenance
 

More from Quontra Solutions

Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
Quontra Solutions
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
Quontra Solutions
 
Network security by quontra solutions uk
Network security by quontra solutions ukNetwork security by quontra solutions uk
Network security by quontra solutions uk
Quontra Solutions
 
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra SolutionsInformatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Quontra Solutions
 
Informatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutionsInformatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutions
Quontra Solutions
 
Dataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsDataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra Solutions
Quontra Solutions
 

More from Quontra Solutions (13)

Java Constructors with examples - Quontra Solutions
Java Constructors with examples  - Quontra SolutionsJava Constructors with examples  - Quontra Solutions
Java Constructors with examples - Quontra Solutions
 
Oracle-12c Online Training by Quontra Solutions
 Oracle-12c Online Training by Quontra Solutions Oracle-12c Online Training by Quontra Solutions
Oracle-12c Online Training by Quontra Solutions
 
Test Automation Framework Online Training by QuontraSolutions
Test Automation Framework Online Training by QuontraSolutionsTest Automation Framework Online Training by QuontraSolutions
Test Automation Framework Online Training by QuontraSolutions
 
Enterprise java beans
Enterprise java beansEnterprise java beans
Enterprise java beans
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
 
DataMining and OLAP Technology Concepts Presented By Quontra Solutions
DataMining and OLAP Technology Concepts Presented By Quontra SolutionsDataMining and OLAP Technology Concepts Presented By Quontra Solutions
DataMining and OLAP Technology Concepts Presented By Quontra Solutions
 
Network security by quontra solutions uk
Network security by quontra solutions ukNetwork security by quontra solutions uk
Network security by quontra solutions uk
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutions
 
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra SolutionsInformatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
 
Informatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutionsInformatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutions
 
Dataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsDataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra Solutions
 
Selenium overview ppt by quontra solutions
Selenium overview ppt by quontra solutionsSelenium overview ppt by quontra solutions
Selenium overview ppt by quontra solutions
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 

Structural design patterns by quontra solutions

  • 1. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Structural Design Patterns Online Training Classes info@quontrasolutions.co.uk
  • 2. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Decorator Pattern  The Decorator Pattern is used for adding additional functionality to a particular object as opposed to a class of objects.  A Decorator, also known as a Wrapper, is an object that has an interface identical to an object that it contains. info@quontrasolutions.co.uk
  • 3. www.quontrasolutions.co.uk info@quontrasolutions.co.uk • Any calls that the decorator gets, it relays to the object that it contains, and adds its own functionality along the way, either before or after the call. • This gives you a lot of flexibility, since you can change what the decorator does at runtime, as opposed to having the change be static and determined at compile time by sub classing. info@quontrasolutions.co.uk
  • 4. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Decorator Pattern  A Decorator is a concrete instance of the abstract class and is indistinguishable from the object that it contains.  This can be used to great advantage, as you can recursively nest decorators without any other objects being able to tell the difference, allowing a near infinite amount of customization. info@quontrasolutions.co.uk
  • 5. www.quontrasolutions.co.uk info@quontrasolutions.co.uk • Decorators add the ability to dynamically alter the behavior of an object. • Good idea to use in a situation to change the behavior of an object repeatedly during runtime. • It helps to add behavior or responsibilities to an object. info@quontrasolutions.co.uk
  • 7. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Command pattern  A Command pattern is an object behavioral pattern used to achieve complete decoupling between the sender and the receiver.  A sender is an object that invokes an operation, and a receiver is an object that receives the request to execute a certain operation. info@quontrasolutions.co.uk
  • 8. www.quontrasolutions.co.uk info@quontrasolutions.co.uk • With decoupling, the sender has no knowledge of the Receiver's interface. • The term request here refers to the command that is to be executed. • The Command pattern allows to vary when and how a request is fulfilled thus providing flexibility as well as extensibility. info@quontrasolutions.co.uk
  • 9. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Command Pattern  Intent:  encapsulate a request in an object  allows the parameterization of clients with different requests  allows saving the requests in a queue  Implementation:  The Client asks for a command to be executed.  The Invoker takes the command, encapsulates it and places it in a queue, in case there is something else to do first, and the ConcreteCommand that is in charge of the requested info@command, quontrasolutions.sending co.its uk result to the
  • 11. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Factory Pattern  Factory Method is a creational pattern which helps to model an interface for creating an object which at creation time can let its subclasses decide which class to instantiate.  Factory Pattern is responsible for "Manufacturing" an Object.  It helps to instantiate the appropriate Subclass by creating the right Object from a group of related classes. info@quontrasolutions.co.uk
  • 12. • The Factory Pattern promotes loose coupling by eliminating the need to bind application-specific classes into the code. • The use of factories gives the programmer the opportunity to abstract the specific attributes of an Object into specific subclasses which create them. • Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.
  • 14. Singleton Pattern  Singleton involves only one class which is responsible to instantiate itself, to make sure it creates not more than one instance; in the same time it provides a global point of access to that instance.  The same instance can be used from everywhere, being impossible to invoke directly the constructor each time.  Intent:  Ensure that only one instance of a class is created.  Provide a global point of access to the object.
  • 15. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Singleton Pattern  Implementation:  It involves a static member in the "Singleton" class, a private constructor and a static public method that returns a reference to the static member.  The Singleton Pattern defines a getInstance operation which exposes the unique instance which is accessed by the clients.  Constructor is not accessible from outside of the class. info@quontrasolutions.co.uk
  • 16. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Singleton: Specific Implementation issues  Thread-safe implementation: Singletons can be used specifically in multi-threaded application to make sure the reads/writes are synchronized.  Lazy instantiation: Synchronization can be very expensive considering the performance. When the singleton object is already created it should be returned without using any synchronized block.  Such optimization consist of checking in an unsynchronized block if the object is null and if not to check again and create it in an syncronized block. This is called double locking mechanism. info@quontrasolutions.co.uk
  • 17. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Singleton: Specific Implementation issues  Early instantiation using static field: The singleton object is instantiated when the class is loaded and not when it is first used, due to the fact that the instance member is declared static.  Classes loaded by different classloaders: If a class(same name, same package) is loaded by 2 different classloaders they represents 2 different clasess in memory. info@quontrasolutions.co.uk
  • 18. • Serialization: If Singleton class implements java.io.Serializable interface, when a singleton is serialized and then deserialized more than once, there will be multiple instances of Singleton created. It can be avoided by implementing the readResolve method. • Abstract Factory and Factory Methods implemented as singletons: Having 2 factories might have undesired effects when objects are created. Hence, to ensure that a factory is nique it should be implemented as a singleton, thus avoiding to instantiate the
  • 20. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Visit: http://www.quontrasolutions.co.uk/ Email: info@quontrasolutions.co.uk Call Now : 20-3734-1498 info@quontrasolutions.co.uk