ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

Similar documents
ADVANCED SOFTWARE DESIGN LECTURE 4 GRASP. Dave Clarke

XVIII. Software Architectures

XIX. Software Architectures

An Introduction to Software Architecture. David Garlan & Mary Shaw 94

An Introduction to Software Architecture

Architectural Styles. Software Architecture Lecture 5. Copyright Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy. All rights reserved.

System Design. Acknowledge: Atlee and Pfleeger (Software Engineering: Theory and Practice)

An Introduction to Software Architecture

An Introduction to Software Architecture By David Garlan & Mary Shaw 94

Information Expert (or Expert)

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

Topic : Object Oriented Design Principles

Products of Requirements elicitation and analysis. Chapter 6: System design: decomposing the system

XVIII. Software Architectures

CAS 703 Software Design

CSE 435: Software Engineering. System Design

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

Architectural Design. CSCE Lecture 12-09/27/2016

Object-Oriented Design

GRASP: Patterns for. chapter18

Architectural Styles - Finale

17. GRASP: Designing Objects with Responsibilities

5/9/2014. Recall the design process. Lecture 1. Establishing the overall structureof a software system. Topics covered

Software Architecture

GRASP ing at the First 5 Patterns Principles CSSE 574: Session 3, Part 4

Establishing the overall structure of a software system

Software Architecture

Architectural Design

CSCI 3130 Software Architectures 1/3. February 5, 2013

ICS 52: Introduction to Software Engineering

Introduction to Software Engineering 10. Software Architecture

DISTRIBUTED COMPUTER SYSTEMS ARCHITECTURES

Engr. M. Fahad Khan Lecturer Software Engineering Department University Of Engineering & Technology Taxila

Refresher: Lifecycle models. Lecture 22: Moving into Design. Analysis vs. Design. Refresher: different worlds. Analysis vs. Design.

Object-Oriented Design

Chapter 6 Architectural Design. Lecture 1. Chapter 6 Architectural design

ICS 52: Introduction to Software Engineering

Architectural Styles II

Design Patterns Design patterns advantages:

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

System Design. Design: HOW to implement a system

Architectural Blueprint

Design Process Overview. At Each Level of Abstraction. Design Phases. Design Phases James M. Bieman

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

Architectural Design. Architectural Design. Software Architecture. Architectural Models

Design Concepts and Principles

WHAT IS SOFTWARE ARCHITECTURE?

Chapter 13: Architecture Patterns

Design Engineering. Overview

DS 2009: middleware. David Evans

Chapter 6 Architectural Design. Chapter 6 Architectural design

CAS 703 Software Design

ESE Einführung in Software Engineering!

Chapter 6 System Design: Decomposing the System

Architectural Styles I

1 Software Architecture

Architecture Styles. Instructor: Yongjie Zheng February 7, CS 5553: Software Architecture and Design

Software Engineering (CSC 4350/6350) Rao Casturi

6/20/2018 CS5386 SOFTWARE DESIGN & ARCHITECTURE LECTURE 5: ARCHITECTURAL VIEWS C&C STYLES. Outline for Today. Architecture views C&C Views

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

VEL TECH HIGH TECH Dr. RANGARAJAN Dr. SAKUNTHALA ENGINEERING COLLEGE UNIT 1 UML DIAGRAMS

Common Architectural Styles & Patterns

In this Lecture you will Learn: System Design. System Architecture. System Architecture

Element: Relations: Topology: no constraints.

Architectural Design

Design: HOW to implement a system

Objectives. Architectural Design. Software architecture. Topics covered. Architectural design. Advantages of explicit architecture

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod

Software Architecture

CSSE 374: GRASP ing at the First Five Patterns Principles. Shawn Bohner Office: Moench Room F212 Phone: (812)

Client/Server-Architecture

System Design. Design: HOW to implement a system

Lecture 1. Chapter 6 Architectural design

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

WHO WANTS TO BE A DESILLIONAIRE GAME RULES INTERNATIONAL TEAM OF EXPERTS MAIN IDEA INTERACTIVE SYSTEMS SOFTWARE ARCHITECTURAL STYLES

Architectural Styles and Non- Functional Requirements

Appendix A - Glossary(of OO software term s)

GUI-Hanger syndrome SOFTWARE ARCHITECTURES. Architectural Design Choices. Why software architectures? Monolithic Architecture / 2

Patterns and Testing

Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions

6. System Design: Decomposing the System

Credit where Credit is Due. Goals for this Lecture. Introduction to Design

Responsibilities. Using several specific design principles to guide OO design decisions.

Architectural Design. Topics covered. Architectural Design. Software architecture. Recall the design process

Creational. Structural

An Introduction to Software Architecture By David Garlan & Mary Shaw 94

Chapter 6 Architectural Design

Object-Oriented Design

Object Persistence Design Guidelines

Application Architectures, Design Patterns

Patterns Architectural Styles Archetypes

Electronic Payment Systems (1) E-cash

Object Analysis & Design in the textbook. Introduction to GRASP: Assigning Responsibilities to Objects. Responsibility-Driven Design

References: Applying UML and patterns Craig Larman

COMP 6471 Software Design Methodologies

System Design. Design Issues. System Design. System Design. Design: HOW to implement a system. Strategic vs. Local Design Decisions.

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Architectural Design

Software Paradigms (Lesson 10) Selected Topics in Software Architecture

GRASP 2. CSC 440: Software Engineering Slide #1

Transcription:

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE Dave Clarke 1

THIS LECTURE At the end of this lecture you will know notations for expressing software architecture the design principles of cohesion and coupling various different architectural styles 2

DEFINITION 3

SOFTWARE ARCHITECTURE A Software Architecture defines: the components of the software system how the components use each other s functionality and data how control is managed between the components The highest level of design large-scale structure of solution 4

BUILDING BLOCKS 5

SUBSYSTEMS A replaceable part with well-defined interfaces that encapsulates the state and behaviour of its contained classes Two UML possibilities: Component and packages diagrams 6

PACKAGE DIAGRAMS Packages Hierarchy Dependency Useful for expressing the dependencies between major elements of a system. 7

COMPONENT DIAGRAMS Component a set of related operations that share a common purpose Interface the set of operations available to other sub-systems Required interface Provided interface Plugging 8

NOTATION I LL USE module connector module architecture: 9

COUPLING AND COHESION 10

COUPLING AND COHESION Coupling: Amount of relations between sub-systems Low coupling general design goal: Independence, supportability May lead to extra layers of abstraction Cohesion: Amount of relations within a sub-system High cohesion general design goal: Reduce complexity Often a trade-off 11

PROPERTIES OF A GOOD ARCHITECTURE minimises coupling between modules Goal: modules don t need to know much about one another to interact Low coupling makes future change easier maximises cohesion within modules Goal: the contents of each module are strongly inter-related High cohesion makes a module easier to understand X Applies also to classes 12

LOW COUPLING 13

PROBLEM How to support low dependency, low change impact, and increase reuse? 14

COUPLING Measure how strongly one element is connected to, has knowledge of or relies on other elements. An element with weak low (or weak) coupling is not dependent on too many other elements. 15

WHEN ARE TWO CLASSES COUPLED? Common forms of coupling from TypeX to TypeY: TypeX has an attribute that refers to a TypeY instance. A TypeX object calls on services of a TypeY object. TypeX has a method that references an instance of TypeY (parameter, local variable, return type). TypeX is a direct or indirect subclass of TypeY. TypeY is an interface and TypeY implements that interface. 16

HIGH COUPLING (BAD) A class with high (or strong) coupling relies on many other classes. Such classes may be undesirable and suffer from the following problems: Forced local changes because of changes in related classes. Harder to understand in isolation. Harder to reuse because its use requires the additional presence of the classes on which it is dependent. 17

SOLUTION Assign responsibility so that coupling remains low. Use this principle to evaluate alternatives. 18

EXAMPLE Consider the following classes. Payment Register Sale We need to create a Payment instance and associate it with the Sale. Which class should be responsible? 19

POSSIBILITY #1 makepayment() :Register 1:create() p:payment 2:addPayment(p) :Sale This is the solution Creator pattern (later) would suggest. 20

POSSIBILITY #2 makepayment() :Register 1:makePayment() :Sale 1.1:create() :Payment 21

WHICH IS BETTER? Assume that each Sale will eventually be coupled with a Payment. Design #1 has the coupling of Register and Payment, which is absent in Design #2. Design #2 therefore has lower coupling. Note that two patterns Low Coupling and Creator suggest different solutions. Do not consider patterns in isolation. 22

DISCUSSION. Low coupling encourages designs to be more independent, which reduces the impact of change. Needs to be considered with other patterns such as Information Expert (later) and High Cohesion. Subclassing increases coupling especially considering Domain objects subclassing technical services (e.g., PersistentObject) High coupling to stable global objects is not problematic to Java libraries such as java.util. 23

PICK YOUR BATTLES The problem is not high coupling per se; it is high coupling to unstable elements. Designers can future proof various aspects of the system using lower coupling and encapsulation, but there needs to be good motivation. Focus on points of realistic high instability and evolution. 24

HIGH COHESION 25

PROBLEM How to keep objects focussed, understandable, and manageable, and as a side-effect, support Low Coupling? Cohesion is a measure of how strongly related and focused the responsibilities of an element are. An element with highly related responsibilities that does not do a tremendous amount of work has high cohesion. 26

LOW COHESION A class with low cohesion does many unrelated things or does too much work. Such classes are undesirable; they suffer from the following problems: hard to comprehend hard to reuse hard to maintain delicate; constantly affected by change. 27

SOLUTION Assign responsibility so that cohesion remains high. Use this to evaluate alternatives. 28

EXAMPLE 29

LOW COHESION Game is doing all the work. How related are tasks A, B, C? If not strongly related, then design has low cohesion. 30

HIGH COHESION Delegates and distributes the work, presumably to objects with appropriately assigned responsibilities. 31

DISCUSSION Very low cohesion: a class that does two completely different tasks, e.g., database connectivity and RPC. Low cohesion: a class that has sole responsibility for a complex task in one functional area, e.g., one single interface responsible for all database access. Moderate cohesion: a lightweight class, solely responsible for a few logically related areas, e.g., Company that knows the employees and the financial details. High cohesion: a class with moderate responsibilities in one functional area that collaborates with other classes. 32

RULES OF THUMB For high cohesion, a class must have few methods have a small number of lines of code not do too much work have high relatedness of code. 33

ARCHITECTURAL STYLES 34

ARCHITECTURAL STYLES Object-oriented Client server; object broker; peer to peer Pipe and filter Event based publish/subscriber Layered Three-tier, Four-tier Repositories: blackboard, Model/View/Controller (MVC) Process control 35

OBJECT-ORIENTED ARCHITECTURES Example Abstract data types (modules) Interesting properties data hiding (internal data representations are not visible to clients) can decompose problems into sets of interacting agents can be multi-threaded or single thread Disadvantages amples: abstract data types objects must know the identity of objects they wish to interact with object method invocation method invocation object object object method invocation method invocation object 36

VARIANT: CLIENT-SERVER Variant 1: Client Server Interesting properties client client method invocation Clients do not need to know about one another method invocation nteresting properties Breaks the system into manageable components Independent flow of control Is a special case of the previous pattern object oriented archite Server generally responsible for persistence and consistency of data Disadvantages Client objects must know the identity of the server client Server method invocation 37

CLIENT-SERVER Client/Server communication via remote procedure call or common object broker (e.g. CORBA, Java RMI, or HTTP) Distributed systems. e.g,. web services, system with central DBMS Variants thick clients have their own services thin ones get everything from servers 38

VARIANT: OBJECT BROKER Variant 2: Object Brokers server server broker client client Interesting Properties client resting properties Adds a broker between the clients and servers Clients no longer need to know which server they are using Can have many brokers, many servers. Disadvantages Broker can become a bottleneck Degraded performance 39

VARIANT: PEER-TO-PEER Peer Peer Interesting Properties Find peers via server or broadcast. Peer Server/Tracker/ Directory Peer Interact subsequently with peers. Peer Reduces bottleneck. Robust to peer failure. Disadvantages Server can become a bottleneck Peers have only incomplete picture synchronisation is (virtually) impossible 40

PIPE AND FILTER Examples Unix command shell pipe filter filter pipe pipe filter filter pipe pipe filter pipe filter pipe Examples: compiler chain: lexical analysis parsing semantic analysis code generation pipe pipe signal processing Interesting properties: grep gustav < foo.txt sort cut f2-3 filters don't need to know anything about what they are connected to filters can be implemented in parallel behaviour of the system is the composition of behaviour of the filters specialised analysis such as throughput and deadlock analysis is possible 41

BROKER ARCHITECTURE EXAMPLE Broker Architecture Example 42

EVENT-BASED (IMPLICIT INVOCATION) Examples debugging systems (listen for particular breakpoints) database management systems (for data integrity checking) graphical user interfaces Interesting properties announcers of events don t need to know who will handle the event supports re-use, and evolution of systems (add new agents easily) Disadvantages es agent agent announce event listen for event Components have no control over ordering of computations broadcast medium announce event listen for event agent agent 43

LAYERED SYSTEMS Examples Operating Systems communication protocols users application layer utilities kernal Interesting properties ms Support increasing levels of abstraction during design Support enhancement (add functionality) and re-use can define standard layer interfaces Disadvantages May not be able to identify (clean) layers 44

LAYERS AND PARTITIONS Layering Hierarchical decomposition tree of sub-systems Horizontal division Open vs closed layers Partitioning Vertical division : Each set handles a function Extreme form of decoupling: Semi-independent 45

EXAMPLE: 3-LAYER DATA ACCESS riant: 3-layer data a Presentation layer Appl n Views Java AWT Application Logic layer Business logic Contol objects Storage layer Query Engine DBMS File Mgmnt 46

OPEN VS CLOSED ARCHITECTURE closed architecture each layer only uses services of the layer immediately below; minimises dependencies between layers and reduces the impact of a change. Layer N Layer N-1 Layer 2 Layer 1 open architecture a layer can use services from any lower layer. More compact code, as the services of lower layers can be accessed directly Breaks the encapsulation of layers, so increase dependencies between layers Layer N Layer N-1 Layer 2 Layer 1 47

HOW MANY LAYERS? 2 layers: application layer database layer e.g., simple client-server model layers? Application (client) Database (server) 3 layers (three tier): separate out the business logic helps make both user interface and database layers modifiable 4 layers (four tier): separate applications from the domain entities that they use boundary classes in presentation layer control classes in application layer entity classes in domain layer partitioned 4 layers: identify separated applications Presentation layer (user interface) Business Logic Database Presentation layer (user interface) Applications Domain Entities Database UI1 UI2 UI3 UI4 App1 App2 App3 App4 Domain Entities Database 48

REPOSITORIES Examples databases blackboard expert systems programming environments agent agent agent blackboard (shared data) agent agent agent Interesting properties can choose where the locus of control is (agents, blackboard, both) reduce the need to duplicate complex data Disadvantages blackboard becomes a bottleneck 49

REPOSITORY Sub-systems access and modify a single data structure Complex, changing data Concurrency & data consistency Control by sub-systems or by repository (blackboard) Disadvantage: Possibly performance bottlenecks and reduced modifiability E.g. databases, IDE s, tuple spaces 50

MODEL-VIEW-CONTROLLER view propagate propagate view controller access update model access update controller Properties roperties One central model, many views (viewers) Each view has an associated controller The controller handles updates from the user of the view Changes to the model are propagated to all the views 51

MODEL-VIEW-CONTROLLER (MVC) Can be seen as a special case of repository: Model contains domain knowledge (= repository) Views only display data Controllers only manage interaction sequences Model does not depend on views or controllers Subscribe/notify mechanism Interactive systems Same potential drawbacks as the repository pattern 52

EXAMPLE MODEL-VIEW-CONTROLLER Model View Controller Example 53

MVC INTERACTION MVC Component Interaction 54

PROCESS CONTROL Examples control parameters aircraft/spacecraft flight control Examples systems controller manipulated variables input variables actuators process sensors controlled variables controllers for industrial production lines, power stations, etc. chemical engineering Interesting properties separates control policy from the controlled process handles real-time, reactive computations Disadvantages difficult to specify the timing characteristics and response to disturbances 55

THIS LECTURE This lecture covered notations for expressing software architecture the design principles of cohesion and coupling various different architectural styles 56