You are on page 1of 12

THE FACTORY METHOD

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

( ) THE SIMPLE FACTORY PROGRAMMING IDIOM


( ApplicationUI( .))4 )( , buildPanel ( popup menu
)Dropdown menu - window Pane ( .)5 .

()4

()5

, Design for interface, not to an implementation


( .)Concrete Select the components that " :
, "varies , and separate them from what stays the same
. Panel
( )Menu Panel
(.)Dropdown Panel

()6

()7

(.)SimplePanelFactory
)( .createPanel ApplicationUI
(.)8

()8

()9

ApplicationUI ( (.))11


Design to ":
interface,
not
to
"implementation

()11


.SimplePanelFactory:

)( buildPanel SimplePanelFactory
,

ApplicationUI SimplePanelFactory
ApplicationStatusBar ApplicationDialog.

( )8 ( .)Simple Factory Programming idiom


ApplicationUI ( )The client Panel
(.)The products

.

( ) THE FACTORY METHOD DESIGN PATTERN


.
.
( )Application ) (web application
( .)standalone application
. buildPanel
Panel .

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

You might also like