SlideShare une entreprise Scribd logo
1  sur  34
Design Patterns Course
Ahmed Soliman
Silence Please!
Session 1

Introduction
What is so special about design patterns?
OO Design Principles
Strategy
Meet the Observer Pattern.
OO Basics

Abstraction
Encapsulation
Polymorphism
Inheritance
What is so special about
design patterns?
 At any given moment, somewhere in the world,
 someone struggles with the same software design
 problems you have. But better yet, someone has
 already solved your software design problems.
 Tried-and-true, road-tested, successfully used by
 developers to create functional, elegant, reusable, and
 flexible software.
Use inheritance
                                  Duck



   The Duck Game
                                  MallardDuck
                                  RedhedDuck

                                  Quack()
                                  Swim()
                                  Display()

                                  Someone wants fly()




                                  Use Interfaces
                                  Quackable
                                  Swimmable
                                  Flyable


       Let’s Design it together   Code reuse?

                                  Waiting for a design
                                  pattern to save the
                                  day? No :P




Design Priciple 1
Identify the aspects of
your application that
vary and separate them
from what stays the
same.
The one constant in
software development
The one constant in
software development


   CHANGE
Adding a spice of flexibility

       Design Priciple 2
       Program to an interface,
       not an implementation
OO Design Principles


Indentify the aspects of your application that vary and
separate them from what stays the same.
Program to an interface, not an implementation.
Favor composition over inheritance
Strategy pattern


  Defines a family of algorithms, encapsulates each one,
 and make them interchangeable.
 Strategy lets the algorithm vary independently from
 clients that use it.
So?

How do I use design patterns?
If design patterns are so great, why can’t somebody
build a library of them so I don’t have to?
Aren’t libraries and frameworks also design patterns?
Knowing OO basics is enough? What makes me a
good OO designer?
The Observer Pattern
Observer Pattern
The most heavily used pattern in the JDK
Publisher + subscriber = Observer Pattern
Defines a one-to-many relationship.
State monitor.
Definition: defines one-to-many dependency between
objects so that when one object changes state, all of
its dependencies are notified and updated
automatically.
Session 2

Design Patterns Categories
Decorating your Objects (Decorator)
Factory Pattern
Factory Method Pattern
DP Categories
Creational
  Concern the ways and means of object instantiation
Structural
  Deal with the mutual composition of classes or
  objects.
Behavioral
  Analyze the ways in which classes or objects interact
  and distribute responsibilities among them.
Starbuzz Coffe

Beverage
  getDescription()
  getCost()
  HouseBlend, DarkRoast, Decaf, Espresso.
OO Design Principles



Classes should be open for for extension, but closed
for modification. (Open-Closed Principle)
Decorator Pattern


Attach additional responsibilities to an object
dynamically.
Decorators provide a flexible alternative to subclassing
for extending functionality.
Factory Pattern



 Pizza and PizzaStore
Factory Method Pattern


Defines an interface for creating an object, but lets
subclasses decide which class to instantiate. Factory
Method lets a class defer instantiation to subclasses.
Session 3

Singleton Pattern
Command Pattern
Adapter Pattern
Facade Pattern
Singleton Pattern

 One of a kind objects.
 Static initializers?
 Private constructors? Useful?
 Ensures a class has only one instance, and provide a
 global point of access to it.
Command Pattern


Encapsulates a request as an object, thereby letting
you parameterize other objects with different requests,
queue or log requests, and support undoable
operations.
Adapter and Facade
Patterns
Adapter pattern: converts the interface of a class into
another interface the clients expect. Adapters lets
classes work together that couldn’t otherwise because
of incompatible interfaces.
Facade pattern: provides a unified interface to a set of
interfaces in a subsystem. Facade defines a higher-
level interface that makes the subsystem easier to use.
OO Design Principle


Least Knowledge: talk only to your immediate friends.
How java violates it?
How facade use it?
Session 4


Iterator Pattern
Composite Pattern
State Pattern
Iterator Pattern


 Provides a way to access the elements of an aggregate
 object (collection) sequentially without exposing its
 underlying representation.
OO Design Principle

Single Responsibility: A class should have only one
reason to change.
Cohesion: a term measures how closely a class or a
module supports a single purpose or responsibility.
High Cohesion -> if a class is designed around a set of
related functions.
Composite Pattern


Allows you to compose objects into tree structures to
represent part-whole hierarchies, Composite lets clients
treat individual objects and compositions of objects
uniformly.
Session 5

State Pattern
Proxy Pattern
Compound Patterns
Discussion
State pattern

 A little known fact: the strategy and state patterns were
 twins separated at birth.
 Allows an object to alter its behavior when its internal
 state changes. The object will appear to change its
 class.
Proxy Pattern

Remote Proxy.
Virtual proxy.
Protection proxy.
Definition: Provides a surrogate or placeholder for
another object to control access to it.
Compound Patterns

Patterns are often used together and combined within
the same design solution.
A compound pattern combines two or more patterns
into a solution that solves a recurring or general
problem.

Contenu connexe

Tendances

3.o o design -_____________lecture 3
3.o o design -_____________lecture 33.o o design -_____________lecture 3
3.o o design -_____________lecture 3Warui Maina
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
 
SOLID Principles and Design Patterns
SOLID Principles and Design PatternsSOLID Principles and Design Patterns
SOLID Principles and Design PatternsGanesh Samarthyam
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 
Introduction to Object Oriented Design
Introduction to Object Oriented DesignIntroduction to Object Oriented Design
Introduction to Object Oriented DesignOleg Yaroshevych
 

Tendances (9)

3.o o design -_____________lecture 3
3.o o design -_____________lecture 33.o o design -_____________lecture 3
3.o o design -_____________lecture 3
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
SOLID Principles and Design Patterns
SOLID Principles and Design PatternsSOLID Principles and Design Patterns
SOLID Principles and Design Patterns
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Introduction to Object Oriented Design
Introduction to Object Oriented DesignIntroduction to Object Oriented Design
Introduction to Object Oriented Design
 
Design pattern
Design patternDesign pattern
Design pattern
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 

En vedette

The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design PrinciplesSteve Zhang
 
Community manager: gestión de comunidades virtuales AERCO - PSM
Community manager: gestión de comunidades virtuales AERCO - PSMCommunity manager: gestión de comunidades virtuales AERCO - PSM
Community manager: gestión de comunidades virtuales AERCO - PSMJuan Carlos Mejía Llano
 
Community Manager y Herramientas de Marketing 2.0
Community Manager y Herramientas de Marketing 2.0Community Manager y Herramientas de Marketing 2.0
Community Manager y Herramientas de Marketing 2.0Jayguer Vásquez
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
Plantilla para crear publicaciones facebook
Plantilla para crear publicaciones facebookPlantilla para crear publicaciones facebook
Plantilla para crear publicaciones facebookalixcecilia
 
Web api 2 With MVC 5 With TrainerKrunal
Web api 2 With MVC 5 With TrainerKrunalWeb api 2 With MVC 5 With TrainerKrunal
Web api 2 With MVC 5 With TrainerKrunalKrunal Trivedi
 

En vedette (7)

ASP.NET MVC Web API
ASP.NET MVC Web APIASP.NET MVC Web API
ASP.NET MVC Web API
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 
Community manager: gestión de comunidades virtuales AERCO - PSM
Community manager: gestión de comunidades virtuales AERCO - PSMCommunity manager: gestión de comunidades virtuales AERCO - PSM
Community manager: gestión de comunidades virtuales AERCO - PSM
 
Community Manager y Herramientas de Marketing 2.0
Community Manager y Herramientas de Marketing 2.0Community Manager y Herramientas de Marketing 2.0
Community Manager y Herramientas de Marketing 2.0
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
Plantilla para crear publicaciones facebook
Plantilla para crear publicaciones facebookPlantilla para crear publicaciones facebook
Plantilla para crear publicaciones facebook
 
Web api 2 With MVC 5 With TrainerKrunal
Web api 2 With MVC 5 With TrainerKrunalWeb api 2 With MVC 5 With TrainerKrunal
Web api 2 With MVC 5 With TrainerKrunal
 

Similaire à Design Patterns Course

Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro anshu_atri
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Javawiradikusuma
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignIrwansyah Irwansyah
 
Software design and Architecture.pptx
Software design and Architecture.pptxSoftware design and Architecture.pptx
Software design and Architecture.pptxSHAHZAIBABBAS13
 
Design patterns in brief
Design patterns in briefDesign patterns in brief
Design patterns in briefDUONG Trong Tan
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java scriptAmit Thakkar
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringWhy Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringProtelo, Inc.
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsMichael Heron
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2Ankit Dubey
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patternsAmit Kabra
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsJuan Lopez
 

Similaire à Design Patterns Course (20)

Oops design pattern intro
Oops design pattern intro Oops design pattern intro
Oops design pattern intro
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Practical OOP In Java
Practical OOP In JavaPractical OOP In Java
Practical OOP In Java
 
Solid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven DesignSolid principles, Design Patterns, and Domain Driven Design
Solid principles, Design Patterns, and Domain Driven Design
 
Software design and Architecture.pptx
Software design and Architecture.pptxSoftware design and Architecture.pptx
Software design and Architecture.pptx
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
Design patterns in brief
Design patterns in briefDesign patterns in brief
Design patterns in brief
 
Design pattern in an expressive language java script
Design pattern in an expressive language java scriptDesign pattern in an expressive language java script
Design pattern in an expressive language java script
 
Why Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software EngineeringWhy Design Patterns Are Important In Software Engineering
Why Design Patterns Are Important In Software Engineering
 
PATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design PatternsPATTERNS01 - An Introduction to Design Patterns
PATTERNS01 - An Introduction to Design Patterns
 
Module 2 design patterns-2
Module 2   design patterns-2Module 2   design patterns-2
Module 2 design patterns-2
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Spring fundamentals
Spring fundamentalsSpring fundamentals
Spring fundamentals
 
Dependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and PatternsDependency Injection, Design Principles and Patterns
Dependency Injection, Design Principles and Patterns
 
Shuzworld Analysis
Shuzworld AnalysisShuzworld Analysis
Shuzworld Analysis
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Dtacs
DtacsDtacs
Dtacs
 

Plus de Ahmed Soliman

Introduction to Really.io
Introduction to Really.ioIntroduction to Really.io
Introduction to Really.ioAhmed Soliman
 
A Journey to Reactive Function Programming
A Journey to Reactive Function ProgrammingA Journey to Reactive Function Programming
A Journey to Reactive Function ProgrammingAhmed Soliman
 
Intro to distributed systems
Intro to distributed systemsIntro to distributed systems
Intro to distributed systemsAhmed Soliman
 
Lego bricks of cloud applications
Lego bricks of cloud applicationsLego bricks of cloud applications
Lego bricks of cloud applicationsAhmed Soliman
 
Introduction to Cloud Computing
Introduction to Cloud ComputingIntroduction to Cloud Computing
Introduction to Cloud ComputingAhmed Soliman
 
العباقرة يصنعون لا يولدون
العباقرة يصنعون لا يولدونالعباقرة يصنعون لا يولدون
العباقرة يصنعون لا يولدونAhmed Soliman
 
Geniuses are made not born 2
Geniuses are made not born 2Geniuses are made not born 2
Geniuses are made not born 2Ahmed Soliman
 
Geniuses are made, not born
Geniuses are made, not bornGeniuses are made, not born
Geniuses are made, not bornAhmed Soliman
 

Plus de Ahmed Soliman (9)

Introduction to Really.io
Introduction to Really.ioIntroduction to Really.io
Introduction to Really.io
 
A Journey to Reactive Function Programming
A Journey to Reactive Function ProgrammingA Journey to Reactive Function Programming
A Journey to Reactive Function Programming
 
Intro to distributed systems
Intro to distributed systemsIntro to distributed systems
Intro to distributed systems
 
Lego bricks of cloud applications
Lego bricks of cloud applicationsLego bricks of cloud applications
Lego bricks of cloud applications
 
Introduction to Cloud Computing
Introduction to Cloud ComputingIntroduction to Cloud Computing
Introduction to Cloud Computing
 
العباقرة يصنعون لا يولدون
العباقرة يصنعون لا يولدونالعباقرة يصنعون لا يولدون
العباقرة يصنعون لا يولدون
 
NoSQL Introduction
NoSQL IntroductionNoSQL Introduction
NoSQL Introduction
 
Geniuses are made not born 2
Geniuses are made not born 2Geniuses are made not born 2
Geniuses are made not born 2
 
Geniuses are made, not born
Geniuses are made, not bornGeniuses are made, not born
Geniuses are made, not born
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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 TerraformAndrey Devyatkin
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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...apidays
 
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 WorkerThousandEyes
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
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 2024The Digital Insurer
 
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 WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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...
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Design Patterns Course

  • 3. Session 1 Introduction What is so special about design patterns? OO Design Principles Strategy Meet the Observer Pattern.
  • 5. What is so special about design patterns? At any given moment, somewhere in the world, someone struggles with the same software design problems you have. But better yet, someone has already solved your software design problems. Tried-and-true, road-tested, successfully used by developers to create functional, elegant, reusable, and flexible software.
  • 6. Use inheritance Duck The Duck Game MallardDuck RedhedDuck Quack() Swim() Display() Someone wants fly() Use Interfaces Quackable Swimmable Flyable Let’s Design it together Code reuse? Waiting for a design pattern to save the day? No :P Design Priciple 1 Identify the aspects of your application that vary and separate them from what stays the same.
  • 7. The one constant in software development
  • 8. The one constant in software development CHANGE
  • 9. Adding a spice of flexibility Design Priciple 2 Program to an interface, not an implementation
  • 10. OO Design Principles Indentify the aspects of your application that vary and separate them from what stays the same. Program to an interface, not an implementation. Favor composition over inheritance
  • 11. Strategy pattern Defines a family of algorithms, encapsulates each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
  • 12. So? How do I use design patterns? If design patterns are so great, why can’t somebody build a library of them so I don’t have to? Aren’t libraries and frameworks also design patterns? Knowing OO basics is enough? What makes me a good OO designer?
  • 14. Observer Pattern The most heavily used pattern in the JDK Publisher + subscriber = Observer Pattern Defines a one-to-many relationship. State monitor. Definition: defines one-to-many dependency between objects so that when one object changes state, all of its dependencies are notified and updated automatically.
  • 15. Session 2 Design Patterns Categories Decorating your Objects (Decorator) Factory Pattern Factory Method Pattern
  • 16. DP Categories Creational Concern the ways and means of object instantiation Structural Deal with the mutual composition of classes or objects. Behavioral Analyze the ways in which classes or objects interact and distribute responsibilities among them.
  • 17. Starbuzz Coffe Beverage getDescription() getCost() HouseBlend, DarkRoast, Decaf, Espresso.
  • 18. OO Design Principles Classes should be open for for extension, but closed for modification. (Open-Closed Principle)
  • 19. Decorator Pattern Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
  • 20. Factory Pattern Pizza and PizzaStore
  • 21. Factory Method Pattern Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  • 22. Session 3 Singleton Pattern Command Pattern Adapter Pattern Facade Pattern
  • 23. Singleton Pattern One of a kind objects. Static initializers? Private constructors? Useful? Ensures a class has only one instance, and provide a global point of access to it.
  • 24. Command Pattern Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
  • 25. Adapter and Facade Patterns Adapter pattern: converts the interface of a class into another interface the clients expect. Adapters lets classes work together that couldn’t otherwise because of incompatible interfaces. Facade pattern: provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher- level interface that makes the subsystem easier to use.
  • 26. OO Design Principle Least Knowledge: talk only to your immediate friends. How java violates it? How facade use it?
  • 27. Session 4 Iterator Pattern Composite Pattern State Pattern
  • 28. Iterator Pattern Provides a way to access the elements of an aggregate object (collection) sequentially without exposing its underlying representation.
  • 29. OO Design Principle Single Responsibility: A class should have only one reason to change. Cohesion: a term measures how closely a class or a module supports a single purpose or responsibility. High Cohesion -> if a class is designed around a set of related functions.
  • 30. Composite Pattern Allows you to compose objects into tree structures to represent part-whole hierarchies, Composite lets clients treat individual objects and compositions of objects uniformly.
  • 31. Session 5 State Pattern Proxy Pattern Compound Patterns Discussion
  • 32. State pattern A little known fact: the strategy and state patterns were twins separated at birth. Allows an object to alter its behavior when its internal state changes. The object will appear to change its class.
  • 33. Proxy Pattern Remote Proxy. Virtual proxy. Protection proxy. Definition: Provides a surrogate or placeholder for another object to control access to it.
  • 34. Compound Patterns Patterns are often used together and combined within the same design solution. A compound pattern combines two or more patterns into a solution that solves a recurring or general problem.

Notes de l'éditeur