بسم هللا الرحمن الرحيم والصالة والسالم على رسول هللا، الحمد هلل Software Architecture Styles Hany H. Ammar, Professor, LANE Department of Computer Science and Electrical Engineering West Virginia University, Morgantown, West Virginia, USA, and Visiting Professor, Faculty of Computers and Information, Cairo University, Cairo, Egypt Modeling and Documenting Software Architectures 1 OUTLINE Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • SW Systems Mix of Architecture Styles • Other Important Styles • Modeling and Documenting Software Architectures 2 Introduction Recall the definition of Styles • An architectural style is a coordinated set of architectural constraints that restricts the roles/features of architectural elements and the allowed relationships among those elements within any architecture that conforms to that style. Introduction What does it give us? • An architectural style describes a certain codification of elements and their arrangements. • Conversely, an architectural style constrains both the elements and their interrelationships. • It specifies components and connectors types Introduction Example Component Types Ex: Con nect or Type s Examples of Popular Architecture Styles Families of Architecture Styles • There is a number of families of styles that has been defined and used in many software systems Notable examples are: 1. Independent Components: Event-based Architectures 2. Virtual Machines 3. Data Flow: Pipes and Filters 4. Data-Centered Systems 5. Call-and Return Architectures Modeling and Documenting Software Architectures 8 OUTLINE • Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return Modeling and Documenting Software Architectures 9 Architectural Styles Independent Components 1. Independent Components. Architecture is viewed a set of independent processes or objects or components that communicate through messages. Two subfamilies: - Event based systems (implicit and direct invocation style), and - Communicating processes family (client-server style). Modeling and Documenting Software Architectures 10 Architectural styles: Event-based Architecture Some processes post events, others express an interest in events Modeling and Documenting Software Architectures 11 Event-based Architecture Event-based Architecture Implicit Invocation: The Observer Pattern Modeling and Documenting Software Architectures 14 Modeling and Documenting Software Architectures 15 Another Example: Lunar Lander Game Players Subscribers register to the Game Server that Publishes information on new Lunar Terrain data, new spacecraft, and the locations of currently registered space crafts Component-connector notation Summary of Event-Based Style 1.Independent Components asynchronously emit and receive events communicated over event buses 2.Components are independent concurrent even generators and consumers 3.Data elements are events sent as first class entities over the event bus Communicating Processes: ClientServer Architecture Style OUTLINE • Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return Modeling and Documenting Software Architectures 20 Architectural Styles Virtual Machines 2. Virtual Machines. Originated from the concept that programs are treated as data by a virtual machine, which is an abstract machine implemented entirely in software, that runs on top of the actual hardware machine. Ex: rulebased style. Modeling and Documenting Software Architectures 21 Architectural Styles Virtual Machines Virtual Machines: The primary benefits are the separation between instruction and implementation, (Used when inputs are defined by a script and data) Example: Java Virtual Machine. Java code translated to platform independent bytecodes. JVM is platform specific and interprets (or compiles -JIT) the bytecodes. Modeling and Documenting Software Architectures 23 Virtual Machines Style Virtual Machines Style Example OUTLINE • Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return Modeling and Documenting Software Architectures 26 Architectural Styles Data Flow 3. Data Flow. Include Batch Sequential Systems (BSS) and Pipes and Filters (PF). - BSS: different components take turns at processing a batch of data, each saving the result of their processing in a shared repository that the next component can access. Ex. Dynamic control of physical processes based on a feedback loop. - PF: A stream of data processed by a complex structure of process (filters). Ex, UNIX. Modeling and Documenting Software Architectures 27 Architectural Styles Data Flow: Control Loop and Pipes and Filters Control Loop Modeling and Documenting Software Architectures 28 BSS Architecture Style Example BSS Style Summary PF Example concurrency between components (Filters) is allowed PF example in Embedded Systems concurrency between components (Filters) is allowed A Robotics Example Modeling and Documenting Software Architectures 33 PF Another Architecture Example: Watch for the Two Views Modeling and Documenting Software Architectures 34 PFs Style Summary OUTLINE • Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return Modeling and Documenting Software Architectures 36 Data-Centered Architectural Styles 4. Data-Centered Systems. Consist of having different components communicate through shared data repositories. When data repository is an active repository that notifies registered components of changes in it then-blackboard style. Modeling and Documenting Software Architectures 37 Data-Centered Architectural Styles Repository Architecture Style Data-Centered Architectural Styles Repository Architecture Example: CASE Tools Example Data-Centered Architectural Styles Repository Architecture Example: Compiler Architecture Data-Centered Architectural Styles Blackboard Architecture Style: Components perusing shared data, and communicating through it. Used in Database intensive systems Modeling and Documenting Software Architectures 41 Data-Centered Architectural Styles Blackboard Architecture Style Example Compare with the PFs Style Data-Centered Architectural Styles Blackboard Architecture Style: Intelligent Agent Systems Example Data-Centered Architectural Styles Blackboard Architecture Style: Travel Counseling System Example Data-Centered Architectural Styles Blackboard Architecture Style: Intelligent Agent Systems Example Blackboard Architecture Style: Intelligent Agent Systems Example Data-Centered Architectural Styles Blackboard and Publish/Subscribe Styles: Intelligent Agent Systems Example Blackboard Architecture Style Rule-Based or Expert System Architecture Style: Three components, a user interface, an inference engine, and a knowledgebase Rule-Based or Expert Systems Style OUTLINE • Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • SW Systems Mix of Architecture Styles Modeling and Documenting Software Architectures 51 Architectural styles Call-and Return Family 5. Call-and Return Architectures. Due to heir simple control paradigm and component interaction mechanism , these architectures have dominated the SW landscape by the early decades of the SW Eng. • There are several styles within this family: examples are main program and subroutine, and layered architectures. -) Main Program and Subroutine Style. Programs are modularized based on functional decomposition, single thread of control held by the main program, which is then passed to subprograms, along with some data on which the subprograms can operate. Modeling and Documenting Software Architectures 52 Main Program and Subroutine Style Register.exe Course registration System example PeopleInfo CourseInfo Course StudentInfo CourseOffering Modeling and Documenting Software Architectures 53 ProfessorInfo Call-and Return Architectural styles -) Layered. Functionality is divided into layers of abstractioneach layer provides services to the layer(s) above it, and uses the services of layer(s) below it. In its purest form, each layer access only the layer below it, but does not depend on lower layers. Modeling and Documenting Software Architectures Based on general systems 54 Architecture, Network Architectures, etc. Layered Architectural styles Example of a Layered Application Architecture Layered Architectural styles Example: Interactive Electronic Technical Manual Layered Architecture IETM Electronic Display System (EDS) IETM Data Data Access Data Layer Business Layer User Interface Presentation Layer Layered Architectural styles A Robotics Architecture The Reactive Layer contains basic skills of the robot such as grasping an object and behavior that must execute immediately in response to inputs from sensors. The Sequencing Layer combines functions in the reactive layer into more complex behavior. The Planning Layer performs slower Long-term planning OUTLINE • Introduction • Software Architecture Styles •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • SW Systems Mix of Architecture Styles Modeling and Documenting Software Architectures 58 SW Systems-Mix of Architecture Styles • Most SW systems use a mix of architecture styles. Ex, personnel management system with a scheduling component, implemented using the independent component style, and a payroll component, using the batch sequential style. Modeling and Documenting Software Architectures 59 SW Systems-Mix of Architecture Styles Quality Attributes tradeoffs • Choosing a style to implement a particular system depends on several factors based on stakeholders concerns. • The typical factors concern the level of quality attributes that each style enables us to attain. EX, event-based systems-achieve very high level of evolvability, at the expense of performance and complexity. • Virtual-machine style-achieve very high level of portability, at expense of performance and perhaps even testability. SW Systems-Mix of Architecture Styles Components of each Layer use different architecture styles SW Systems-Mix of Architecture Styles OUTLINE Introduction • Software Architecture Styles • •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • SW Systems Mix of Architecture Styles • Other Important Styles • Buffered Massage-Based • Model-View-Controller • Presentation-Abstraction-Control • Broker Architecture Style • Service Oriented Architecture (SOA) Modeling and Documenting 63 • Peer-to-Peer Architecture Software Architectures Buffered Massage-Based Software Architecture Style In the J2EE Paltform, • Java Massage Server (JMS) ia an API thatprovides Asynchronous massage queuing mechanism • Massage Driven Bean (MDB) is a special type of EJBs that consumes asynchronous massages Buffered Massage-Based Software Architecture Style Clients can publish massages on the JMS and MDBs register with the JMS to receive Certain massage topics (asynchronous massage based publish/subscribe). Buffered Massage-Based Software Architecture Style • The MDB plays the role of a massage listener It can connect remote Session EJBs or Entity EJBs Web Application Example Massage-Based Architecture Style consists of three types of components Massage-Based Architecture Style Massage-Based Architecture Style OUTLINE Introduction • Software Architecture Styles • •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • Other Important Styles • • • • • • Buffered Massage-Based Model-View-Controller Presentation-Abstraction-Control Broker Architecture Style Service Oriented Architecture (SOA) Peer-to-Peer Architecture Modeling and Documenting Software Architectures 71 Model-View-Controller Architecture Style • The Controller manipulates the data Model • The View retrieves data from the model and displays needed information Model-View-Controller Architecture Style Dynamic Interactions Model-View-Controller Architecture Style Web Applications Java-based Implementation Example OUTLINE Introduction • Software Architecture Styles • •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • Other Important Styles • • • • • • Buffered Massage-Based Model-View-Controller Presentation-Abstraction-Control Broker Architecture Style Service Oriented Architecture (SOA) Peer-to-Peer Architecture Modeling and Documenting Software Architectures 75 Presentation-Abstraction-Control Agents Architecture Style • • • • • Based on MVC Style but geared towards agent-oriented Systems Consists of a Hierarchy of Agents, each agent with a P, A, and C components The C component in each agent is in charge with communicating with other agents The top-level agent is in charge of the core data and business logics Lower-Level Agents provides detailed data and presentation Presentation-Abstraction-Control Agents Architecture Style Example • Simple Presentation Application that can display Pages of a presentation • Consists one a top-level agent 1 and four lower level agents • Agent 1 have access to the pages, and the other agents respond to user requests for first, previous, next and last pages A scenario capturing the event of pressing the next button Presentation-Abstraction-Control Style Presentation-Abstraction-Control Style PAC Style vs MVC Style OUTLINE Introduction • Software Architecture Styles • •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • Other Important Styles • • • • • • Buffered Massage-Based Model-View-Controller Presentation-Abstraction-Control Broker Architecture Style Service Oriented Architecture (SOA) Peer-to-Peer Architecture Modeling and Documenting Software Architectures 81 Broker Architecture Style Brokers gets requests from client proxies and manages them by forwarding to server Proxies or dispatches them to other connected brokers Broker Architecture Style Broker Architecture Style Broker Architecture Style Example: CORBA, Common Object Request Broker Architecture Client-Side Proxy IDL Server-Side Proxy (IDL) Example: CORBA, Common Object Request Broker Architecture OUTLINE Introduction • Software Architecture Styles • •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • Other Important Styles • • • • • • Buffered Massage-Based Model-View-Controller Presentation-Abstraction-Control Broker Architecture Style Service Oriented Architecture (SOA) Peer-to-Peer Architecture Modeling and Documenting Software Architectures 88 Service Oriented Architecture (SOA) Style Makes use of an Enterprise Service Bus ESB Used in web-based systems and distributed computing The SOA Style Before SOA nodes make resources available to other participants in the system as independent services that the participants access in a standardized way using the ESB Service Oriented Architecture (SOA) Style A Map of SOA Components Registry and Repository Manage and monitor Security Web Portals Human Business Process Management (BPM) Enterprise Service Bus (ESB) Data Services Process Services Business Logic Orchestration System BPM The ESB Performs: • data transformation • Intelligent routing • Real time monitoring • Exception handling • Service security Databases Systems of Record Cloud Services Architecture SOA supports Cloud Computing Models Cloud Services Architecture Human as a service, Software as a service, Infrastructure as a service OUTLINE Introduction • Software Architecture Styles • •Independent Components • Virtual Machines • Data Flow • Data-Centered • Call-and return • Other Important Styles • • • • • • Buffered Massage-Based Model-View-Controller Presentation-Abstraction-Control Broker Architecture Style Service Oriented Architecture (SOA) Peer-to-Peer Architecture Modeling and Documenting Software Architectures 93 Peer-to-Peer Architecture Style Peer-to-Peer Architecture Style The Gnutella Example • Pure Peer-to-Peer Architecture • A sends query for a data resource to neighbors B and H, they pass it on until the peer having the resource is found or until a certain threshold of hops is reached Peer-to-Peer Architecture Style The Gnutella Example Recent Versions of Gnutella supports two types of peers Ultra peers and Leaf peers Ultra peers runs in systems with fast internet connects and are responsible for request routing and responses, they are connected to a large number of other Ultra peers and leaf peers, while the leaf peers are connected to a small number of Ultra peers Peer-to-Peer Architecture Style The Skype Example • A mixed client-Server and Pee-to-Peer • Skype Peers get promoted to a supernode status based on their network connectivity And machine performance • Supernodes perform the Communication and routing of massages to establish a call • When a user logs in to the server he is connected to a supernode • If a peer becomes a supernode he unknowingly bears the cost of routing a potentially large number of calls. Peer-to-Peer Architecture Style The Skype Example Conclusions • An architectural style is a coordinated set of architectural constraints that restricts the roles/features of architectural elements and the allowed relationships among those elements • Choosing a style to implement a particular system depends on several factors based on stakeholders concerns and quality attributes • Most SW systems use a mix of architecture styles