** Reuse Activities ** Selecting Design Patterns and Components (Part 1) Done by Safaa khalil...
-
Upload
kelley-chandler -
Category
Documents
-
view
215 -
download
1
Transcript of ** Reuse Activities ** Selecting Design Patterns and Components (Part 1) Done by Safaa khalil...
**Reuse Activities** Selecting Design Patterns
and Components(Part 1 )
Done by
Safaa khalil Meqdad
Outline
• Introduction
• Sources of Changes
• Design Patterns
.. Sources of Changes ..
• New vendor or new technology
• New implementation • New views
• Errors
.. Design Patterns ..• Bridge Design Pattern
• Adapter Design Pattern
• Strategy Design Pattern
• Abstract Factory Design Pattern
** Bridge Design Pattern **
• decouple the interface from an implementation so that implementations can be substituted possibly at run time .
• From figure (1) the client just deal with Abstraction class and completely shielded from both abstraction implementor and concrete implementation .
• Bridge design pattern fills the gap between the interface and its implementation .
Arena
LaegueStore LaegueStoreImplementator
StubStoreImplementor
XMLStoreImplementor
JDBCStoreImplementor
Figure (1)
Abstraction class
** Adapter Design Pattern **
• The Adapter converts the interface of a legacy system into an interface expected by the user ..
• From figure ( 2 ) the Adapter class (MyStringComparator) provides the interface expected by the client ,and delegates the request the client request to the Legacy class (MyString) and perform any necessary conversions .
• Adapter works with Legacy Class and all of its subclasses.
• Client and Legacy class can work together with out any modification on both sides .
ArrayComparator
compare ) (
MyStringComparator
compare ) (
MyString
graeterThan) ( eqauls ) (
Figure (2)
Adapter class
Legacy class
** Strategy Design Pattern **
• Decouple a policy-deciding class from a set of mechanisms so that different mechanisms can be changed transparently from the client.
• From figure (3) .. the network access protocols implementations are encapsulated with a strategy pattern to decouple the policy from selecting a network interface
• New algorithms can be added .
Application
LocationManager
NetworkConnection
send ) (receive ) (setNetworkInterface ) (
NetworkInterface
open) ( close) ( send) ( receive) (
Ethernet
Open) ( close) ( send) ( receive) (
WaveLAN
Open) ( close) ( send) ( receive) (
UMTS
Open) ( close) ( send) ( receive) (
Figure (3)
Strategy class
Policy
** Abstract Factory Design Pattern **
• The Abstract Factory shield the client from different platforms that provide different implementations for the same set of concepts ..
• Client deals with interface provided by the AbstractFactory figure (4).
• Client can change platforms easier .
• Adding new product is difficult since new realization for each factory must be created.
Blind
LuxmateBulbEIBBulbLuxmateBulbEIBBulb
LightBulb
HouseFartory
createBulb ) (craeteBlind ) (
EIBFactory
createBulb) ( craeteBlind) (
LuxmateFactory
createBulb) ( craeteBlind) (
TheftApplication
Figure (4)
AbstractFactory class
SummaryPhraseDesign Pattern
“Must Support future protocols”Bridge Design Pattern
“Must deal with existing systems or reuse Legacy systems”
Adapter Design Pattern
“Platform independency” .. “Manufacturers independency”
AbstractFactory Design Pattern
“Must allow different algorithms to be interchanged at runtime”
Strategy Design Pattern