SlideShare a Scribd company logo
Creational
Patterns
Dr. Himanshu Hora
SRMS college of Engineering & Technology
Bareilly (UP) INDIA
Contents
 Introduction
 Types of Creational Pattern
 Why use Creational Pattern
 The Factory Pattern
 The factory Design Pattern
 Abstract factory
 The Singleton
 Summary
 References
Introduction
 Creational design patterns are design
patterns that deal with object creation
mechanisms, trying to create objects in a
manner suitable to the situation.
Creational Patterns
 There are three creational patterns
 The Factory
 The Abstract Factory
 The Singleton
Why Use A Creational Pattern?
 Some situations are more complex than simple
instantiation can handle.
 Imagine for example you want to create an entirely ‘
skinnable’ look and feel for an application.
 Some situations have complex consequences if
objects aren’t instantiated in the right way or the
right order.
 Some situations require that only one object is
ever created.
The Factory Pattern
 The Factory is used to provide a consistent
interface to setup properly configured objects.
 It can be represented by a single class
containing a single static method.
 More complex factories exist, dealing with more
complex situations.
The Factory Design Pattern
 Imagine a simple class hierarchy:
The Factory Design Pattern
 Now imagine you are creating a simple
drawing package.
 User selects a shape
 User clicks on the screen
 Application draws the shape.
 This can all be hard-coded directly into an
application.
The Factory Design Pattern
 Instead, we use a factory to generate specific
objects, through the power of polymorphism.
 Polymorphism is key to the way a Factory works.
 The system that drives a factory is that all these
shapes have a common parent class.
 All we need is the Shape object that is
represented by specific objects.
Another Example
 Let’s say we have a file that we have created
in our application.
 We now want to export it to a different file
format.
 Each file format has its own peculiarities.
 We could hard-code this into our application.
The Factory Design Pattern
 The Factory Pattern reduces hard-coded
complexity.
 The Factory Pattern properly devolves
responsibility to individual objects.
 However, the Factory pattern by itself is
limited to certain simple contexts.
The Abstract Factory
 The next level of abstraction is the Abstract
Factory.
 This is a Factory for factories.
 Imagine here we have slightly more
complicated situations.
 Designing an interface that allows for
different themes.
 A file conversion application that must allow
for different versions of different formats.
The Abstract Factory
 We could handle these with a factory by itself.
 This introduces the same combinatorial
problems that the factory is designed to
resolve.
 A simple rule to remember is – coding
combinations is usually bad design.
 Bad design causes trouble later on.
 When doing anything more substantial than
simple ‘proof of concept’ applications.
The Consequence
 Entirely new suites of themes can be added to
this system without risking combinatorial
explosion.
 The ‘operational’ code is also much tighter and
more focused.
The Singleton
 The Factory and Abstract Factory handle
structural creation issues.
 They fix several aspects of bad design with
regards to creating objects.
 The Singleton is designed to increase data
consistency.
 One of the problems that must be managed
with object orientation is inter-object
communication.
The Singleton
 This is fine in most situations.
 However, when dealing with objects that
contain ‘live data’, it becomes problematic.
 Each object has its own copy of the data.
 It would be much better if all objects had
access to the same copy of the data.
 That is hard to manage effectively.
The Singleton
 The Singleton pattern resolves this by ensuring a
single interface to the creation of an object.
 Objects cannot be created with new, they must be
created through a method.
 This method is responsible for ensuring only one
live version of an object.
 If one exists, it sends that out.
 If it doesn’t, it creates it and then sends it out.
 The pattern is very simple.
 But offers great improvements in data consistency.
Summary
 Creational Patterns manage the complexity of
object instantiations.
 They make it easier to manage the combinatorial
explosion that comes along with certain kinds of
object creation schemes.
 The Factory allows for the creation of
properly configured objects.
 The Abstract Factory is a factory for factories.
 The Singleton ensures data consistency by
restricting instantiation of objects.
References
 Presentation session notes including link to this
session, will be available on
http://learningaboutfudge.blogspot.com
 All the source for this session is publically
available at:
https://github.com/SheepWorx/Training
 RSS Feed:
http://learningaboutfudge.blogspot.com/feeds/post
s/default?alt=rss
 Local Network: dmeyer-msharetrainingCode
Like a Ninja
 Source was compiled using Visual Studio 2012
 http://www.gofpatterns.com/
Thank You
Dr. Himanshu Hora
SRMS college of Engineering & Technology
Bareilly (UP) INDIA

More Related Content

PPTX
Design Pattern - Singleton Pattern
PDF
Introduction to Design Pattern
PPT
Structural patterns
PDF
Gof design pattern
PDF
Java Design Patterns Tutorial | Edureka
PPTX
Gof design patterns
PPTX
The Singleton Pattern Presentation
PPTX
Let us understand design pattern
Design Pattern - Singleton Pattern
Introduction to Design Pattern
Structural patterns
Gof design pattern
Java Design Patterns Tutorial | Edureka
Gof design patterns
The Singleton Pattern Presentation
Let us understand design pattern

What's hot (20)

PPTX
Design pattern-presentation
PPT
Composite Design Pattern
PPT
Software Design Patterns
PDF
Design patterns
PPT
System Models in Software Engineering SE7
PPTX
PDF
Java Course 11: Design Patterns
PPT
Flyweight pattern
PPT
Prototype pattern
PPT
PPT
Builder pattern
PPTX
Design Patterns - General Introduction
PPT
Facade pattern
PDF
Design Patterns Presentation - Chetan Gole
DOCX
Ooad notes
PPT
Domain model
PPT
Design Patterns
PPTX
Software design patterns ppt
PPTX
Uml Presentation
Design pattern-presentation
Composite Design Pattern
Software Design Patterns
Design patterns
System Models in Software Engineering SE7
Java Course 11: Design Patterns
Flyweight pattern
Prototype pattern
Builder pattern
Design Patterns - General Introduction
Facade pattern
Design Patterns Presentation - Chetan Gole
Ooad notes
Domain model
Design Patterns
Software design patterns ppt
Uml Presentation
Ad

Viewers also liked (6)

PPTX
Design Pattern
PPTX
Security and Integrity of Data
PPTX
Behavioral pattern By:-Priyanka Pradhan
PPT
Design patterns ppt
PPTX
Adapter Design Pattern
ZIP
Adapter Design Pattern
Design Pattern
Security and Integrity of Data
Behavioral pattern By:-Priyanka Pradhan
Design patterns ppt
Adapter Design Pattern
Adapter Design Pattern
Ad

Similar to Creational pattern (20)

PPTX
PATTERNS02 - Creational Design Patterns
PPTX
CREATIONAL Pattern .pptx
PPTX
PPTX
OOPSDesign PPT ( introduction to opps and design (
PPT
Unit 2-Design Patterns.ppt
PPTX
Lecture-7.pptx software design and Arthitechure
PPTX
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
PDF
E1803023637
PPTX
Design Pattern lecture 2
ODP
Design Patterns Part1
PPTX
Software Architecture and Design Patterns Notes.pptx
PPTX
Creational Design Patterns.pptx
DOCX
Understanding Creational Design Patterns in Python.docx
DOCX
Understanding Creational Design Patterns in Python
PPT
Design Pattern For C# Part 1
PPTX
Design Patterns
PPTX
design patter related ppt and presentation
PDF
The maze of Design Patterns & SOLID Principles
PPT
Bartlesville Dot Net User Group Design Patterns
PPTX
Creational Patterns
PATTERNS02 - Creational Design Patterns
CREATIONAL Pattern .pptx
OOPSDesign PPT ( introduction to opps and design (
Unit 2-Design Patterns.ppt
Lecture-7.pptx software design and Arthitechure
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
E1803023637
Design Pattern lecture 2
Design Patterns Part1
Software Architecture and Design Patterns Notes.pptx
Creational Design Patterns.pptx
Understanding Creational Design Patterns in Python.docx
Understanding Creational Design Patterns in Python
Design Pattern For C# Part 1
Design Patterns
design patter related ppt and presentation
The maze of Design Patterns & SOLID Principles
Bartlesville Dot Net User Group Design Patterns
Creational Patterns

More from Himanshu (20)

PPTX
Software product line
PPT
Shared information systems
PPTX
Saam
PPTX
Architecture Review
PPTX
Reliability and its principals
PPTX
Structural and functional testing
PPTX
White box black box & gray box testing
PPTX
Pareto analysis
PPTX
Load runner & win runner
PPTX
Crud and jad
PPTX
Junit and cactus
PPTX
Risk based testing and random testing
PPTX
Testing a data warehouses
PPTX
Software testing tools and its taxonomy
PPTX
Software reliability engineering process
PPTX
Software reliability growth model
PPTX
Software reliability tools and common software errors
PPTX
Regression and performance testing
PPTX
Eleven step of software testing process
PPTX
Off the-shelf components (cots)
Software product line
Shared information systems
Saam
Architecture Review
Reliability and its principals
Structural and functional testing
White box black box & gray box testing
Pareto analysis
Load runner & win runner
Crud and jad
Junit and cactus
Risk based testing and random testing
Testing a data warehouses
Software testing tools and its taxonomy
Software reliability engineering process
Software reliability growth model
Software reliability tools and common software errors
Regression and performance testing
Eleven step of software testing process
Off the-shelf components (cots)

Recently uploaded (20)

PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
Institutional Correction lecture only . . .
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PDF
Business Ethics Teaching Materials for college
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Pre independence Education in Inndia.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
RMMM.pdf make it easy to upload and study
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
O7-L3 Supply Chain Operations - ICLT Program
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Insiders guide to clinical Medicine.pdf
Cell Structure & Organelles in detailed.
Institutional Correction lecture only . . .
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Business Ethics Teaching Materials for college
STATICS OF THE RIGID BODIES Hibbelers.pdf
Pre independence Education in Inndia.pdf
Basic Mud Logging Guide for educational purpose
Pharmacology of Heart Failure /Pharmacotherapy of CHF
TR - Agricultural Crops Production NC III.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
VCE English Exam - Section C Student Revision Booklet
2.FourierTransform-ShortQuestionswithAnswers.pdf
RMMM.pdf make it easy to upload and study
O5-L3 Freight Transport Ops (International) V1.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial disease of the cardiovascular and lymphatic systems
PPH.pptx obstetrics and gynecology in nursing
O7-L3 Supply Chain Operations - ICLT Program

Creational pattern

  • 1. Creational Patterns Dr. Himanshu Hora SRMS college of Engineering & Technology Bareilly (UP) INDIA
  • 2. Contents  Introduction  Types of Creational Pattern  Why use Creational Pattern  The Factory Pattern  The factory Design Pattern  Abstract factory  The Singleton  Summary  References
  • 3. Introduction  Creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.
  • 4. Creational Patterns  There are three creational patterns  The Factory  The Abstract Factory  The Singleton
  • 5. Why Use A Creational Pattern?  Some situations are more complex than simple instantiation can handle.  Imagine for example you want to create an entirely ‘ skinnable’ look and feel for an application.  Some situations have complex consequences if objects aren’t instantiated in the right way or the right order.  Some situations require that only one object is ever created.
  • 6. The Factory Pattern  The Factory is used to provide a consistent interface to setup properly configured objects.  It can be represented by a single class containing a single static method.  More complex factories exist, dealing with more complex situations.
  • 7. The Factory Design Pattern  Imagine a simple class hierarchy:
  • 8. The Factory Design Pattern  Now imagine you are creating a simple drawing package.  User selects a shape  User clicks on the screen  Application draws the shape.  This can all be hard-coded directly into an application.
  • 9. The Factory Design Pattern  Instead, we use a factory to generate specific objects, through the power of polymorphism.  Polymorphism is key to the way a Factory works.  The system that drives a factory is that all these shapes have a common parent class.  All we need is the Shape object that is represented by specific objects.
  • 10. Another Example  Let’s say we have a file that we have created in our application.  We now want to export it to a different file format.  Each file format has its own peculiarities.  We could hard-code this into our application.
  • 11. The Factory Design Pattern  The Factory Pattern reduces hard-coded complexity.  The Factory Pattern properly devolves responsibility to individual objects.  However, the Factory pattern by itself is limited to certain simple contexts.
  • 12. The Abstract Factory  The next level of abstraction is the Abstract Factory.  This is a Factory for factories.  Imagine here we have slightly more complicated situations.  Designing an interface that allows for different themes.  A file conversion application that must allow for different versions of different formats.
  • 13. The Abstract Factory  We could handle these with a factory by itself.  This introduces the same combinatorial problems that the factory is designed to resolve.  A simple rule to remember is – coding combinations is usually bad design.  Bad design causes trouble later on.  When doing anything more substantial than simple ‘proof of concept’ applications.
  • 14. The Consequence  Entirely new suites of themes can be added to this system without risking combinatorial explosion.  The ‘operational’ code is also much tighter and more focused.
  • 15. The Singleton  The Factory and Abstract Factory handle structural creation issues.  They fix several aspects of bad design with regards to creating objects.  The Singleton is designed to increase data consistency.  One of the problems that must be managed with object orientation is inter-object communication.
  • 16. The Singleton  This is fine in most situations.  However, when dealing with objects that contain ‘live data’, it becomes problematic.  Each object has its own copy of the data.  It would be much better if all objects had access to the same copy of the data.  That is hard to manage effectively.
  • 17. The Singleton  The Singleton pattern resolves this by ensuring a single interface to the creation of an object.  Objects cannot be created with new, they must be created through a method.  This method is responsible for ensuring only one live version of an object.  If one exists, it sends that out.  If it doesn’t, it creates it and then sends it out.  The pattern is very simple.  But offers great improvements in data consistency.
  • 18. Summary  Creational Patterns manage the complexity of object instantiations.  They make it easier to manage the combinatorial explosion that comes along with certain kinds of object creation schemes.  The Factory allows for the creation of properly configured objects.  The Abstract Factory is a factory for factories.  The Singleton ensures data consistency by restricting instantiation of objects.
  • 19. References  Presentation session notes including link to this session, will be available on http://learningaboutfudge.blogspot.com  All the source for this session is publically available at: https://github.com/SheepWorx/Training  RSS Feed: http://learningaboutfudge.blogspot.com/feeds/post s/default?alt=rss  Local Network: dmeyer-msharetrainingCode Like a Ninja  Source was compiled using Visual Studio 2012  http://www.gofpatterns.com/
  • 20. Thank You Dr. Himanshu Hora SRMS college of Engineering & Technology Bareilly (UP) INDIA