background image

 

 

 

 

Design Patterns

Design Patterns

By Mareck Kortylevitch and 

By Mareck Kortylevitch and 

Piotreck Ratchinsky

Piotreck Ratchinsky

background image

 

 

 

 

What is Design Pattern?

What is Design Pattern?

Recurring solution to known 

Recurring solution to known 

problems

problems

Workaround to problems 

Workaround to problems 

that arise when developing 

that arise when developing 

software within a particular 

software within a particular 

context

context

background image

 

 

 

 

History

History

Precursor of design pattern 

Precursor of design pattern 

was Christopher Alexander

was Christopher Alexander

First Design Patterns used in 

First Design Patterns used in 

architecture

architecture

background image

 

 

 

 

Why to use DP?

Why to use DP?

Help you learn from others' 

Help you learn from others' 

successes instead of your 

successes instead of your 

own failures

own failures

Provide a communication 

Provide a communication 

platform concerning 

platform concerning 

elegant, reusable solutions 

elegant, reusable solutions 

to commonly encountered 

to commonly encountered 

programming challenges 

programming challenges 

background image

 

 

 

 

Why to use...continuation

Why to use...continuation

Enforce using techspeak

Enforce using techspeak

Isolate changes in the code

Isolate changes in the code

Design and interaction of 

Design and interaction of 

objects

objects

background image

 

 

 

 

Design Patterns Examples

Design Patterns Examples

Facade

Facade

Adapter

Adapter

Singleton

Singleton

Abstract Factory

Abstract Factory

Bridge

Bridge

background image

 

 

 

 

Facade - definition

Facade - definition

Provide a unified interface 

Provide a unified interface 

to a set of interfaces in a 

to a set of interfaces in a 

subsystem. Façade defines a 

subsystem. Façade defines a 

higher-level interface that 

higher-level interface that 

makes the subsystem easier 

makes the subsystem easier 

to use. 

to use. 

background image

 

 

 

 

Facade - 

Facade - 

UML class 

UML class 

diagram

diagram

 

 

background image

 

 

 

 

Facade - example

Facade - example

Facade 

Facade 

  

  

(MortgageApplication)

(MortgageApplication)

 

 

knows which subsystem classes are 

knows which subsystem classes are 

responsible for a request. 

responsible for a request. 

delegates client requests to 

delegates client requests to 

appropriate subsystem objects. 

appropriate subsystem objects. 

Subsystem classes 

Subsystem classes 

  

  

(Bank, 

(Bank, 

Credit, Loan)

Credit, Loan)

 

 

implement subsystem functionality. 

implement subsystem functionality. 

handle work assigned by the Facade 

handle work assigned by the Facade 

object. 

object. 

have no knowledge of the facade 

have no knowledge of the facade 

and keep no reference to it. 

and keep no reference to it. 

background image

 

 

 

 

Facade – example diagram

Facade – example diagram

Facade

Subsystems

Loan

Credit

Bank 

 

background image

 

 

 

 

Singleton - definition

Singleton - definition

ensure a class has only one 

ensure a class has only one 

instance and provide a global 

instance and provide a global 

point of access to it. 

point of access to it. 

defines an Instance operation 

defines an Instance operation 

that lets clients access its unique 

that lets clients access its unique 

instance. Instance() is a class 

instance. Instance() is a class 

operation. 

operation. 

responsible for creating and 

responsible for creating and 

maintaining its own unique 

maintaining its own unique 

instance. 

instance. 

background image

 

 

 

 

Singleton – UML

Singleton – UML

Singleton

-Singleton()

+static 
getInstance():Singleton

-static Singleton: instance


Document Outline