Upload
vanthien
View
251
Download
0
Embed Size (px)
Citation preview
Patterns in Software Engineering
Lecturer: Raman Ramsin
Lecture 9Lecture 9
GoV Patterns: Design
Department of Computer Engineering1
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
GoV Design Patterns: CategoriesGoV Design Patterns: CategoriesStructural Decomposition
Support a suitable decomposition of subsystems and complex components intoSupport a suitable decomposition of subsystems and complex components into cooperating parts. Whole-Part
Organization of WorkOrganization of Work Define how components collaborate together to solve a complex problem. Master-Slave
Access ControlAccess Control Guard and control access to services or components. Proxy
ManagementHandle homogenous collections of objects, services and components in their entirety. Command Processor and View Handler
Communication Help to organize communication between components. Forwarder-Receiver Client-Dispatcher-Server and Publisher-Subscriber
Department of Computer Engineering2
Sharif University of Technology
Forwarder-Receiver, Client-Dispatcher-Server, and Publisher-Subscriber
Patterns in Software Engineering – Lecture 9
Design: Structural DecompositionDesign: Structural Decomposition
Whole-Part : Helps with the aggregation of components that together form a semantic unit.
An aggregate component, the whole:encapsulates its constituent components: the parts;organizes the parts’ collaboration; andorganizes the parts collaboration; and provides a common interface to its functionality.
Direct access to the parts is not possible.Analogous to the State-over-a-Collection and Behavior-over-a-Collection patterns
The Composite pattern also belongs to this categoryThe Composite pattern also belongs to this category.
Department of Computer Engineering3
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Design: Organization of WorkDesign: Organization of Work
Master-Slave: supports fault tolerance, parallel computation pp , p pand computational accuracy. A master component:
distributes work to identical slave components, and
computes a final result from the results these slaves return.
The Chain of Responsibility, Command and Mediatorpatterns also belong to this category.
Department of Computer Engineering4
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Organization of Work: Master-Slave – StructureOrganization of Work: Master Slave Structure
A master component pdistributes work to identical slave components; computes a final result from the results these slaves return.
The master component provides a service that can be solved by applyingThe master component provides a service that can be solved by applying the 'divide and conquer' principle.
Department of Computer Engineering5
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Organization of Work: Master-Slave – DynamicsOrganization of Work: Master Slave Dynamics
Department of Computer Engineering6
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Design: Access ControlDesign: Access Control
Proxy: makes the clients of a component communicate with a representative rather than to the component itself.
The Facade and Iterator patterns also belong to this tcategory.
Department of Computer Engineering7
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Design: ManagementDesign: Management
Command Processor: separates the request for a service from its p qexecution. A command processor component:
manages requests as separate objects, h d l th ti f th t dschedules the execution of the requests, and
provides additional services such as the storing of request objects for later undo.
View Handler: helps to manage views in a software system. A view handler component:
allows clients to open, manipulate and dispose of views, coordinates dependencies between views, and organizes the update of the views.g p
The Memento pattern also belongs to this category.
Department of Computer Engineering8
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Management: Command Processor – StructureManagement: Command Processor Structure Manages requests as separate objects, schedules their execution, and provides relevant servicesrelevant services.Builds on the Command design pattern.
Whenever a user calls a specific function of the application, the request is turned into a Command objectinto a Command object.A Command object delegates the execution of its task to supplier components.The Command Processor takes care of all command objects.
Department of Computer Engineering9
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Management: Command Processor – DynamicsManagement: Command Processor Dynamics
Department of Computer Engineering10
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Management: View HandlerManagement: View Handler
A view handler componentA view handler component
manages all views that the software system provides,
allows clients to open manipulate and dispose of views andallows clients to open, manipulate and dispose of views, and
coordinates dependencies between views and organizes their update.
Specific views, together with functionality for their presentation and control are encapsulated within separate view components one forcontrol, are encapsulated within separate view components - one for each kind of view.
Suppliers provide views with the data they must present.
Department of Computer Engineering11
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Management: View Handler – StructureManagement: View Handler Structure
Department of Computer Engineering12
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Management: View Handler – Dynamics (1)Management: View Handler Dynamics (1)
Scenario I: The view handler creates a new view.Scenario I: The view handler creates a new view.
Department of Computer Engineering13
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Management: View Handler – Dynamics (2)Management: View Handler Dynamics (2)
Scenario II: The view handler organizes the tiling of views.Scenario II: The view handler organizes the tiling of views.
Department of Computer Engineering14
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Design: CommunicationDesign: Communication
Forwarder-Receiver: provides transparent inter-process communication for software systems with a peer-to-peer interaction model.
Introduces forwarders and receivers to decouple peers from theIntroduces forwarders and receivers to decouple peers from the underlying communication mechanisms.
Client-Dispatcher-Server: introduces an intermediate layer between clients and servers: the dispatcher component.
P id l ti t b f iProvides location transparency by means of a name service. Hides the details of the establishment of the communication connection between clients and servers.
Publisher-Subscriber: The same as the Observer pattern.
Department of Computer Engineering15
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Communication: Forwarder-ReceiverCommunication: Forwarder Receiver
Peer components:ibl f li i kare responsible for application tasks,
know the names of the remote peers with which they need to communicate, and use a forwarder to send messages to other peers and a receiver to receive g pmessages from other peers.
Forwarder components: send messages across process boundaries,provide a general interface for sending messages, marshal and deliver messages to remote receivers, and g ,map names to physical addresses.
Receiver components: are responsible for receiving messages,provide a general interface for receiving messages, and receive and unmarshal messages from remote forwarders
Department of Computer Engineering16
Sharif University of Technology
receive and unmarshal messages from remote forwarders.
Patterns in Software Engineering – Lecture 9
Communication: Forwarder-Receiver – StructureCommunication: Forwarder Receiver Structure
Department of Computer Engineering17
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Communication: Forwarder-Receiver – DynamicsCommunication: Forwarder Receiver Dynamics
Department of Computer Engineering18
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Communication: Client-Dispatcher-ServerCommunication: Client Dispatcher Server
Provides a dispatcher component to act as an intermediate layer between p p yclients and servers. The dispatcher
implements a name service that allows clients to refer to servers by names instead of physical locations, thus providing location transparency, andinstead of physical locations, thus providing location transparency, and is responsible for establishing the communication channel between a client and a server.
Before sending a request to a server, the client asks the dispatcher for a communication channel.
The client uses this channel to communicate with the server.
A id t f ti t li tA server provides a set of operations to clients. It either registers itself or is registered with the dispatcher by its name and address.
Department of Computer Engineering19
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Communication: Client-Dispatcher-Server – Structure p
Department of Computer Engineering20
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
Communication: Client-Dispatcher-Server – Dynamics p y
Department of Computer Engineering21
Sharif University of Technology
Patterns in Software Engineering – Lecture 9
R fReference
Buschmann, F., Meunier, R., Rohnert, H., Sommerlad, P., and Stal M Pattern Oriented Software Architecture: A System ofStal, M., Pattern-Oriented Software Architecture: A System of Patterns, Vol. 1. Wiley, 1996.
Department of Computer Engineering22
Sharif University of Technology