SlideShare a Scribd company logo
1 of 12
Design pattern
kiennt10@techcombank.com.vn
Design pattern categories
• Creational Patterns
• These design patterns provide a way to create objects while hiding the creation logic,
rather than instantiating objects directly using new opreator. This gives program
more flexibility in deciding which objects need to be created for a given use case.
• Structural Patterns
• These design patterns concern class and object composition. Concept of inheritance
is used to compose interfaces and define ways to compose objects to obtain new
functionalities.
• Behavioral Patterns
• These design patterns are specifically concerned with communication between
objects.
• J2EE Patterns
• These design patterns are specifically concerned with the presentation tier. These
patterns are identified by Sun Java Center.
Factory Pattern
• One of most used design pattern in Java
• Create object without exposing the creation logic to the client
and refer to newly created object using a common interface
Factory Pattern
• Pros
• Allows you to hide implementation of an application seam (the core interfaces
that make up your application)
• Allows you to easily test the seam of an application (that is to mock/stub)
certain parts of your application so you can build and test the other parts
• Allows you to change the design of your application more readily, this is
known as loose coupling
• Con's
• Makes code more difficult to read as all of your code is behind an abstraction
that may in turn hide abstractions
• Can be classed as an anti-pattern when it is incorrectly used, for example
some people use it to wire up a whole application when using an IOC
container, instead use Dependency Injection.
• Too much abstract 
Factory Pattern: Installation
• Procedural Solution - switch/case noob instantiation
• Most simple and intuitive
• Add new concrete product call we should modify the Factory class? ->
not very flexible
Factory Pattern: Installation
Factory Pattern: Reflection
• Class Registration - reflection
Discussion
• Factory Pattern vs Dependency Injection?
Visitor Pattern
• What is that?
• Behavior pattern category
• Do the right thing based on the type of two objects
• When: Lets you define a new operation without changing the classes
of the elements on which it operates
• Real world example
• Shopping cart when you shopping in supermarket which include product a,
product b…
• The cashier acts as a visitor, taking the disparate set of elements. Some of
them using prices, some need to be weighted to provide you total
Visitor Pattern: How
Visitor Pattern: Example
Visitor Pattern: Pros & Cons
• PROs
• Allows you to add operations to a Composite structure without changing the
structure itself
• Adding new operations is relatively easy
• The code for operations performed by the Visitor is centralized
• CONs
• Encapsulation is broken when the Visitor is used
• Because the traversal function is involved, changes to the Composite
structure are more difficult

More Related Content

Viewers also liked

Basics fashion design construction (2009)bbs
Basics fashion design construction (2009)bbsBasics fashion design construction (2009)bbs
Basics fashion design construction (2009)bbs
Mia Delos Santos
 
The secret behind psychology..
The secret behind psychology..The secret behind psychology..
The secret behind psychology..
Clark Balido
 
Fashion and clothing in ancient civilisations
Fashion and clothing in ancient civilisationsFashion and clothing in ancient civilisations
Fashion and clothing in ancient civilisations
mswilsonri
 

Viewers also liked (14)

Patternmaking
PatternmakingPatternmaking
Patternmaking
 
Basics fashion design construction (2009)bbs
Basics fashion design construction (2009)bbsBasics fashion design construction (2009)bbs
Basics fashion design construction (2009)bbs
 
Hunting primes (a caccia di primi) 27 ott 2014
Hunting primes (a caccia di primi)   27 ott 2014Hunting primes (a caccia di primi)   27 ott 2014
Hunting primes (a caccia di primi) 27 ott 2014
 
Industrial Phycology - Polishing Effluents, Recycling Nutrients, Low Carbon B...
Industrial Phycology - Polishing Effluents, Recycling Nutrients, Low Carbon B...Industrial Phycology - Polishing Effluents, Recycling Nutrients, Low Carbon B...
Industrial Phycology - Polishing Effluents, Recycling Nutrients, Low Carbon B...
 
The secret behind psychology..
The secret behind psychology..The secret behind psychology..
The secret behind psychology..
 
Psychology unit 1 developmental psychology
Psychology unit 1   developmental psychologyPsychology unit 1   developmental psychology
Psychology unit 1 developmental psychology
 
Psyche Introduction 2
Psyche Introduction 2Psyche Introduction 2
Psyche Introduction 2
 
Phycology basic presentation
Phycology  basic presentationPhycology  basic presentation
Phycology basic presentation
 
Garment Design & Construction 1 - Skirt Block
Garment Design & Construction 1 - Skirt BlockGarment Design & Construction 1 - Skirt Block
Garment Design & Construction 1 - Skirt Block
 
Fashion and clothing in ancient civilisations
Fashion and clothing in ancient civilisationsFashion and clothing in ancient civilisations
Fashion and clothing in ancient civilisations
 
Pattern Making Deparment
Pattern Making DeparmentPattern Making Deparment
Pattern Making Deparment
 
Pattern magic vol. 1
Pattern magic vol. 1Pattern magic vol. 1
Pattern magic vol. 1
 
Flat pattern
Flat pattern Flat pattern
Flat pattern
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar to Weekly Meeting: Basic Design Pattern

Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP
 

Similar to Weekly Meeting: Basic Design Pattern (20)

Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelinesMobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
 
Sitecore mvc
Sitecore mvcSitecore mvc
Sitecore mvc
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and BeyondEntity Framework: To the Unit of Work Design Pattern and Beyond
Entity Framework: To the Unit of Work Design Pattern and Beyond
 
Introduction to DDD
Introduction to DDDIntroduction to DDD
Introduction to DDD
 
OOP -interface and objects.pptx
OOP -interface and objects.pptxOOP -interface and objects.pptx
OOP -interface and objects.pptx
 
Design Pattern lecture 2
Design Pattern lecture 2Design Pattern lecture 2
Design Pattern lecture 2
 
Creational Patterns
Creational PatternsCreational Patterns
Creational Patterns
 
Porting the Legacy Application to Composite Application Guidance
Porting the Legacy Application to Composite Application GuidancePorting the Legacy Application to Composite Application Guidance
Porting the Legacy Application to Composite Application Guidance
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
Decision CAMP 2014 - Erik Marutian - Using rules-based gui framework to power...
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Alex Theedom Java ee revisits design patterns
Alex Theedom	Java ee revisits design patternsAlex Theedom	Java ee revisits design patterns
Alex Theedom Java ee revisits design patterns
 
SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"SE2016 Java Alex Theedom "Java EE revisits design patterns"
SE2016 Java Alex Theedom "Java EE revisits design patterns"
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Software Design principales
Software Design principalesSoftware Design principales
Software Design principales
 

Recently uploaded

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 

Weekly Meeting: Basic Design Pattern

  • 2. Design pattern categories • Creational Patterns • These design patterns provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new opreator. This gives program more flexibility in deciding which objects need to be created for a given use case. • Structural Patterns • These design patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities. • Behavioral Patterns • These design patterns are specifically concerned with communication between objects. • J2EE Patterns • These design patterns are specifically concerned with the presentation tier. These patterns are identified by Sun Java Center.
  • 3. Factory Pattern • One of most used design pattern in Java • Create object without exposing the creation logic to the client and refer to newly created object using a common interface
  • 4. Factory Pattern • Pros • Allows you to hide implementation of an application seam (the core interfaces that make up your application) • Allows you to easily test the seam of an application (that is to mock/stub) certain parts of your application so you can build and test the other parts • Allows you to change the design of your application more readily, this is known as loose coupling • Con's • Makes code more difficult to read as all of your code is behind an abstraction that may in turn hide abstractions • Can be classed as an anti-pattern when it is incorrectly used, for example some people use it to wire up a whole application when using an IOC container, instead use Dependency Injection. • Too much abstract 
  • 5. Factory Pattern: Installation • Procedural Solution - switch/case noob instantiation • Most simple and intuitive • Add new concrete product call we should modify the Factory class? -> not very flexible
  • 7. Factory Pattern: Reflection • Class Registration - reflection
  • 8. Discussion • Factory Pattern vs Dependency Injection?
  • 9. Visitor Pattern • What is that? • Behavior pattern category • Do the right thing based on the type of two objects • When: Lets you define a new operation without changing the classes of the elements on which it operates • Real world example • Shopping cart when you shopping in supermarket which include product a, product b… • The cashier acts as a visitor, taking the disparate set of elements. Some of them using prices, some need to be weighted to provide you total
  • 12. Visitor Pattern: Pros & Cons • PROs • Allows you to add operations to a Composite structure without changing the structure itself • Adding new operations is relatively easy • The code for operations performed by the Visitor is centralized • CONs • Encapsulation is broken when the Visitor is used • Because the traversal function is involved, changes to the Composite structure are more difficult