Presentation is loading. Please wait.

Presentation is loading. Please wait.

Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky.

Similar presentations


Presentation on theme: "Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky."— Presentation transcript:

1 Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky

2 What is Design Pattern? Recurring solution to known problems Recurring solution to known problems Workaround to problems that arise when developing software within a particular context Workaround to problems that arise when developing software within a particular context

3 History Precursor of design pattern was Christopher Alexander Precursor of design pattern was Christopher Alexander First Design Patterns used in architecture First Design Patterns used in architecture

4 Why to use DP? Help you learn from others' successes instead of your own failures Help you learn from others' successes instead of your own failures Provide a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges Provide a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges

5 Why to use...continuation Enforce using techspeak Enforce using techspeak Isolate changes in the code Isolate changes in the code Design and interaction of objects Design and interaction of objects

6 Design Patterns Examples Facade Facade Adapter Adapter Singleton Singleton Abstract Factory Abstract Factory Bridge Bridge

7 Facade - definition Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use. Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.

8 Facade - UML class diagram

9 Facade - example Facade (MortgageApplication) Facade (MortgageApplication) knows which subsystem classes are responsible for a request. knows which subsystem classes are responsible for a request. delegates client requests to appropriate subsystem objects. delegates client requests to appropriate subsystem objects. Subsystem classes (Bank, Credit, Loan) Subsystem classes (Bank, Credit, Loan) implement subsystem functionality. implement subsystem functionality. handle work assigned by the Facade object. handle work assigned by the Facade object. have no knowledge of the facade and keep no reference to it. have no knowledge of the facade and keep no reference to it.

10 Facade – example diagram Facade Subsystems LoanCreditBank

11 Singleton - definition ensure a class has only one instance and provide a global point of access to it. ensure a class has only one instance and provide a global point of access to it. defines an Instance operation that lets clients access its unique instance. Instance() is a class operation. defines an Instance operation that lets clients access its unique instance. Instance() is a class operation. responsible for creating and maintaining its own unique instance. responsible for creating and maintaining its own unique instance.

12 Singleton – UML Singleton -Singleton() +static getInstance():Singleton -static Singleton: instance


Download ppt "Design Patterns By Mareck Kortylevitch and Piotreck Ratchinsky."

Similar presentations


Ads by Google