1 / 64

Software Architecture Prof.Dr.ir. F. Gielen

Software Architecture Prof.Dr.ir. F. Gielen. Architectural Patterns. What is a Pattern?.

tracy
Télécharger la présentation

Software Architecture Prof.Dr.ir. F. Gielen

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software ArchitectureProf.Dr.ir. F. Gielen Architectural Patterns Vakgroep Informatietechnologie – IBCN

  2. What is a Pattern? “ Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice …” • Christopher Alexander Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  3. Taxonomy of Patterns & Idioms Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  4. C++ idioms: Array - Tabel • Find an element in a list • C++ idiom: for(int i = 0; i < N; i++) • Typical mistake: array index overrun Linked List • Add or delete an element to a list. • C++ idiom: for(link t=x; t !=0; t=t->next) • Typical mistake : null pointers, memory leaks. Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  5. Design Patterns • Design Patterns • Elements of Reusable • Object-Oriented Software E. Gamma, R. Helm, R. Johnson, J. Vlissides (the “Gang of Four”) • Addison-Wesley, 1995 • ISBN: 0-201-63361-2 Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  6. Design Patterns … “Design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context” • Gang of Four Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  7. Design Pattern example : Strategy TextProcessor text search(String) searcher SearchAlgorithm searchFor(String, Text) 1 SearchAlgorithm2 searchFor(String, Text) SearchAlgorithm1 searchFor(String, Text) • Use the Strategy pattern when • Many related classes that differ only in their behaviour • You need different variants of an algorithm • An algorithm uses data that clients should not know about • A class defines many behaviours Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  8. Design patternsare applicable towards the end of coarse-grained design when refining and extending the fundamental architecture of a software system. Design patterns are also applicable in the detailed design stage for specifying local design aspects (e.g. multiple implementations of a component) Architectural patternscan be used at the beginning of coarse grained design, when specifying the fundamental structure of an application (cf. first iteration(s) of the ADD method) Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  9. Architectural patterns & ADD 1. Choose the module to decompose • Start with entire system • Inputs for this module need to be available • Constraints, functional and quality requirements 2. Refine the module • Choose architectural drivers relevant to this decomposition • Choose the architectural patterns that satisfies these drivers • Instantiate modules and allocate functionality from use cases representing using multiple views. • Define interfaces of child modules. • Verify and refine use cases and quality scenarios. 3. Repeat for every module that needs further decomposition Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  10. Architectural Style and Patterns Architectural Styles are recurring organisational patterns and idioms. A style consists of key features and rules for combining those features so that the architectural integrity is maintained. • Benefits of Style: • Reuse: well understood solutions applied to new problems • Common vocabulary leads to understandability of organisation. (e.g. Client Server,broker,…) • Style specific analysis. Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  11. Architectural Integrity Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  12. What Makes a Architectural Pattern? • Context A situation giving rise to a problem • General context : developing software with a flexible human-computer interface • Specific context : managing the change-propagation in a flight simulator or avionics system Specifying the correct context for a pattern is difficult : • Impossible to determine all situations • List known context situations for a pattern can give valuable guidance Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  13. What Makes a Architectural Pattern? • Problem The recurring problem arising in that context • Requirements the solution must fulfill : e.g. Peer-to-peer inter-process communication must be efficient • Constraints you must consider : e.g. That inter-process communication must follow a particular protocol, client has to run on smart phones • Desirable properties the solution should have : e.g. changing software should be easy In the context of ADD these are quality requirements. Constraints can be found in the feature description Desirable properties are almost always related to modifiability and reuse Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  14. What Makes a Architectural Pattern? • Solution Structure with components and relationships Run-time behavior A pattern is a mental building block. After applying a pattern architectures should include a particular structure that provides for the roles specified by the pattern, but adjusted and tailored to the specific needs of the problem at hand. Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  15. Software Architecture Pattern is: • A set of component types • process, data repository, procedure • Topological layout of the components • configuration rules, relations • A set of semantic rules and constraints: • compositions have well defined meanings • A set of connectors for communication , co-ordination and co-operation between components • subroutine call, sockets, message queues Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  16. Independent Components Communicating Processes Event Based Systems Architectural Style Catalogue Data Flow Data Centered Blackboard Repository Pipes & Filters Batch Sequential Call & Return Layered Object Oriented Virtual Machines Interpreter Rule based Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  17. Data Flow Architectures • Key feature: • Dominated by motion of data through the system • datastreams • Pipes and Filters • Filters are independent entities (components) • incremental: output begins before input is consumed • example : Unix shell programs, compiler Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  18. Architectural Pattern: Pipes and Filters (Data Flow) Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  19. Example : Multimedia Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  20. Independent Components Communicating Processes Event Based Systems Architectural Style Catalogue Data Flow Data Centered Blackboard Repository Pipes & Filters Batch Sequential Call & Return Layered Object Oriented Virtual Machines Interpreter Rule based Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  21. Data-Centered Architectures Key Feature: • Dominated by a complex central data store, manipulated by independent components. • Repository • Passive data store: file, database • Blackboard • Active data store: sends events to the subscribers • Artificial Intelligence • Speech and Pattern recognition Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  22. Control Architectural Pattern: Blackboard (Data Centered) Knowledge Source Knowledge Source Blackboard (shared data) • Vocabulary • Hypothesis • Abstraction level Knowledge Source Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  23. Architectural Pattern: Blackboard • Define the problem • Define the solution space for the problem • Divide the solution process into steps • Divide the knowledge into specialized knowledge sources with certain subtasks • Define the vocabulary of the blackboard • Specify the control of the system • Implement the knowledge sources Example HEARSAY II used a blackboard architecture to recognize human speech. In this case the raw data was acoustical data which was to be transformed into a database query. Contributors/knowledge sources existed for transforming acoustical data (level 0, wave forms) into phonetic data (level 1, phonemes), phonetic data into lexical data (level 2, words), lexical data into syntactical data (level 3, phrases), and syntactical data into queries (level 4). Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  24. Architectural Pattern: Blackboard Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  25. Independent Components Communicating Processes Event Based Systems Architectural Style Catalogue Data Flow Data Centered Blackboard Repository Pipes & Filters Batch Sequential Call & Return Layered Object Oriented Virtual Machines Interpreter Rule based Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  26. Call and Return Architectures • Key Feature • Dominated by order of computation • Examples • Abstract data types • Object Oriented • Layered • Call based Client/Server Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  27. & OS Domain-Specific Services Common Middleware Services Distribution Middleware Host Infrastructure Middleware Operating Systems & Protocols The Evolution of Middleware Historically, mission-critical apps were built directly atop hardware Applications • Tedious, error-prone, & costly over lifecycles There are layers of middleware, just like there are layers of networking protocols Standards-based COTS middleware helps: • Control end-to-end resources & QoS • Leverage hardware & software technology advances • Evolve to new environments & requirements • Provide a wide array of reusable, off-the-shelf developer-oriented services Hardware There are multiple COTS middleware layers & research/business opportunities Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  28. Architectural Pattern: Layers Structure Dynamics Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  29. Communication protocols • FTP • TCP • IP • Ethernet Architectural Pattern: Layers • Define the abstraction criterion • Determine the number of abstraction levels • Name the layers and assign tasks to each of them • Specify the services • Refine the layering • Specify the interfaces for each layer • Structure individual layers • Specify the communication between adjacent layers • Decouple adjacent layers Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  30. Architectural Pattern: Layers Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  31. Model-View-Controller Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  32. MVC structure Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  33. Architectural Pattern: Model-View-Controller Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  34. MVC analysis Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  35. Architectural Style Catalogue Data Flow Data Centered Blackboard Repository Pipes & Filters Batch Sequential Call & Return Independent Components Layered Object Oriented Virtual Machines Communicating Processes Event Based Systems Interpreter Rule based Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  36. Independent Components • Key Features • Dominated by communication patterns. • Components communicate through messages. • They send data; not control. • Examples • Event systems • Implicit invocation • Announcers of events do not know which components will be affected by the event • Communicating processes Shaw and Garlan Software Architecture in Practice Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  37. Broker: Broker Forwarding Pattern Broker 2: forwardedRequest 1: clientRequest 4: forwardedReply 3: serverReply Client Server Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  38. Broker Components: CRC Broker Client Server Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  39. Architectural Pattern: Broker • Define an object model • Decide which kind of component-interoperability the system should offer • Specify the API’s the broker component provides for collaborating with client and server • Use proxy objects to hide implementation details from clients and servers • Design the broker component in parallel with steps 3 and 4 • Specify protocol, message buffers, directory service, dynamic method invocation, IDL compiler… CORBA IBM SOM/DSOM Microsoft’s OLE 2.x World Wide Web: hypertext browers such as Netscape act as brokers and WWW servers play the role of service providers Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  40. Architectural Pattern: Broker Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  41. Broker Handle Pattern Direct communication: same protocol or proxy Broker R2: registrationAck B1: clientBrokerRequest B2: serviceHandle R1: registerService B3: clientServiceRequest Client Server B4: serverReply Here the proxy takes some of the broker’s responsibilities for handling most of the communication activities Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  42. AbstractService Proxy Service service service service pre-processing: e.g.,marshaling post-processing: e.g., unmarshaling Client : Client : Proxy : Service service 1 1 service Design Pattern: Proxy Structure Dynamics Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  43. Design Pattern: Proxy Examples: Firewall proxy, cache proxy, … 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 (combination of different proxy types!!!) Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  44. Example: Java RMI • Remote Method Invocation (RMI) is a Java mechanism similar to RPCs. • RMI allows a Java program on one machine to invoke a method on a remote object. Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  45. Stub &skeleton implementation. Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  46. Broker Proxies Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  47. Server Proxy Client Proxy marshal unmarshal dispatch receive_request marshal unmarhal receive_result service_p Structure Broker 1 1 * * calls * message exchange main_loop srv_registration srv_lookup xmit_message manage_QoS message exchange calls * 1 1 Server Client start_up main_loop service_i call_service_p start_task Broker Pattern Revisited: Proxy Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  48. : Client : Server : Server Proxy : Client Proxy : Broker register_service start_up operation (params) connect assigned port marshal Dynamics send_request unmarshal dispatch operation (params) result receive_reply marshal unmarshal result Broker Pattern Revisited: Proxy Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  49. Subscribe Message Manager Publish Event Based Systems • Individual components announce data that they wish to share with other components: Publish. • Other components can register an interest in a class of data: Subscribe. • Typically involves a message manager that controls communication between components • Example: debuggers, databases, brokers Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

  50. Filter Subscriber filterEvent consume Event Dynamics Structure consume Publisher Event Channel : Publisher : Event Channel : Subscriber attachPublisher detachPublisher attachSubscriber detachSubscriber pushEvent attachSubscriber produce produce : Event pushEvent event pushEvent event creates receives * detachSubscriber Publisher-Subscriber Vakgroep Informatietechnologie – Onderzoeksgroep IBCN

More Related