Professional Documents
Culture Documents
The Factory Method Pattern
The Factory Method Pattern
PATTERN
Teaching document
Borhan Otour ()
TISHREEN UNIVERSITY | borhanhunter@gmail.com
:
.1
.2
.3
.4
.
( ).
(.)Simple factory
(.)The factory method
( )Factory method
( .)creational patterns
( )Object creation .
( ).
: .
( )
( )The Factory method design pattern
.
( )
( " , " ,
features) . .
. " " OO
.Design principles
( .)Principles #0
.Change is the only constant that exists in OO software development
. .
((:))1
()1
( ) .
.
(.)2
( " .)"Design for implementation
( )
.
.
.
5 .
( " )Inconsistency .
( )1 ( (.))3
( )3
( .)Design for interface
.
)( calculateFunds
.
" "polymorphism
.
( )Account
.
Design to interface, not to " :
"an implementation
()2
()3
( ApplicationUI( .))4 )( , buildPanel ( popup menu
)Dropdown menu - window Pane ( .)5 .
()4
()5
()6
()7
(.)SimplePanelFactory
)( .createPanel ApplicationUI
(.)8
()8
()9
ApplicationUI ( (.))11
Design to ":
interface,
not
to
"implementation
()11
.SimplePanelFactory:
)( buildPanel SimplePanelFactory
,
ApplicationUI SimplePanelFactory
ApplicationStatusBar ApplicationDialog.
ApplicationUI )( .createPanel
Panel (.)11
)( createPanel
( ) .
ApplicationUI )( .createPanel )(createPanel
Panel ( 12
.) 14 13-
()11
()12
()13
()14
( , )
ApplicationUI
ApplicationUI )( buildPanel (.)12
createPanel () :
) .(Factory method design pattern :
" ".
:
( )15