SlideShare ist ein Scribd-Unternehmen logo
1 von 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.

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie Design Patterns Course Overview

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
 

Ähnlich wie Design Patterns Course Overview (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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 

Kürzlich hochgeladen (20)

UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 

Design Patterns Course Overview

  • 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.

Hinweis der Redaktion