• Nie Znaleziono Wyników

Design Patterns Design Patterns

N/A
N/A
Protected

Academic year: 2021

Share "Design Patterns Design Patterns"

Copied!
12
0
0

Pełen tekst

(1)

Design Patterns Design Patterns

By Mareck Kortylevitch and By Mareck Kortylevitch and

Piotreck Ratchinsky

Piotreck Ratchinsky

(2)

What is Design Pattern?

What is Design Pattern?

 Recurring solution to known Recurring solution to known problems

problems

 Workaround to problems that Workaround to problems that

arise when developing software arise when developing software

within a particular context

within a particular context

(3)

History History

 Precursor of design pattern was Precursor of design pattern was Christopher Alexander

Christopher Alexander

 First Design Patterns used in First Design Patterns used in architecture

architecture

(4)

Why to use DP?

Why to use DP?

 Help you learn from others' Help you learn from others'

successes instead of your own successes instead of your own

failures failures

 Provide a communication Provide a communication

platform concerning elegant, platform concerning elegant,

reusable solutions to commonly reusable solutions to commonly

encountered programming encountered programming

challenges

challenges

(5)

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

(6)

Design Patterns Examples Design Patterns Examples

 Facade Facade

 Adapter Adapter

 Singleton Singleton

 Abstract Factory Abstract Factory

 Bridge Bridge

(7)

Facade - definition Facade - definition

 Provide a unified interface to a Provide a unified interface to a set of interfaces in a subsystem.

set of interfaces in a subsystem.

Façade defines a higher-level Façade defines a higher-level

interface that makes the interface that makes the

subsystem easier to use.

subsystem easier to use.

(8)

Facade -

Facade - UML class diagram UML class diagram

(9)

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 appropriate delegates client requests to appropriate subsystem objects.

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 and have no knowledge of the facade and

(10)

Facade – example diagram Facade – example diagram

Facade

Subsystems

Loan Credit

Bank

(11)

Singleton - definition Singleton - definition

 ensure a class has only one instance ensure a class has only one instance and provide a global point of access and provide a global point of access

to it.

to it.

 defines an Instance operation that defines an Instance operation that lets clients access its unique

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 instance.

maintaining its own unique instance.

(12)

Singleton – UML Singleton – UML

Singleton

-Singleton()

+static getInstance():Singleton

-static Singleton: instance

Cytaty

Powiązane dokumenty

Spośród 166 ankietowanych nauczycielek tylko 42 (25,3%) jest zdania, iż czę­ sty kontakt w codziennej pracy dziecka z komputerem może mieć korzystny wpływ na jego

Po tych, niemal bluźnierczych, słowach króla zwróco­ nych do proroka zaczyna się druga część opowiadania.. Wstęp i zakończenie wskazują na silny kontrast pomiędzy

They match the currently best known iteration bounds for the prototype self-regular function with quadratic growth term, the simple nonself-regular function with linear growth term,

BOCZNIKI POLSKIEGO TOWARZYSTWA MATEMATYCZNEGO Seria I: PRACE MATEMATYCZNE X (1967). ANNALES SOCIETATIS MATHEMATICAE POLONAE Series I: COMMENTATIONES

characterization of an arc and a simple closed curve via stretchy mappings is valid for graphs only, i.e., whether it cannot be extended for some wider classes

To begin, note that the interest is in explaining the evolution of non-cooperative (i.e., blight-gen- erating) property maintenance behaviour in a given urban area at the

If we expect that during classification outlier objects, or objects from classes that are not represented in the training set might occur or we only have examples from a single class

A complex of design calculations and engineering works concerning the two-stage worm turn drive of the capstan head has been performed.. On a basis of