SlideShare a Scribd company logo
Introduction
 Design patterns are medium-scale patterns.
They are smaller in scale than architectural
patterns, but are at a higher level than the
programming language-specific idioms.
Architectural Patterns
Design Patterns
programming language-specific idioms
Group Design Patterns
 Structural Decomposition
 Organization of Work
 Access Control
 Management
 Communication
Overview(1)
 Structural Decomposition This category includes patterns
that support a suitable decomposition of subsystems and
complex components into cooperating parts. The Whole-
Part pattern is the most general pattern we are aware of
in this category.
 Organization of Work. This category comprises patterns
that define how components collaborate together to solve
a complex problem. We describe the Master-Slave
pattern, which helps you to organize the computation of
services for which fault tolerance or computational
accuracy is required.
Overview(2)
 Access Control. Such patterns guard and control access to
services or components. We describe the Proxy pattern
here.
 Management. This category includes patterns for handling
homogenous collections of objects, services and
components in their entirety. We describe two patterns: the
Command Processor pattern addresses the management
and scheduling of user commands, while the View
Handler pattern describes how to manage views in a
software system.
Overview(3)
 Communication. Patterns in this category help to organize
communication between components. Two patterns address
issues of inter-process communication: the Forwarder-Receiver
pattern deals with peer-to-peer communication, while the
Client Dispatcher-Server pattern describes location-transparent
communication in a Client-Server structure. The Publisher-
Subscriber pattern helps with the task of keeping data
consistent between cooperating components.
*An important property of all design patterns is that they are
independent of a particular application domain.
*Most design patterns are independent of a particular programming
paradigm.
Structural Decomposition(1)
 Structural Decomposition
 Organization of Work
 Access Control
 Management
 Communication
Structural Decomposition()
 The Whole-Part design pattern helps
with the aggregation of components
that together form a semantic unit.
 The Composite pattern organizes
objects into tree structures that
represent part-whole hierarchies.
The Whole-part Design Pattern
 Example
 Context
 Problem
 Solution
 Structure
 Dynamics
 Implementation
 Variants
 Example Resolved
 Known Uses
 See also
Whole-part-- Example
Whole-part-- Context
 Context Implementing aggregate objects.
Whole-part-- Problem
 A complex object should either be decomposed
into smaller objects, or composed of existing
objects, to support reusability, changeability and
the recombination of the constituent objects in
other types of aggregate.
 Clients should see the aggregate object as an
atomic object that does not allow any direct
access to its constituent parts.
Whole-part-- Solution
Introduce a component that encapsulates smaller objects, and
prevents clients from accessing these constituent parts
directly. Define an interface for the aggregate that is the
only means of access to the functionality of the
encapsulated objects. allowing the aggregate to appear as a
semantic unit.
The general principle of the Whole-Part pattern is applicable
to the organization of three types of relationship:
 An assembly-parts relationship
 A container-contents relationship
 The collection-members relationship
Whole-part—Structure(1)
Whole-part—Structure(2)
Whole-part—Dynamics(1)
Whole-part—Dynamics(2)
Whole-part– Implementation(1)
1 Design the public interface of the Whole. Analyze the
functionality the Whole must offer to its clients.
2 Separate the Whole into Parts, or synthesize it from
existing ones. There are two approaches:
 The bottom-up approach allows you to compose Wholes
from loosely-coupled Parts that you can later reuse when
implementing other types of Whole.
 The top-down approach makes it is possible to cover all
of the Whole's functionality.
Whole-part– Implementation(2)
3 If you follow a bottom-up approach, use existing
Parts from component libraries or class libraries
and specify their collaboration.
4 If you follow a top-down approach, partition the
Mirhole's services into smaller collaborating
services and map these collaborating services to
separate Parts.
Whole-part– Implementation(3)
5 Specify the services of the W'hole in terms of
services of the Parts.---two possible ways to call a
Part service:
 If a client request is forwarded to a Part service, the
Part does not use any knowledge about the execution
context of the Whole, relying on its own
environment instead.
 A delegation approach requires the Whole to pass its
own context information to the Part.
Whole-part– Implementation(4)
6 Implement the Parts. If the Parts are Whole-Part
structures themselves, design them recursively
starting with step 1. If not, reuse existing Parts
from a library, or just implement them if their
implementation is straightforward and further
decomposition is not necessary.
7 Implement the Whole. Implement the Whole's
services based on the structure you developed
in the preceding steps.
Whole-part– Variants(1)
Shared Parts. This variant relaxes the restriction that
each Part must be associated with exactly one
Whole by allowing several Wholes to share the
same Part.
Whole-part– Variants(2)
The next three variants describe the implementation of the
Whole-to-Parts relationships we introduced in the Solution
section:
 Assembly-Parts In this variant the Whole may be an object
that represents an assembly of smaller objects.
 Container-Contents. In this variant a container is
responsible for maintaining differing contents.
 The Collection-Members variant is a specialization of
Container-Contents, in that the Part objects all have the
same type.
Whole-part– Example Resolved(1)
Whole-part– Example Resolved(2)
Whole-part– Example Resolved(3)
Whole-part– Known Uses
 The key abstractions of many object-oriented
applications follow the Whole-Part pattern.
 Most object-oriented class libraries provide
collection classes such as lists. sets. and maps.
These classes implement the Collection-Member
and Container-Contents variants.
 Graphical user interface toolkits such as Fresco
or ET++ use the Composite variant of the Whole-
Part pattern.
Whole-part– Consequences
Benefits:
 Changeability of Parts
 Separation of concerns
 Reusability
liabilities:
 Lower eminency through indirection
 Complexity of decomposition into Parts
Whole-part– See also
the Composite design pattern is applicable when:
 You want to represent whole-part hierarchies of objects.
 You want clients to be able to ignore the difference
between compositions of objects and individual objects.
 Composite is a variant of the Whole-Part design pattern
that you should consider when facing these two
requirements.
 The Facade design pattern helps to provide a simple
interface to a complex subsystem.
3.3 Organization of Work(1)
 Structural Decomposition
 Organization of Work
 Access Control
 Management
 Communication
Organization of Work(2)
 The implementation of complex services is often solved
by several components in cooperation.
 The Master-Slave pattern supports fault computation and
computational accuracy.
 Master-Slave applies the 'divide and conquer' principle.
 The Master-Slave pattern is widely applied in the areas of
parallel and distributed computing.
 The Chain of Responsibility, Command and Mediator
patterns also belong to this category
3.3.1Master-Slave
 Example
 Context
 Problem
 Solution
 Structure
 Dynamics
 Implementation
 Variants
 Known Uses
 See also
Master-Slave-- Example
Master-Slave-- Context
 Context Partitioning work into semantically-
identical sub-tasks.
Master-Slave– Problem(1)
 Clients should not be aware that the
calculation is based on the “divide and
conquer” principle.
 Neither clients nor the processing of sub-
tasks should depend on the algorithms for
partitioning work and assembling the final
result.
Master-Slave– Problem(2)
 It can be helpful to use different but
semantically-identical implementations for
processing sub-tasks, for example to
increase computational accuracy.
 Processing of sub-tasks sometimes needs
coordination, for example in simulation
applications using the finite element method.
Master-Slave-- Solution
A master component divides work into equal sub-tasks, delegates
these sub-tasks to several independent but semantically-identical
shve components, and computes a final result from the partial
results the slaves return.
This general principle is found in three application areas:
 Fault tolerance
 Parallel computing
 Computational accuracy
Master-Slave—Structure(1)
Master-Slave—Structure(2)
Master-Slave—Dynamics(1)
 A client requests a service from the master
 The master partitions the task into several equal sub-tasks.
 The master delegates the execution of these sub-tasks to
several slave instances, starts their execution and waits for
the results they return
 The slaves perform the processing of the sub-tasks and
return the results of their computation back to the master
 The master computes a final result for the whole task from
the partial results received from the slaves
 The master returns this result to the client
Master-Slave—Dynamics(2)
Master-Slave– Implementation(1)
The implementation of the Master-Slave pattern follows
five steps:
1.Divide work. Specify how the computation of the task
can be split into a set of equal sub-tasks. Identify the
sub-services that are necessary to process a sub-task.
2.Combine sub-task results. Specify how the final
result of the whole service can be computed with the
help of the results obtained from processing individual
sub-tasks.
Master-Slave– Implementation(2)
3. Specify the cooperation between master and
slaves. Define an interface for the sub-service
identified in step 1. It will be implemented by
the slave and used by the master to delegate the
processing of individual sub-tasks.
4.Implement the slave components according to
the specifications developed in the previous step.
5.Implement the master according to the
specifications developed in step 1 to 3.
Master-Slave– Variants(1)
Master Slave for fault tolerance. In this variant the
master just delegates the execution of a service to a
fixed number of replicated implementations, each
represented by a slave.
Master-Slave for parallel computation. The master
divides a complex task into a number of identical
sub-tasks, each of which is executed in parallel by a
separate slave. The master builds the final result
from the results obtained from the slaves.
Master-Slave– Variants(2)
Master-Slave for computational accuracy. The
execution of a service is delegated to at least three
different implementations, each of which is a
separate slave.
Master-Slave– Variants(3)
Further variants exist for implementing slaves:
Slaves as Processes. To handle slaves located in separate
processes, you can extend the original Master-Slave
structure with two additional components
Slaves as Threads. Every slave is implemented within
its own thread of control.
Master Slave with slave coordination. The computation
of a slave may depend on the state of computation of
other slaves
Master-Slave– Known Uses
 Matrix multiplication. Each row in the product matrix
can be computed by a separate slave.
 Transform-coding an image, for example in
computing the discrete cosine transform (DCT) of
every 8 x 8 pixel block in an image. Each block can
be computed by a separate slave.
 Computing the cross-correlation of two signals. This
is done by iterating over all samples in the signal,
computing the mean-square distance between the
sample and its correlate, and summing the distances.
Master-Slave– Consequences
Benefits:
 Exchangeability and extensibility
 Separation of concerns
 Efficiency
liabilities:
 Feasibility
 Hard to implement
 Portability
Master-Slave– See also
 The Master-Slave Pattern for Parallel Compute
Services [Bro96] provides additional insights for
implementing a Master-Slave structure.
 The book Programming with Threads [KSS96]
describes the Slaves as Threads variant in detail.
 Object Group [Maf96] is a pattern for group
communication and support of fault tolerance in
distributed applications. It corresponds to the Master-
Slave for fault tolerance variant and provides additional
details for its implementation.
3.4 Access Control (1)
 Structural Decomposition
 Organization of Work
 Access Control
 Management
 Communication
Access Control(2)
 Sometimes a component or even a whole subsystem
cannot or should not be accessible directly by its clients.
 The Proxy design pattern makes the clients of a
component communicate with a representative rather than
to the component itself.
 The Facade pattern provides a uniform interface to a set of
interfaces in a subsystem.
 The Iterator pattern provides a way to access the elements
of an aggregate object sequentially without exposing its
underlying representation.
3.4.1Proxy
 Example
 Context
 Problem
 Solution
 Structure
 Dynamics
 Implementation
 Variants
 Example Resolved
 Known Uses
 See also
Proxy-- Example
Proxy-- Context
 Context A client needs access to the services of
another component. Direct access is technically
possible, but may not be the best approach.
Proxy– Problem(1)
 Accessing the component should be run-time-
efficient, costeffective, and safe for both the
client and the component.
 Access to the component should be transparent
and simple for the client. The client should
particularly not have to change its calling
behavior and syntax from that used to call any
other direct-access component.
Proxy– Problem(2)
 The client should be well aware of possible
performance or financial penalties for
accessing remote clients. Full transparency
can obscure cost differences between
services.
Proxy-- Solution
Let the client communicate with a representative rather
than the component itself.
This representative-called a proxy-offers the interface of
the component but performs additional pre- and post-
processing such as access-control checking or making
read-only copies of the original.
Proxy—Structure(1)
 The original implements a particular service.
 The client is responsible for a specific task.
 The abstract original provides the interface
implemented by the proxy and the original
Proxy—Structure(2)
Proxy—Structure(3)
Proxy—Dynamics(1)
 While working on its task the client asks the proxy to carry
out a service.
 The proxy receives the incoming service request and pre-
processes it.
 If the proxy has to consult the original to fulfill the request,
it forwards the request to the original using the proper
communication protocols and security measures.
 The original accepts the request and fulfills it. It sends the
response back to the proxy.
 The proxy receives the response.
Proxy—Dynamics(2)
Proxy– Implementation(1)
To implement the Proxy pattern, carry out the following
steps:
1. Identify all responsibilities for dealing with access
control to a component.
2. 2 If possible introduce an abstract base class that
specifies the common parts of the interfaces of both
the proxy and the original. Derive the proxy and the
original from this abstract base.
Proxy– Implementation(2)
3. Impkment the proxy's finctions. To this end check
the roles specified in the first step.
4. Free the original and its clients from responsibilities
that have migrated into the proxy.
5. Associate the proxy and the original by giving the
proxy a handle to the original.
6. Remove all direct relationships between the original
and its clients.
Proxy– Variants(1)
Remote Proxy. Clients of remote components should
be shielded from network addresses and inter-
process communication protocols.
Protection Proxy. Components must be protected
from unauthorized access.
Cache Proxy. Multiple local clients can share results
from remote components.
Synchronization Proxy. Multiple simultaneous
accesses to a component must be synchronized.
Proxy– Variants(2)
Counting Proxy. Accidental deletion of components
must be prevented or usage statistics collected.
Virtual Proxy. Processing or loading a component is
costly, while partial information about the
component may be sufficient.
Firewall Proxy. Local clients should be protected
from the outside world.
Proxy– Example Resolved
You may often need to use more than one of the above
Proxy variants Resolved -you may want the proxy to
play several of the above roles and fulfill the
corresponding responsibilities.
You can solve remote data access problems by using
proxies with the properties of both Remote and Cache
Proxy variants. Implementing such a mixed-mode
proxy can be accomplished by using the Whole-Part
pattern
Proxy– Known Uses(1)
 NeXTSTEP. The Proxy pattern is used in the
NeXTSTEP operating system to provide local stubs
for remote objects.
 OMG-CORBA uses the Proxy pattern for two
purposes. Socalled 'client-stubs', or IDL-stubs, guard
clients against the concrete implementation of their
servers and the Object Request Broker.
 Orbix, a concrete OMG-CORBA implementation,
uses remote proxies.
Proxy– Known Uses(2)
 World Wide Web Proxy describes aspects of the
CERN HTTP server that typically runs on a firewall
machine. It gives people inside the firewall concurrent
access to the outside world. Efficiency is increased by
caching recently transferred files.
 OLE. In Microsoft OLE servers may be implemented
as libraries dynamically linked to the address space of
the client, or as separate processes. Proxies are used to
hide whether a particular server is local or remote from
a client
Proxy– Consequences
Benefits:
 Enhanced egiciency and lower cost
 Decoupling clients from the location of seruer
components
 Separation of housekeeping code from
functionality
liabilities:
 Less emiency due to indirection
 Overkill via sophisticated strategies
Proxy– See also
 The Decorator pattern is very similar in structure to
Proxy. Concrete component-the original in the Proxy
pattern-implements some behavior that is invoked via a
decorator-the proxy in the Proxy pattern. Both classes
inherit from a common base. The major difference
between the Decorator and Proxy patterns is one of
intent. The decorator adds functionality or, more
generally, gives options for dynamically choosing
functionality in addition to the core functionality of
Concrete component. The proxy frees the original from
very specific housekeeping code.

More Related Content

What's hot

Normalization
NormalizationNormalization
Normalization
Altafsoomro
 
Relational algebra (basics)
Relational algebra (basics)Relational algebra (basics)
Relational algebra (basics)
usama nizam
 
J2EE and layered architecture
J2EE and layered architectureJ2EE and layered architecture
J2EE and layered architecture
Suman Behara
 
Corba concepts & corba architecture
Corba concepts & corba architectureCorba concepts & corba architecture
Corba concepts & corba architecture
nupurmakhija1211
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
Mohd Arif
 
Resource management
Resource managementResource management
Resource management
Dr Sandeep Kumar Poonia
 
Corba
CorbaCorba
Web security for e-commerce
Web security for e-commerceWeb security for e-commerce
Web security for e-commerce
Nishant Pahad
 
1.4 data independence
1.4 data independence1.4 data independence
1.4 data independence
BHARATH KUMAR
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memoryebt
 
Query trees
Query treesQuery trees
Query trees
Shefa Idrees
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
AbDul ThaYyal
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
RituBhargava7
 
DBMS ARCHITECTURE.pptx
DBMS ARCHITECTURE.pptxDBMS ARCHITECTURE.pptx
DBMS ARCHITECTURE.pptx
Anusha sivakumar
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database System
Meghaj Mallick
 
Halftoning in Computer Graphics
Halftoning  in Computer GraphicsHalftoning  in Computer Graphics
Halftoning in Computer Graphics
University of Potsdam
 
Ddbms1
Ddbms1Ddbms1
Ddbms1
pranjal_das
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
Sulemang
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
Ali Usman
 
Switches on Networking
Switches on NetworkingSwitches on Networking
Switches on Networking
Gayan Geethanjana
 

What's hot (20)

Normalization
NormalizationNormalization
Normalization
 
Relational algebra (basics)
Relational algebra (basics)Relational algebra (basics)
Relational algebra (basics)
 
J2EE and layered architecture
J2EE and layered architectureJ2EE and layered architecture
J2EE and layered architecture
 
Corba concepts & corba architecture
Corba concepts & corba architectureCorba concepts & corba architecture
Corba concepts & corba architecture
 
Two dimensional viewing
Two dimensional viewingTwo dimensional viewing
Two dimensional viewing
 
Resource management
Resource managementResource management
Resource management
 
Corba
CorbaCorba
Corba
 
Web security for e-commerce
Web security for e-commerceWeb security for e-commerce
Web security for e-commerce
 
1.4 data independence
1.4 data independence1.4 data independence
1.4 data independence
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Query trees
Query treesQuery trees
Query trees
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
Client server architecture
Client server architectureClient server architecture
Client server architecture
 
DBMS ARCHITECTURE.pptx
DBMS ARCHITECTURE.pptxDBMS ARCHITECTURE.pptx
DBMS ARCHITECTURE.pptx
 
Query processing in Distributed Database System
Query processing in Distributed Database SystemQuery processing in Distributed Database System
Query processing in Distributed Database System
 
Halftoning in Computer Graphics
Halftoning  in Computer GraphicsHalftoning  in Computer Graphics
Halftoning in Computer Graphics
 
Ddbms1
Ddbms1Ddbms1
Ddbms1
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
 
Database , 8 Query Optimization
Database , 8 Query OptimizationDatabase , 8 Query Optimization
Database , 8 Query Optimization
 
Switches on Networking
Switches on NetworkingSwitches on Networking
Switches on Networking
 

Viewers also liked

Chapter 17
Chapter 17Chapter 17
Chapter 17
stanbridge
 
2D Array
2D Array2D Array
2D Array
Swarup Boro
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
Rajendran
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overview
Ishraq Al Fataftah
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
Mindfire Solutions
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
EngineerBabu
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
soms_1
 
Design patterns
Design patternsDesign patterns
Design patterns
abhisheksagi
 
Array in c language
Array in c languageArray in c language
Array in c language
home
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
Education Front
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
eShikshak
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
Gagan Deep
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
Smit Parikh
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
Herman Peeren
 

Viewers also liked (14)

Chapter 17
Chapter 17Chapter 17
Chapter 17
 
2D Array
2D Array2D Array
2D Array
 
Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional array
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overview
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Array in c language
Array in c languageArray in c language
Array in c language
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in C
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns Illustrated
 

Similar to Design pattern (week 2)

Architecture and design
Architecture and designArchitecture and design
Architecture and design
himanshu_airon
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
saurabhshertukde
 
Object oriented sad-5 part ii
Object oriented sad-5 part iiObject oriented sad-5 part ii
Object oriented sad-5 part ii
Bisrat Girma
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
bonej010
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Object oriented analysis and design unit- iv
Object oriented analysis and design unit- ivObject oriented analysis and design unit- iv
Object oriented analysis and design unit- iv
Shri Shankaracharya College, Bhilai,Junwani
 
Design patterns
Design patternsDesign patterns
Design patterns
Vignesh Nethaji
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering
Bilal Hassan
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Dr. C.V. Suresh Babu
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-design
Oliver Cheng
 
software engineering Architecture and design Unit 3.pptx
software engineering Architecture and design Unit 3.pptxsoftware engineering Architecture and design Unit 3.pptx
software engineering Architecture and design Unit 3.pptx
SomnathMule5
 
Design patterns
Design patternsDesign patterns
Design patterns
Ahmed Elharouny
 
Open Framework for the Dynamic Reconfiguration of Component-Based Software
Open Framework for the Dynamic Reconfiguration of Component-Based SoftwareOpen Framework for the Dynamic Reconfiguration of Component-Based Software
Open Framework for the Dynamic Reconfiguration of Component-Based Software
Madjid KETFI
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
Mayukh Maitra
 
Software Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfSoftware Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdf
MeagGhn
 
Sda 9
Sda   9Sda   9
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
Saransh Garg
 
Seii unit7 component-level-design
Seii unit7 component-level-designSeii unit7 component-level-design
Seii unit7 component-level-design
Ahmad sohail Kakar
 
Design patterns
Design patternsDesign patterns
Design patterns
Elyes Mejri
 

Similar to Design pattern (week 2) (20)

Architecture and design
Architecture and designArchitecture and design
Architecture and design
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principles
 
Object oriented sad-5 part ii
Object oriented sad-5 part iiObject oriented sad-5 part ii
Object oriented sad-5 part ii
 
Software Patterns
Software PatternsSoftware Patterns
Software Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Object oriented analysis and design unit- iv
Object oriented analysis and design unit- ivObject oriented analysis and design unit- iv
Object oriented analysis and design unit- iv
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
Pressman ch-11-component-level-design
Pressman ch-11-component-level-designPressman ch-11-component-level-design
Pressman ch-11-component-level-design
 
software engineering Architecture and design Unit 3.pptx
software engineering Architecture and design Unit 3.pptxsoftware engineering Architecture and design Unit 3.pptx
software engineering Architecture and design Unit 3.pptx
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Open Framework for the Dynamic Reconfiguration of Component-Based Software
Open Framework for the Dynamic Reconfiguration of Component-Based SoftwareOpen Framework for the Dynamic Reconfiguration of Component-Based Software
Open Framework for the Dynamic Reconfiguration of Component-Based Software
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
 
Software Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfSoftware Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdf
 
Sda 9
Sda   9Sda   9
Sda 9
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technology
 
Seii unit7 component-level-design
Seii unit7 component-level-designSeii unit7 component-level-design
Seii unit7 component-level-design
 
Design patterns
Design patternsDesign patterns
Design patterns
 

More from stanbridge

Micro Lab 3 Lecture
Micro Lab 3 LectureMicro Lab 3 Lecture
Micro Lab 3 Lecture
stanbridge
 
Creating a poster v2
Creating a poster v2Creating a poster v2
Creating a poster v2
stanbridge
 
Creating a poster
Creating a posterCreating a poster
Creating a poster
stanbridge
 
Sample poster
Sample posterSample poster
Sample poster
stanbridge
 
OT 5018 Thesis Dissemination
OT 5018 Thesis DisseminationOT 5018 Thesis Dissemination
OT 5018 Thesis Dissemination
stanbridge
 
Ot5101 005 week 5
Ot5101 005 week 5Ot5101 005 week 5
Ot5101 005 week 5
stanbridge
 
Ot5101 005 week4
Ot5101 005 week4Ot5101 005 week4
Ot5101 005 week4
stanbridge
 
Compliance, motivation, and health behaviors
Compliance, motivation, and health behaviors Compliance, motivation, and health behaviors
Compliance, motivation, and health behaviors
stanbridge
 
Ch 5 developmental stages of the learner
Ch 5   developmental stages of the learnerCh 5   developmental stages of the learner
Ch 5 developmental stages of the learner
stanbridge
 
OT 5101 week2 theory policy
OT 5101 week2 theory policyOT 5101 week2 theory policy
OT 5101 week2 theory policy
stanbridge
 
OT 5101 week3 planning needs assessment
OT 5101 week3 planning needs assessmentOT 5101 week3 planning needs assessment
OT 5101 week3 planning needs assessment
stanbridge
 
Ot5101 week1
Ot5101 week1Ot5101 week1
Ot5101 week1
stanbridge
 
NUR 304 Chapter005
NUR 304 Chapter005NUR 304 Chapter005
NUR 304 Chapter005
stanbridge
 
NUR 3043 Chapter007
NUR 3043 Chapter007NUR 3043 Chapter007
NUR 3043 Chapter007
stanbridge
 
NUR 3043 Chapter006
NUR 3043 Chapter006NUR 3043 Chapter006
NUR 3043 Chapter006
stanbridge
 
NUR 3043 Chapter004
NUR 3043 Chapter004NUR 3043 Chapter004
NUR 3043 Chapter004
stanbridge
 
3043 Chapter009
3043 Chapter0093043 Chapter009
3043 Chapter009
stanbridge
 
3043 Chapter008
 3043 Chapter008 3043 Chapter008
3043 Chapter008
stanbridge
 
Melnyk ppt chapter_21
Melnyk ppt chapter_21Melnyk ppt chapter_21
Melnyk ppt chapter_21
stanbridge
 
Melnyk ppt chapter_22
Melnyk ppt chapter_22Melnyk ppt chapter_22
Melnyk ppt chapter_22
stanbridge
 

More from stanbridge (20)

Micro Lab 3 Lecture
Micro Lab 3 LectureMicro Lab 3 Lecture
Micro Lab 3 Lecture
 
Creating a poster v2
Creating a poster v2Creating a poster v2
Creating a poster v2
 
Creating a poster
Creating a posterCreating a poster
Creating a poster
 
Sample poster
Sample posterSample poster
Sample poster
 
OT 5018 Thesis Dissemination
OT 5018 Thesis DisseminationOT 5018 Thesis Dissemination
OT 5018 Thesis Dissemination
 
Ot5101 005 week 5
Ot5101 005 week 5Ot5101 005 week 5
Ot5101 005 week 5
 
Ot5101 005 week4
Ot5101 005 week4Ot5101 005 week4
Ot5101 005 week4
 
Compliance, motivation, and health behaviors
Compliance, motivation, and health behaviors Compliance, motivation, and health behaviors
Compliance, motivation, and health behaviors
 
Ch 5 developmental stages of the learner
Ch 5   developmental stages of the learnerCh 5   developmental stages of the learner
Ch 5 developmental stages of the learner
 
OT 5101 week2 theory policy
OT 5101 week2 theory policyOT 5101 week2 theory policy
OT 5101 week2 theory policy
 
OT 5101 week3 planning needs assessment
OT 5101 week3 planning needs assessmentOT 5101 week3 planning needs assessment
OT 5101 week3 planning needs assessment
 
Ot5101 week1
Ot5101 week1Ot5101 week1
Ot5101 week1
 
NUR 304 Chapter005
NUR 304 Chapter005NUR 304 Chapter005
NUR 304 Chapter005
 
NUR 3043 Chapter007
NUR 3043 Chapter007NUR 3043 Chapter007
NUR 3043 Chapter007
 
NUR 3043 Chapter006
NUR 3043 Chapter006NUR 3043 Chapter006
NUR 3043 Chapter006
 
NUR 3043 Chapter004
NUR 3043 Chapter004NUR 3043 Chapter004
NUR 3043 Chapter004
 
3043 Chapter009
3043 Chapter0093043 Chapter009
3043 Chapter009
 
3043 Chapter008
 3043 Chapter008 3043 Chapter008
3043 Chapter008
 
Melnyk ppt chapter_21
Melnyk ppt chapter_21Melnyk ppt chapter_21
Melnyk ppt chapter_21
 
Melnyk ppt chapter_22
Melnyk ppt chapter_22Melnyk ppt chapter_22
Melnyk ppt chapter_22
 

Recently uploaded

"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
DanBrown980551
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
BibashShahi
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 

Recently uploaded (20)

"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
AppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSFAppSec PNW: Android and iOS Application Security with MobSF
AppSec PNW: Android and iOS Application Security with MobSF
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
LF Energy Webinar: Carbon Data Specifications: Mechanisms to Improve Data Acc...
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Principle of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptxPrinciple of conventional tomography-Bibash Shahi ppt..pptx
Principle of conventional tomography-Bibash Shahi ppt..pptx
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 

Design pattern (week 2)

  • 1. Introduction  Design patterns are medium-scale patterns. They are smaller in scale than architectural patterns, but are at a higher level than the programming language-specific idioms. Architectural Patterns Design Patterns programming language-specific idioms
  • 2. Group Design Patterns  Structural Decomposition  Organization of Work  Access Control  Management  Communication
  • 3. Overview(1)  Structural Decomposition This category includes patterns that support a suitable decomposition of subsystems and complex components into cooperating parts. The Whole- Part pattern is the most general pattern we are aware of in this category.  Organization of Work. This category comprises patterns that define how components collaborate together to solve a complex problem. We describe the Master-Slave pattern, which helps you to organize the computation of services for which fault tolerance or computational accuracy is required.
  • 4. Overview(2)  Access Control. Such patterns guard and control access to services or components. We describe the Proxy pattern here.  Management. This category includes patterns for handling homogenous collections of objects, services and components in their entirety. We describe two patterns: the Command Processor pattern addresses the management and scheduling of user commands, while the View Handler pattern describes how to manage views in a software system.
  • 5. Overview(3)  Communication. Patterns in this category help to organize communication between components. Two patterns address issues of inter-process communication: the Forwarder-Receiver pattern deals with peer-to-peer communication, while the Client Dispatcher-Server pattern describes location-transparent communication in a Client-Server structure. The Publisher- Subscriber pattern helps with the task of keeping data consistent between cooperating components. *An important property of all design patterns is that they are independent of a particular application domain. *Most design patterns are independent of a particular programming paradigm.
  • 6. Structural Decomposition(1)  Structural Decomposition  Organization of Work  Access Control  Management  Communication
  • 7. Structural Decomposition()  The Whole-Part design pattern helps with the aggregation of components that together form a semantic unit.  The Composite pattern organizes objects into tree structures that represent part-whole hierarchies.
  • 8. The Whole-part Design Pattern  Example  Context  Problem  Solution  Structure  Dynamics  Implementation  Variants  Example Resolved  Known Uses  See also
  • 10. Whole-part-- Context  Context Implementing aggregate objects.
  • 11. Whole-part-- Problem  A complex object should either be decomposed into smaller objects, or composed of existing objects, to support reusability, changeability and the recombination of the constituent objects in other types of aggregate.  Clients should see the aggregate object as an atomic object that does not allow any direct access to its constituent parts.
  • 12. Whole-part-- Solution Introduce a component that encapsulates smaller objects, and prevents clients from accessing these constituent parts directly. Define an interface for the aggregate that is the only means of access to the functionality of the encapsulated objects. allowing the aggregate to appear as a semantic unit. The general principle of the Whole-Part pattern is applicable to the organization of three types of relationship:  An assembly-parts relationship  A container-contents relationship  The collection-members relationship
  • 17. Whole-part– Implementation(1) 1 Design the public interface of the Whole. Analyze the functionality the Whole must offer to its clients. 2 Separate the Whole into Parts, or synthesize it from existing ones. There are two approaches:  The bottom-up approach allows you to compose Wholes from loosely-coupled Parts that you can later reuse when implementing other types of Whole.  The top-down approach makes it is possible to cover all of the Whole's functionality.
  • 18. Whole-part– Implementation(2) 3 If you follow a bottom-up approach, use existing Parts from component libraries or class libraries and specify their collaboration. 4 If you follow a top-down approach, partition the Mirhole's services into smaller collaborating services and map these collaborating services to separate Parts.
  • 19. Whole-part– Implementation(3) 5 Specify the services of the W'hole in terms of services of the Parts.---two possible ways to call a Part service:  If a client request is forwarded to a Part service, the Part does not use any knowledge about the execution context of the Whole, relying on its own environment instead.  A delegation approach requires the Whole to pass its own context information to the Part.
  • 20. Whole-part– Implementation(4) 6 Implement the Parts. If the Parts are Whole-Part structures themselves, design them recursively starting with step 1. If not, reuse existing Parts from a library, or just implement them if their implementation is straightforward and further decomposition is not necessary. 7 Implement the Whole. Implement the Whole's services based on the structure you developed in the preceding steps.
  • 21. Whole-part– Variants(1) Shared Parts. This variant relaxes the restriction that each Part must be associated with exactly one Whole by allowing several Wholes to share the same Part.
  • 22. Whole-part– Variants(2) The next three variants describe the implementation of the Whole-to-Parts relationships we introduced in the Solution section:  Assembly-Parts In this variant the Whole may be an object that represents an assembly of smaller objects.  Container-Contents. In this variant a container is responsible for maintaining differing contents.  The Collection-Members variant is a specialization of Container-Contents, in that the Part objects all have the same type.
  • 26. Whole-part– Known Uses  The key abstractions of many object-oriented applications follow the Whole-Part pattern.  Most object-oriented class libraries provide collection classes such as lists. sets. and maps. These classes implement the Collection-Member and Container-Contents variants.  Graphical user interface toolkits such as Fresco or ET++ use the Composite variant of the Whole- Part pattern.
  • 27. Whole-part– Consequences Benefits:  Changeability of Parts  Separation of concerns  Reusability liabilities:  Lower eminency through indirection  Complexity of decomposition into Parts
  • 28. Whole-part– See also the Composite design pattern is applicable when:  You want to represent whole-part hierarchies of objects.  You want clients to be able to ignore the difference between compositions of objects and individual objects.  Composite is a variant of the Whole-Part design pattern that you should consider when facing these two requirements.  The Facade design pattern helps to provide a simple interface to a complex subsystem.
  • 29. 3.3 Organization of Work(1)  Structural Decomposition  Organization of Work  Access Control  Management  Communication
  • 30. Organization of Work(2)  The implementation of complex services is often solved by several components in cooperation.  The Master-Slave pattern supports fault computation and computational accuracy.  Master-Slave applies the 'divide and conquer' principle.  The Master-Slave pattern is widely applied in the areas of parallel and distributed computing.  The Chain of Responsibility, Command and Mediator patterns also belong to this category
  • 31. 3.3.1Master-Slave  Example  Context  Problem  Solution  Structure  Dynamics  Implementation  Variants  Known Uses  See also
  • 33. Master-Slave-- Context  Context Partitioning work into semantically- identical sub-tasks.
  • 34. Master-Slave– Problem(1)  Clients should not be aware that the calculation is based on the “divide and conquer” principle.  Neither clients nor the processing of sub- tasks should depend on the algorithms for partitioning work and assembling the final result.
  • 35. Master-Slave– Problem(2)  It can be helpful to use different but semantically-identical implementations for processing sub-tasks, for example to increase computational accuracy.  Processing of sub-tasks sometimes needs coordination, for example in simulation applications using the finite element method.
  • 36. Master-Slave-- Solution A master component divides work into equal sub-tasks, delegates these sub-tasks to several independent but semantically-identical shve components, and computes a final result from the partial results the slaves return. This general principle is found in three application areas:  Fault tolerance  Parallel computing  Computational accuracy
  • 39. Master-Slave—Dynamics(1)  A client requests a service from the master  The master partitions the task into several equal sub-tasks.  The master delegates the execution of these sub-tasks to several slave instances, starts their execution and waits for the results they return  The slaves perform the processing of the sub-tasks and return the results of their computation back to the master  The master computes a final result for the whole task from the partial results received from the slaves  The master returns this result to the client
  • 41. Master-Slave– Implementation(1) The implementation of the Master-Slave pattern follows five steps: 1.Divide work. Specify how the computation of the task can be split into a set of equal sub-tasks. Identify the sub-services that are necessary to process a sub-task. 2.Combine sub-task results. Specify how the final result of the whole service can be computed with the help of the results obtained from processing individual sub-tasks.
  • 42. Master-Slave– Implementation(2) 3. Specify the cooperation between master and slaves. Define an interface for the sub-service identified in step 1. It will be implemented by the slave and used by the master to delegate the processing of individual sub-tasks. 4.Implement the slave components according to the specifications developed in the previous step. 5.Implement the master according to the specifications developed in step 1 to 3.
  • 43. Master-Slave– Variants(1) Master Slave for fault tolerance. In this variant the master just delegates the execution of a service to a fixed number of replicated implementations, each represented by a slave. Master-Slave for parallel computation. The master divides a complex task into a number of identical sub-tasks, each of which is executed in parallel by a separate slave. The master builds the final result from the results obtained from the slaves.
  • 44. Master-Slave– Variants(2) Master-Slave for computational accuracy. The execution of a service is delegated to at least three different implementations, each of which is a separate slave.
  • 45. Master-Slave– Variants(3) Further variants exist for implementing slaves: Slaves as Processes. To handle slaves located in separate processes, you can extend the original Master-Slave structure with two additional components Slaves as Threads. Every slave is implemented within its own thread of control. Master Slave with slave coordination. The computation of a slave may depend on the state of computation of other slaves
  • 46. Master-Slave– Known Uses  Matrix multiplication. Each row in the product matrix can be computed by a separate slave.  Transform-coding an image, for example in computing the discrete cosine transform (DCT) of every 8 x 8 pixel block in an image. Each block can be computed by a separate slave.  Computing the cross-correlation of two signals. This is done by iterating over all samples in the signal, computing the mean-square distance between the sample and its correlate, and summing the distances.
  • 47. Master-Slave– Consequences Benefits:  Exchangeability and extensibility  Separation of concerns  Efficiency liabilities:  Feasibility  Hard to implement  Portability
  • 48. Master-Slave– See also  The Master-Slave Pattern for Parallel Compute Services [Bro96] provides additional insights for implementing a Master-Slave structure.  The book Programming with Threads [KSS96] describes the Slaves as Threads variant in detail.  Object Group [Maf96] is a pattern for group communication and support of fault tolerance in distributed applications. It corresponds to the Master- Slave for fault tolerance variant and provides additional details for its implementation.
  • 49. 3.4 Access Control (1)  Structural Decomposition  Organization of Work  Access Control  Management  Communication
  • 50. Access Control(2)  Sometimes a component or even a whole subsystem cannot or should not be accessible directly by its clients.  The Proxy design pattern makes the clients of a component communicate with a representative rather than to the component itself.  The Facade pattern provides a uniform interface to a set of interfaces in a subsystem.  The Iterator pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.
  • 51. 3.4.1Proxy  Example  Context  Problem  Solution  Structure  Dynamics  Implementation  Variants  Example Resolved  Known Uses  See also
  • 53. Proxy-- Context  Context A client needs access to the services of another component. Direct access is technically possible, but may not be the best approach.
  • 54. Proxy– Problem(1)  Accessing the component should be run-time- efficient, costeffective, and safe for both the client and the component.  Access to the component should be transparent and simple for the client. The client should particularly not have to change its calling behavior and syntax from that used to call any other direct-access component.
  • 55. Proxy– Problem(2)  The client should be well aware of possible performance or financial penalties for accessing remote clients. Full transparency can obscure cost differences between services.
  • 56. Proxy-- Solution Let the client communicate with a representative rather than the component itself. This representative-called a proxy-offers the interface of the component but performs additional pre- and post- processing such as access-control checking or making read-only copies of the original.
  • 57. Proxy—Structure(1)  The original implements a particular service.  The client is responsible for a specific task.  The abstract original provides the interface implemented by the proxy and the original
  • 60. Proxy—Dynamics(1)  While working on its task the client asks the proxy to carry out a service.  The proxy receives the incoming service request and pre- processes it.  If the proxy has to consult the original to fulfill the request, it forwards the request to the original using the proper communication protocols and security measures.  The original accepts the request and fulfills it. It sends the response back to the proxy.  The proxy receives the response.
  • 62. Proxy– Implementation(1) To implement the Proxy pattern, carry out the following steps: 1. Identify all responsibilities for dealing with access control to a component. 2. 2 If possible introduce an abstract base class that specifies the common parts of the interfaces of both the proxy and the original. Derive the proxy and the original from this abstract base.
  • 63. Proxy– Implementation(2) 3. Impkment the proxy's finctions. To this end check the roles specified in the first step. 4. Free the original and its clients from responsibilities that have migrated into the proxy. 5. Associate the proxy and the original by giving the proxy a handle to the original. 6. Remove all direct relationships between the original and its clients.
  • 64. Proxy– Variants(1) Remote Proxy. Clients of remote components should be shielded from network addresses and inter- process communication protocols. Protection Proxy. Components must be protected from unauthorized access. Cache Proxy. Multiple local clients can share results from remote components. Synchronization Proxy. Multiple simultaneous accesses to a component must be synchronized.
  • 65. Proxy– Variants(2) Counting Proxy. Accidental deletion of components must be prevented or usage statistics collected. Virtual Proxy. Processing or loading a component is costly, while partial information about the component may be sufficient. Firewall Proxy. Local clients should be protected from the outside world.
  • 66. Proxy– Example Resolved You may often need to use more than one of the above Proxy variants Resolved -you may want the proxy to play several of the above roles and fulfill the corresponding responsibilities. You can solve remote data access problems by using proxies with the properties of both Remote and Cache Proxy variants. Implementing such a mixed-mode proxy can be accomplished by using the Whole-Part pattern
  • 67. Proxy– Known Uses(1)  NeXTSTEP. The Proxy pattern is used in the NeXTSTEP operating system to provide local stubs for remote objects.  OMG-CORBA uses the Proxy pattern for two purposes. Socalled 'client-stubs', or IDL-stubs, guard clients against the concrete implementation of their servers and the Object Request Broker.  Orbix, a concrete OMG-CORBA implementation, uses remote proxies.
  • 68. Proxy– Known Uses(2)  World Wide Web Proxy describes aspects of the CERN HTTP server that typically runs on a firewall machine. It gives people inside the firewall concurrent access to the outside world. Efficiency is increased by caching recently transferred files.  OLE. In Microsoft OLE servers may be implemented as libraries dynamically linked to the address space of the client, or as separate processes. Proxies are used to hide whether a particular server is local or remote from a client
  • 69. Proxy– Consequences Benefits:  Enhanced egiciency and lower cost  Decoupling clients from the location of seruer components  Separation of housekeeping code from functionality liabilities:  Less emiency due to indirection  Overkill via sophisticated strategies
  • 70. Proxy– See also  The Decorator pattern is very similar in structure to Proxy. Concrete component-the original in the Proxy pattern-implements some behavior that is invoked via a decorator-the proxy in the Proxy pattern. Both classes inherit from a common base. The major difference between the Decorator and Proxy patterns is one of intent. The decorator adds functionality or, more generally, gives options for dynamically choosing functionality in addition to the core functionality of Concrete component. The proxy frees the original from very specific housekeeping code.