SlideShare ist ein Scribd-Unternehmen logo
1 von 70
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.

Weitere ähnliche Inhalte

Was ist angesagt?

Azure Service Bus
Azure Service BusAzure Service Bus
Azure Service BusJosh Lane
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다Arawn Park
 
CORBA - Introduction and Details
CORBA - Introduction and DetailsCORBA - Introduction and Details
CORBA - Introduction and Detailsdgsdg2websd
 
Introduction to CQRS (Command Query Responsibility Segregation)
Introduction to CQRS (Command Query Responsibility Segregation)Introduction to CQRS (Command Query Responsibility Segregation)
Introduction to CQRS (Command Query Responsibility Segregation)GlobalLogic Ukraine
 
Microservices with Apache Camel, DDD, and Kubernetes
Microservices with Apache Camel, DDD, and KubernetesMicroservices with Apache Camel, DDD, and Kubernetes
Microservices with Apache Camel, DDD, and KubernetesChristian Posta
 
Public vs private vs hybrid cloud what is best for your business-
Public vs private vs hybrid cloud  what is best for your business-Public vs private vs hybrid cloud  what is best for your business-
Public vs private vs hybrid cloud what is best for your business-Everdata Technologies
 
Java web services using JAX-WS
Java web services using JAX-WSJava web services using JAX-WS
Java web services using JAX-WSIndicThreads
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkHùng Nguyễn Huy
 
Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Achmad Solichin
 
Cloud computing
Cloud computingCloud computing
Cloud computingcompherals
 
Microservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudMicroservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudBen Wilcock
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework tola99
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System IntroductionDan Stine
 
.php1 : les fondamentaux du PHP
.php1 : les fondamentaux du PHP.php1 : les fondamentaux du PHP
.php1 : les fondamentaux du PHPAbdoulaye Dieng
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts Bharat Kalia
 
Object oriented modeling and design
Object oriented modeling and designObject oriented modeling and design
Object oriented modeling and designjayashri kolekar
 
Resource scheduling algorithm
Resource scheduling algorithmResource scheduling algorithm
Resource scheduling algorithmShilpa Damor
 
Intro to AsyncAPI
Intro to AsyncAPIIntro to AsyncAPI
Intro to AsyncAPIconfluent
 

Was ist angesagt? (20)

Azure Service Bus
Azure Service BusAzure Service Bus
Azure Service Bus
 
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다
 
CORBA - Introduction and Details
CORBA - Introduction and DetailsCORBA - Introduction and Details
CORBA - Introduction and Details
 
Introduction to CQRS (Command Query Responsibility Segregation)
Introduction to CQRS (Command Query Responsibility Segregation)Introduction to CQRS (Command Query Responsibility Segregation)
Introduction to CQRS (Command Query Responsibility Segregation)
 
Microservices with Apache Camel, DDD, and Kubernetes
Microservices with Apache Camel, DDD, and KubernetesMicroservices with Apache Camel, DDD, and Kubernetes
Microservices with Apache Camel, DDD, and Kubernetes
 
Public vs private vs hybrid cloud what is best for your business-
Public vs private vs hybrid cloud  what is best for your business-Public vs private vs hybrid cloud  what is best for your business-
Public vs private vs hybrid cloud what is best for your business-
 
Java web services using JAX-WS
Java web services using JAX-WSJava web services using JAX-WS
Java web services using JAX-WS
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Microservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloudMicroservices - java ee vs spring boot and spring cloud
Microservices - java ee vs spring boot and spring cloud
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Java 9 Module System Introduction
Java 9 Module System IntroductionJava 9 Module System Introduction
Java 9 Module System Introduction
 
.php1 : les fondamentaux du PHP
.php1 : les fondamentaux du PHP.php1 : les fondamentaux du PHP
.php1 : les fondamentaux du PHP
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
Middleware Technologies ppt
Middleware Technologies pptMiddleware Technologies ppt
Middleware Technologies ppt
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
Object oriented modeling and design
Object oriented modeling and designObject oriented modeling and design
Object oriented modeling and design
 
Resource scheduling algorithm
Resource scheduling algorithmResource scheduling algorithm
Resource scheduling algorithm
 
Intro to AsyncAPI
Intro to AsyncAPIIntro to AsyncAPI
Intro to AsyncAPI
 

Andere mochten auch

Two dimensional array
Two dimensional arrayTwo dimensional array
Two dimensional arrayRajendran
 
Publish subscribe model overview
Publish subscribe model overviewPublish subscribe model overview
Publish subscribe model overviewIshraq Al Fataftah
 
Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design patternMindfire Solutions
 
Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)Array Presentation (EngineerBaBu.com)
Array Presentation (EngineerBaBu.com)EngineerBabu
 
Design Patterns
Design PatternsDesign Patterns
Design Patternssoms_1
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppteShikshak
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : ArraysGagan Deep
 
Multidimensional array in C
Multidimensional array in CMultidimensional array in C
Multidimensional array in CSmit Parikh
 
Design Patterns Illustrated
Design Patterns IllustratedDesign Patterns Illustrated
Design Patterns IllustratedHerman Peeren
 

Andere mochten auch (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
 

Ähnlich wie Design pattern (week 2)

Architecture and design
Architecture and designArchitecture and design
Architecture and designhimanshu_airon
 
Design concepts and principles
Design concepts and principlesDesign concepts and principles
Design concepts and principlessaurabhshertukde
 
Object oriented sad-5 part ii
Object oriented sad-5 part iiObject oriented sad-5 part ii
Object oriented sad-5 part iiBisrat Girma
 
Software Patterns
Software PatternsSoftware Patterns
Software Patternsbonej010
 
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 DesignDr. 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-designOliver 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.pptxSomnathMule5
 
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 SoftwareMadjid KETFI
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technologyMayukh Maitra
 
Software Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfSoftware Engineering Tools and Practices.pdf
Software Engineering Tools and Practices.pdfMeagGhn
 
Component based models and technology
Component based models and technologyComponent based models and technology
Component based models and technologySaransh Garg
 
Seii unit7 component-level-design
Seii unit7 component-level-designSeii unit7 component-level-design
Seii unit7 component-level-designAhmad sohail Kakar
 

Ähnlich wie 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
 

Mehr von stanbridge

Micro Lab 3 Lecture
Micro Lab 3 LectureMicro Lab 3 Lecture
Micro Lab 3 Lecturestanbridge
 
Creating a poster v2
Creating a poster v2Creating a poster v2
Creating a poster v2stanbridge
 
Creating a poster
Creating a posterCreating a poster
Creating a posterstanbridge
 
OT 5018 Thesis Dissemination
OT 5018 Thesis DisseminationOT 5018 Thesis Dissemination
OT 5018 Thesis Disseminationstanbridge
 
Ot5101 005 week 5
Ot5101 005 week 5Ot5101 005 week 5
Ot5101 005 week 5stanbridge
 
Ot5101 005 week4
Ot5101 005 week4Ot5101 005 week4
Ot5101 005 week4stanbridge
 
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 learnerstanbridge
 
OT 5101 week2 theory policy
OT 5101 week2 theory policyOT 5101 week2 theory policy
OT 5101 week2 theory policystanbridge
 
OT 5101 week3 planning needs assessment
OT 5101 week3 planning needs assessmentOT 5101 week3 planning needs assessment
OT 5101 week3 planning needs assessmentstanbridge
 
NUR 304 Chapter005
NUR 304 Chapter005NUR 304 Chapter005
NUR 304 Chapter005stanbridge
 
NUR 3043 Chapter007
NUR 3043 Chapter007NUR 3043 Chapter007
NUR 3043 Chapter007stanbridge
 
NUR 3043 Chapter006
NUR 3043 Chapter006NUR 3043 Chapter006
NUR 3043 Chapter006stanbridge
 
NUR 3043 Chapter004
NUR 3043 Chapter004NUR 3043 Chapter004
NUR 3043 Chapter004stanbridge
 
3043 Chapter009
3043 Chapter0093043 Chapter009
3043 Chapter009stanbridge
 
3043 Chapter008
 3043 Chapter008 3043 Chapter008
3043 Chapter008stanbridge
 
Melnyk ppt chapter_21
Melnyk ppt chapter_21Melnyk ppt chapter_21
Melnyk ppt chapter_21stanbridge
 
Melnyk ppt chapter_22
Melnyk ppt chapter_22Melnyk ppt chapter_22
Melnyk ppt chapter_22stanbridge
 

Mehr von 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
 

Kürzlich hochgeladen

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 

Kürzlich hochgeladen (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 

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.