SlideShare uma empresa Scribd logo
1 de 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.

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais 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
 

Mais 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
 

Último

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
+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...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

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.

Notas do Editor