Documente Academic
Documente Profesional
Documente Cultură
Creational Patterns
S.NO.
TOPIC
Creational Pattern Part-I Introduction
PPT Slides
L1
48
Abstract Factory
L2
9 28
Builder
Factory Method
L3
L4
29 39
40 47
Prototype
L5
48 54
Singleton
L6
55 66
Creational Patterns
L1
created
composed
represented
Creational Patterns
L1
Benefits of creational
patterns
L1
Benefits of creational
patterns
L1
L2
ABSTRACT FACTORY
(Object Creational)
Intent:
Motivation
L2
Motivation:
User interface toolkit supports multiple
look-and-feel standards
(Motif, Presentation Manager)
Different appearances and behaviors for
UI widgets
Apps should not hard-code its widgets
L2
ABSTRACT FACTORY
Motivation
Widget Factory
Client
CreateScrollBar()
CreateWindow()
Windows
PMWindow
MotifWidgetFactory
MotifWindow
PMWidgetFactory
CreateScrollBar()
CreateScrollBar()
CreateWindow()
CreateWindow()
ScrollBar
PMScrollBar
MotifScrollBar
L2
Solution:
Abstract Widget Factory class
Interfaces for creating each basic kind
of widget
Abstract class for each kind of
widgets,
Concrete classes implement specific
look-and-feel.
L2
Applicability
Use the Abstract Factory pattern when
A system should be independent .
A system should be configured with one of multiple
families of products.
A family of related product objects is designed to be
used together.
You want to provide a class library of products.
L2
AbstractFactory
AbstractProductA
Operations:
CreateProdA( )
CreateProcB( )
ConcreteProductA1
ConcreteFactory1
Operations:
CreateProdA( )
CreateProcB( )
ConcreteProductA2
ConcreteFactory2
Operations:
CreateProdA( )
CreateProcB( )
AbstractProductB
ConcreteProductB1
ConcreteProductB2
L2
AbtractFactory(Widget Factory)
ConcreteFactory(MotifWidgetFactory,PMWidgetFactory)
ConcreteProduct(MotifWindow,MotifScrollbar)
AbstractProduct(Window,Scrollbar)
Client:
L2
Collaborations
Consequences
L2
Implementation
Factories as singletons.
L2
Know Uses
Interviews
used to generate look and feel for specific user
interface objects
uses the Kit suffix to denote AbstractFactory classes,
e.g., WidgetKit and DialogKit.
L2
Related Patterns
L2
L3
BUILDER
PATTERN
Intent:
Motivation:
L3
Solution:
Configure RTFReader class with a Text
Converter object
Subclasses of Text Converter specialize
in different conversions and formats
TextWidgetConverter will produce a
complex UI object and lets the user see
and edit the text
L3
BUILDER Motivation
RTFReader
builders
ParseRTF()
TextConverter
ConvertCharacter(char)
ConvertFontChange(Font)
ConvertParagraph()
ASCIIConverter
TextConverter
TextWidgestConverter
ConvertCharacter(char)
ConvertCharacter(char)
ConvertCharacter(char)
GetASCIIText()
ConvertFontChange(Font)
ConvertFontChange(Font)
ConvertParagraph()
ConvertParagraph()
GetTeXText()
GetTextWidget()
ASCIIText
TeXText
TextWidget
L3
Applicability
L3
BUILDER
Structure
builders
Director
Construct ()
Builder
BuildPart ()
ConcreteBuilder
BuildPart ()
GetResult ()
Product
Participant
s Builder(TextConverter)
Specifies an abstract interface for creating parts of
a Product object.
ConcreteBuilder(ASCIIConverter,TeXConverter,Text
WidgetConverter)
Director(RTFReader)
Product(ASCIIText,TeXText,TextWidget)
Builder - Collaborations
L3
L3
BUILDER Collaborations
aClient
aDirector
aConcreteBuilder
new ConcreteBuilder
new Director (aConcreteBuilder)
BuildPart A ()
BuilPart B ()
BuildPart C ()
GetResult ()
Consequences
Implementation
Known Uses
Related Patterns