Software Design
Software Design A software design is a precise description of a system, using variety of different perspective. Software design are complicated, therefore, they must be modeled. Software Design 2
Modeling as a design technique Similar to an architects blueprint A model is an abstraction of the underlying problem Designs are too complicated to develop from scratch Good designs tend to be build using models Abstract different views of the system Build models using precise notations (e.g., UML) Verify that the models satisfy the requirements Gradually add details to transform the models into the design Software Design 3
Modeling as a design technique Software Design 4
Modeling as a design technique - improved Software Design 5
UML a modeling notation Software Design 6
Software Architecture According to Shaw and Garlan [1] The Software Architecture of a system consists of a description of the system elements, interactions between the system elements, patterns that guide the system elements, and constraints on the relationships between system elements. Its a more abstract view of the design Its helpful for communication and complexity management Software Design 7
Software Architecture The software architecture of a program or computing system is a depiction of the system that aids in the understanding of how the system will behave. serves as the blueprint for both the system and the project developing it, defining the work assignments that must be carried out primary carrier of system qualities such as performance, modifiability, and security, none of which can be achieved without a unifying architectural vision. Architecture is an artifact for early analysis to make sure that a design approach will yield an acceptable system. http://www.sei.cmu.edu/architecture/ Software Design 8
The Software Architecture Stack Software Design 9
The Software Architecture Stack Software Design 10
Design Methodologies Software Design 11
Jumpstart Design from scratch is difficult templates, patterns, frameworks, Software Design 12
Spring Framework Software Design 13
Software Design 14
Improving Existing Designs Refactoring technique for restructuring an existing body of code, altering its internal structure without changing its external behavior Software Design 15
Design Patterns & Anti Patterns a formal way of documenting a solution to a design problem Anti patterns negative solutions Software Design 16
SOFTWARE ARCHITECTURE Software Design 17
Software Decomposition Software Decomposition Subsystem Partition Software Design Quality Coupling Cohesion Software Design 18
What is Subsystem Collection of software elements such as software modules and their relations The subsystem boundary is defined explicitly The dependency relations among subsystems are defined Using Partition and Layer techniques to minimize the dependency relations Software Design 19
Sample of Subsystem Decomposition Authoring Augmented Reality Modeling Workflow Inspection Workorder Repair Software Design 20
Partitions and Layers Partitioning and layering are techniques to achieve low coupling A large system is usually decomposed into subsystems using both, layers and partitions Partitions vertically divide a system into several independent (or weakly-coupled) subsystems that provide services on the same level of abstraction A layer is a subsystem that provides subsystem services to a higher layers (level of abstraction) A layer can only depend on lower layers A layer has no knowledge of higher layers Software Design 21
Subsystem Decomposition into Layers A: Subsystem Layer 1 B:Subsystem C:Subsystem D:Subsystem Layer 2 F:Subsystem E:Subsystem G:Subsystem Layer 3 Subsystem Decomposition Heuristics: No more than 7+/-2 subsystems More subsystems increase cohesion but also complexity (more services) No more than 4+/-2 layers, use 3 layers (good) Software Design 22
Closed Architecture (Opaque Layering) Any layer can only invoke operations from the immediate layer below Design goal: High maintainability, flexibility Software Design 23
Open Architecture (Transparent Layering) Any layer can invoke operations from any layers below Design goal: Runtime efficiency Software Design 24
Coupling and Cohesion Goal: Reduction of complexity while change occurs Cohesion measures the dependence among modules High cohesion: The modules in the subsystem perform similar tasks and are related to each other (via associations) Low cohesion: Lots of miscellaneous and auxiliary modules, no associations Software Design 25
Coupling and Cohesion Coupling measures dependencies between subsystems High coupling: Changes to one subsystem will have high impact on the other subsystem (change of model, massive recompilation, etc.) Low coupling: A change in one subsystem does not affect any other subsystem Subsystems should have as maximum cohesion and minimum coupling as possible: How can we achieve high cohesion? How can we achieve loose coupling? Software Design 26
Sample of Cohesion Subsystem A Subsystem B M1 M2 M3 M1 M2 M3 M4 M5 M4 M5 High Cohesion Low Cohesion Software Design 27
Sample of Coupling Subsystem A Subsystem A M1 M2 M1 M2 Subsystem B Subsystem B M3 M4 M3 M4 High Coupling Software Design Low Coupling 28
Software Architecture Design Software Architectural Styles Client/Server Peer-to-Peer Repository Model/View/Control Pipe and Filter Software Design 29
Software Architectural Styles Subsystem decomposition Identification of subsystems, services, and their relationship to each other. Specification of the system decomposition is critical. Patterns for software architecture Client/Server Peer-To-Peer Repository Model/View/Controller Pipes and Filters Software Design 30
Client/Server Architectural Style One or many servers provides services to instances of subsystems, called clients. Client calls on the server, which performs some service and returns the result Client knows the interface of the server (its service) Server does not need to know the interface of the client Response in general immediately Users interact only with the client Client * requester Server * provider service1() service2() servicen() Software Design 31
Client/Server Architectural Style Often used in database systems: Front-end: User application (client) Back end: Database access and manipulation (server) Functions performed by client: Customized user interface Front-end processing of data Initiation of server remote procedure calls Access to database server across the network Functions performed by the database server: Centralized data management Data integrity and database consistency Database security Concurrent operations (multiple user access) Centralized processing (for example archiving) Software Design 32
Design Goals for Client/Server Systems Service Portability Server can be installed on a variety of machines and operating systems and functions in a variety of networking environments Transparency, Location-Transparency The server might itself be distributed (why?), but should provide a single "logical" service to the user Performance Client should be customized for interactive display-intensive tasks Server should provide CPU-intensive operations Scalability Server should have spare capacity to handle larger number of clients Flexibility The system should be usable for a variety of user interfaces and end devices (eg. WAP Handy, wearable computer, desktop) Reliability System should survive node or communication link problems Software Design 33
Problems with Client/Server Architectural Styles Layered systems do not provide peer-to-peer communication Peer-to-peer communication is often needed Example: Database receives queries from application but also sends notifications to application when data have changed Software Design 34
Peer-to-Peer Architectural Style Generalization of Client/Server Architecture Clients can be servers and servers can be clients More difficult because of possibility of deadlocks Peer service1() service2() servicen() requester * * provider Software Design 35
Model/View/Controller Subsystems are classified into 3 different types Model subsystem: Responsible for application domain knowledge View subsystem: Responsible for displaying application domain objects to the user Controller subsystem: Responsible for sequence of interactions with the user and notifying views of changes in the model. MVC is a special case of a repository architecture: Model subsystem implements the central datastructure, the Controller subsystem explicitly dictate the control flow Software Design 36
Repository Architectural Style (Blackboard Architecture) Subsystems access and modify data from a single data structure Subsystems are loosely coupled (interact only through the repository) Control flow is dictated by central repository (triggers) or by the subsystems (locks, synchronization primitives) Repository Subsystem createdata() setdata() getdata() searchdata() Software Design 37
Pipe and Filter Subsystems process data received from a set of inputs and send results to other subsystems via a set of outputs The subsystems are called Filters The associations between the subsystems are called Pipes Sub1 Sub3 Pipe Sub4 Filter Sub2 Sub5 Software Design 38
Sample of Subsystem Decomposition Purchase Order Inventory Verification Goods Receive Invoice Payment Budgeting Decomposing a set of Subsystems Vendor Maintenance Software Design 39
Sample of Subsystem Decomposition Define the dependency among subsystems Vendor Maintenance Purchase Order Invoice Budgeting Payment Inventory Verification Goods Receive Software Design 40
Sample of Subsystem with Interfaces IPO1 IPO2 IIV1 IGR1 Purchase Order Inventory Verification Goods Receive IP1 Invoice Payment Budgeting Decomposing a set of Subsystems Vendor Maintenance Software Design 41
Sample of Hierarchy of Subsystems Finance Purchasing IPO1 Purchase Order Vendor Maintenance IPO2 Budgeting Payment IIV1 Inventory Inventory Verification IX1 Invoice IP1 IGR1 Goods Receive Bank System Software Design 42
Sample of Hierarchy of Subsystems (with Information Hiding) IPO1 IPO2 Finance IIV1 IX1 Purchasing Inventory IP1 IGR1 Bank System Software Design 43
Typical Sale Component Purchasing IPO1 IPO2 IPO1 IPO2 Purchase Order 1 Subsystem = 1 Component <<Component>> Purchasing Purchase Order Vendor Maintenance Invoice Invoice Vendor Maintenance Software Design 44
Typical Sale Component (with Information Hiding) Purchasing IPO1 IPO2 Purchase Order 1 Subsystem = 1 Component IPO1 IPO2 Vendor Maintenance <<Component>> Purchasing Invoice Software Design 45
Typical Finance Component (with Information Hiding) Finance Budgeting 1 Subsystem = 1 Component IP1 <<Component>> Finance Payment IP1 Software Design 46
Typical Inventory Component (with Information Hiding) IX1 Inventory IIV1 Inventory Verification 1 Subsystem = 1 Component IIV1 IX1 <<Component>> Inventory IGR1 Goods Receive IGR1 Software Design 47
Sample of Hierarchy of Subsystems (with Information Hiding) IPO1 IPO2 Finance IIV1 IX1 Purchasing Inventory IP1 IGR1 Bank System Software Design 48
Define a Component Diagram IPO1 IPO2 IIV1 IX1 <<Component>> Inventory <<Component>> Purchasing IP1 IGR1 <<Component>> Finance Software Design 49
Deployment of Client-Server Client Application Server IPO1 IPO2 IIV1 IX1 <<Component>> Sale IP1 IGR1 <<Component>> Inventory <<Component>> Finance Software Design 50
Deployment of Web Application Client Application Server IPO1 IPO2 IIV1 IX1 <<Component>> Web Server <<Component>> Sale IP1 IGR1 <<Component>> Finance <<Component>> Inventory Software Design 51
Tracing from Use Cases to Design Finance Officer Check Available Budget Prepare Payment Check Credit Line Bank System Software Design 52
Tracing from Use Cases to Design Finance Check Available Budget <<Realize>> Budgeting Officer Prepare Payment <<Realize>> Check Credit Line <<Realize>> Payment Bank System IP1 Software Design 53
Reference [1] http://www.cs.cmu.edu/afs/cs/project/vit/ftp/p df/intro_softarch.pdf Software Design 54