Software Design Fundamentals. CSCE Lecture 11-09/27/2016

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

Unit-3 Software Design (Lecture Notes)

Software Metrics and Design Principles. What is Design?

Software Design. Levels in Design Process. Design Methodologies. Levels..

CHAPTER 9 DESIGN ENGINEERING. Overview

Lecturer: Sebastian Coope Ashton Building, Room G.18

UNIT II Requirements Analysis and Specification & Software Design

CS 292 Software Development

Software Design. Software design is a blueprint or a plan for a computerbased solution for system

CHAPTER 5 GENERAL OOP CONCEPTS

Modularity Guidelines for design in any programming language

Programming II (CS300)

Modularity!! Guidelines for design! in any programming language!

Object Oriented Programming

Design. Introduction

The Software Design Process. CSCE 315 Programming Studio, Fall 2017 Tanzir Ahmed

Object Relationships

THE OBJECT-ORIENTED DESIGN PROCESS AND DESIGN AXIOMS (CH -9)

Architectural Design

The modularity requirement

Data Structures (INE2011)

What are the characteristics of Object Oriented programming language?

Program Abstractions, Language Paradigms. CS152. Chris Pollett. Aug. 27, 2008.

Architectural Design

An Overview of the BLITZ System

Patterns and Testing

LECTURE 3: SOFTWARE DESIGN. Software Engineering Mike Wooldridge

Creating a Lattix Dependency Model The Process

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

Design: HOW to implement a system

Architectural Design

The Analysis and Design of the Object-oriented System Li Xin 1, a

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING CS SOFTWARE ENGINEERING

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

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

Darshan Institute of Engineering & Technology for Diploma Studies

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

Chapter 1: Principles of Programming and Software Engineering

Setting the stage... Key Design Issues. Main purpose - Manage software system complexity by improving software quality factors

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

SE Assignment III. 1. List and explain primitive symbols used for constructing DFDs. Illustrate the use of these symbols with the help of an example.

From Module To Objects

Where are we going? EEC 421/521: Software Engineering. What is Design? A Note on Quality. Introduction to Design. Many levels of design: Our focus

System Design. Design: HOW to implement a system

Software Engineering Principles

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

Chapter 8: Class and Method Design

CSCI 253. Outline. Background. George Blankenship 1

Software design descriptions standard

VETRI VINAYAHA COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Topic : Object Oriented Design Principles

Coding and Unit Testing! The Coding Phase! Coding vs. Code! Coding! Overall Coding Language Trends!

Computer Science and Software Engineering University of Wisconsin - Platteville 9-Software Testing, Verification and Validation

Introduction to System Design

Assertions. Assertions - Example

Compiler Design 1. Introduction to Programming Language Design and to Compilation

WHAT IS SOFTWARE ARCHITECTURE?

Chapter 9. Software Testing

In addition to name. Each variable in C program is characterized by its Type Scope Storage Class. Type Have already discussed

Software Design Heuristics

Object-oriented development. Object-oriented Design. Objectives. Characteristics of OOD. Interacting objects. Topics covered

Establishing the overall structure of a software system

MSO Object Creation Singleton & Object Pool

Ghassan Samara Internet Technology Department Zarqa University, Jordan.

Design Patterns Design patterns advantages:

Introduction to Computer Security

Software Testing. Testing: Our Experiences

Model-Based Design for Large High Integrity Systems: A Discussion Regarding Model Architecture

Object interconnections גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Tutorial 1 Answers. Question 1

CSCI 445 Amin Atrash. Control Architectures. Introduction to Robotics L. Itti, M. J. Mataric

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

CS 370 Design Heuristics D R. M I C H A E L J. R E A L E F A L L

Chapter 1. Introduction

Software Architecture

CAS 703 Software Design

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

Object-Oriented and Classical Software Engineering DESIGN 11/12/2017. CET/CSC490 Software Engineering Design CHAPTER 14. Stephen R. Schach.

Checklist for Requirements Specification Reviews

1DL321: Kompilatorteknik I (Compiler Design 1)

Object-Oriented and Classical Software Engineering THE TOOLS OF THE TRADE 9/22/2017. CHAPTER 5 Slide 5.2. Stephen R. Schach. Overview Slide 5.

Welcome to Design Patterns! For syllabus, course specifics, assignments, etc., please see Canvas

Grade Weights. Language Design and Overview of COOL. CS143 Lecture 2. Programming Language Economics 101. Lecture Outline

ICS 52: Introduction to Software Engineering

Introduction to Data Structures & Algorithm

Part 5. Verification and Validation

Integration Testing Qualidade de Software 2

Recap : UML artefacts. Black Box Requirements. Functional Specification. System. System. Test. Design. System. System. Development.

CS112 Lecture: Defining Instantiable Classes

Introduction to Programming Languages and Compilers. CS164 11:00-12:30 TT 10 Evans. UPRM ICOM 4029 (Adapted from: Prof. Necula UCB CS 164)

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

Object-Oriented Design

Chapter 2 Basic Elements of C++

Design Concepts. Slide Set to accompany. Software Engineering: A Practitioner s Approach, 7/e by Roger S. Pressman

COURSE 2 DESIGN PATTERNS

Architecture CSE 403. Fallingwater by Frank Lloyd Wright

Where are we going? EEC 521: Software Engineering. A Note on Quality. What is Design? Introduction to Design. Our focus

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Object-Oriented Analysis and Design Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology-Kharagpur

Transcription:

Software Design Fundamentals CSCE 740 - Lecture 11-09/27/2016

Today s Goals Define design Introduce the design process Overview of design criteria What results in a good design? Gregory Gay CSCE 740 - Fall 2016 2

What is Design? Design is the creative process of transforming a problem into a solution. In our case, transforming a requirements specification into a detailed description of the software to be implemented. Specification - what we re going to build. Design - how to build it. A description of the structure of the solution. Gregory Gay CSCE 740 - Fall 2016 3

What is Design? Design is the process of going from this: Software Gregory Gay CSCE 740 - Fall 2016 4

What is Design? to this:............... Gregory Gay CSCE 740 - Fall 2016 5

What is Design? Design is the process of defining the structure of the software. What units make up the codebase? How do those units connect to perform the required functions? Gregory Gay CSCE 740 - Fall 2016 6

General Design Stages Discussions with Customers Identify nature of requirements High-Level Requirements Analyze problem and derive solution System Specification Postulate a design solution Potential Design Seek a new design Implement solution 1 Validate design against specification 3 Final Design Blueprints 2 Potential Design Refine design Gregory Gay CSCE 740 - Fall 2016 7

Stages of Design Three repeating stages: Problem Understanding Look at the problem from different angles to discover what needs the design needs to capture. Identify Solutions Evaluate possible solutions and choose the most appropriate in terms of available resources. Describe and Document Chosen Solution Use graphical, formal, or other descriptive notations to describe the components of the design. Gregory Gay CSCE 740 - Fall 2016 8

Stages of Design Design is performed at multiple levels of granularity: Architecture Unit How is the system structured into subsystems? How do those subsystems work together? What units make up these subsystems? How do these units work together? Low-Level What algorithms will be employed? What data structures will be used? Gregory Gay CSCE 740 - Fall 2016 9

Design Activities Requirements Specification Architectural Design Interface Design Component Design Data Design Algorithm Design System architecture (high-level breakdown of system) How subsystems interact with each other and how external users and systems interact with your system A listing of the individual classes within your system The format of data that is produced and consumed by your system Algorithms used to implement system functionality. Gregory Gay CSCE 740 - Fall 2016 10

The Design Process Design takes place in overlapping stages. It is artificial to separate them into distinct phases. Some separation occurs, but these phases take place largely at the same time. In practice - design is an exercise in starting from an abstraction and filling in the missing details. However, don t forget about the big picture. Keep looking at all levels of abstraction to make sure you re designing the right solution. Gregory Gay CSCE 740 - Fall 2016 11

Basic Design Strategies

Design Strategies UnitA UnitB... UnitD......... UnitN Systems are typically designed as a hierarchy. UnitN provides a service used by UnitD. UnitD provides a service used by UnitB. UnitB provides a service used by UnitA. Design strategies dictate how these units and their connections are laid out. Gregory Gay CSCE 740 - Fall 2016 13

Centralized Design System is designed from a functional viewpoint: call and return model. Typical in C and non-oo languages. Execution is controlled from a central point in the system. A method is called, the result is passed back to the controlling location, then that is passed into the next method. System is designed as a set of independent services that communicate only with a central master component. Gregory Gay CSCE 740 - Fall 2016 14

Centralized Design The system state is centralized and shared between the functions operating on that state. All data is stored by the master component. Each called component receives all data it needs from the master. Gregory Gay CSCE 740 - Fall 2016 15

Centralized View of a Compiler Source Program Main Error Indicator Output Errors Error Messages Scan Source Tokens Build Symbol Table Tokens, Symbols Syntax Tree Analysis Generate Binary Object Code tokens = scansource(program); symbols=buildsymboltable(tokens); try{ tree=analysis(tokens,symbols); generatebinary(tree); catch(errors){ print errors } Gregory Gay CSCE 740 - Fall 2016 16

Decentralized Design Basis of object-oriented design System is designed as a collection of interacting components. System state is decentralized and each component manages its own data. Multiple instances of an component may exist and communicate. How most modern systems are designed. Easier to isolate errors in one component. Gregory Gay CSCE 740 - Fall 2016 17

Decentralized View of a Compiler Source Program Scan Token Stream Add Symbol Table Check Grammar Get Build Syntax Tree Print Error Messages Generate Abstract Code Generate Object Code Gregory Gay CSCE 740 - Fall 2016 18

Design Strategies UnitA UnitB... UnitD......... UnitN Systems are typically designed as a hierarchy. Higher-level units make use of many lower-level units. Lower-level units tend to stand alone. Small, self-contained, rarely call other components. Gregory Gay CSCE 740 - Fall 2016 19

Top-Down Design In principle, top-down design involves starting at the uppermost components, design those, and work down the hierarchy level-by-level. Choose a major system function. Decide how to break it into components. Decide how to break those components into smaller subcomponents. Gregory Gay CSCE 740 - Fall 2016 20

Top-Down Design In practice, large system design is never truly top-down. Some branches are designed before others. Designers reuse experience (and sometimes components) during the design process. Sometimes, the lower levels need to be designed for the top-level to be completed. Gregory Gay CSCE 740 - Fall 2016 21

Bottom-Up Design In principle,bottom-up design involves starting with standalone components, then assembling them into a complete system. In practice, large system design is never truly bottom-up. An efficient system cannot be designed without planning for integration. The complete picture must be kept in mind. Gregory Gay CSCE 740 - Fall 2016 22

Key Points Design is the process of deciding what components make up the software, and how they connect. The structure of the software. Design activities include architectural design, interface design, component design, data design, and algorithm design. But this is a messy process where phases overlap and activities cycle. Gregory Gay CSCE 740 - Fall 2016 23

What are the criteria for a good design?

Design Quality No simple answer. Design quality is an elusive concept. Depends on organizational priorities, and involves balancing competing objectives. A good design may be the most efficient, the cheapest, the most maintainable, the most reliable, etc Gregory Gay CSCE 740 - Fall 2016 25

Design Quality A good design results in efficient software. Even more important... Software will change over time. During implementation, after release. A good design allows changes to be made. While also protecting what works from any side effects of those changes. Gregory Gay CSCE 740 - Fall 2016 26

Design Attributes Simplicity Modularity Low Coupling High Cohesion Information Hiding Data Encapsulation Other abilities Adaptability Traceability etc... Gregory Gay CSCE 740 - Fall 2016 27

Expensive to Maximize Attributes Costs rise exponentially if very high levels of an attribute are required. Cost Efficiency (Clarity) (Maintainability) (etc.) Gregory Gay CSCE 740 - Fall 2016 28

Modularity A complex system must be broken down into smaller modules. Three goals of modularity: Decomposability Break the system down into understandable modules. Composability Construct a system from smaller pieces. Ease of Understanding The system will change, we must understand it. Gregory Gay CSCE 740 - Fall 2016 29

Modularity Properties Cohesion = The degree to which modules are compatible. Coupling = The degree of interdependence between modules. We want high cohesion and low coupling. Gregory Gay CSCE 740 - Fall 2016 30

Cohesion The degree to which modules are compatible. A measure of how well a component fits together. A component should implement a single logical entity or feature of the software. A high level of cohesion is a desirable design attribute because changes are localized to a single, cohesive component. Gregory Gay CSCE 740 - Fall 2015 31

Types of Cohesion Logical Cohesion (weak) Components that perform similar functions are grouped. Temporal Cohesion (weak) Components that are activated at the same time are grouped. Procedural Cohesion (weak) The elements in a component make up a single control sequence. Sequential Cohesion (medium) The output for one part of a component is the input to another part. Gregory Gay CSCE 740 - Fall 2016 32

Levels of Cohesion Communicational Cohesion (medium) All of the elements of a component operate on the same input or produce the same output. Functional Cohesion (strong) Each part of a component is necessary for the execution of a single system feature. Object/Data Cohesion (strong) Each operation modifies or allows inspection of stored object attributes. The class stores data and all operations performed on that data. Gregory Gay CSCE 740 - Fall 2016 33

Cohesion as a Design Attribute Not well-defined. Despite guidelines, cohesion is subjective and can t be easily measured. Often very difficult to figure out what is related. Some code is used by multiple classes. Inheriting attributes from super-classes weakens cohesion. To understand a component, the super-classes as well as the component class must be examined. Gregory Gay CSCE 740 - Fall 2016 34

Coupling The degree of interdependence between modules. A measure of the strength of the interconnections between components. Is code from another class called often? How much data is passed during those calls? Loose coupling means component changes are unlikely to affect other components. Loose coupling can be achieved by storing local data in objects and communicating solely by passing data through component s parameters. Gregory Gay CSCE 740 - Fall 2016 35

Tight Coupling Component A Component B Shared Data Component C Component D Gregory Gay CSCE 740 - Fall 2016 36

Loose Coupling Component A A s Data Component C Component B C s Data B s Data Component D D s Data Gregory Gay CSCE 740 - Fall 2016 37

Food for Thought How does an OO language like Java or C++ support low coupling and high cohesion? How can we mess it up? How do global variables affect coupling? How about complex data structures? and pointers? What does inheritance do to coupling and cohesion? Gregory Gay CSCE 740 - Fall 2016 38

Coupling and Inheritance Object-oriented systems can be loosely coupled because there is no need for shared state and objects communicate using message passing. However, an object class is coupled to its super-classes. Changes made to the attributes or operations in a super-class propagate to all sub-classes. Such changes must be carefully controlled. Gregory Gay CSCE 740 - Fall 2016 39

Information Hiding Put the complexity inside of a black box Hide it from the components that use that box. The user does not need to know how the box works, just what it does. Greatly reduces the amount of information the designer needs to understand at once. Examples: Functions, Interfaces, Classes, Libraries If used properly, helps ensure loose coupling. Gregory Gay CSCE 740 - Fall 2016 40

Information Hiding Example int[] sortascending(int[] unsorted, int length); We do not know what sort routine is used. All we know is what the interface is and what the module accomplishes. Allows designers to focus on one part of the system at a time, without worrying about other components. Gregory Gay CSCE 740 - Fall 2016 41

Data Encapsulation Encapsulation is the principle of building a barrier around a collection of items. Encapsulate the data a module is working on. Protect the data from unauthorized access. Nobody else can mess with the data. If it gets corrupted, it must have been the fault of this component. Makes the design more robust. Gregory Gay CSCE 740 - Fall 2016 42

Encapsulation Example Version 1: class Adder{ }; int total; void addnum(int number){ total += number; } int main( ) { Adder a; } a.addnum(10); a.addnum(20); a.addnum(30); cout << "Total " << a.total <<endl; return 0; Version 2: class Adder{ private int total; void addnum(int number){ total += number; } int gettotal(){ return total; } }; int main( ) { Adder a; a.addnum(10); a.addnum(20); a.addnum(30); cout << "Total " << a.gettotal() <<endl; return 0; } Gregory Gay CSCE 740 - Fall 2016 43

Understandability The design should be understandable by the developers - unambiguous and easy to follow. Related to many component characteristics: Cohesion Can each component be understood on its own? Naming Are meaningful component (class, method, variable) names used? Documentation Is the design well-documented? Are decisions justified? Rationale noted? Complexity Are complex algorithms used? Gregory Gay CSCE 740 - Fall 2016 44

Understandability High complexity means many relationships between different entities in the design. Hence, the design is hard to understand. Most measurements of design quality measure the complexity. They tell you to avoid high complexity (high number of relations between components). These metrics tend to be of little use - the number is irrelevant - instead, be careful to only include necessary relations. Gregory Gay CSCE 740 - Fall 2016 45

Adaptability A design is adaptable if: Its components are loosely coupled. It is well-documented and the documentation is kept up to date. There is an obvious correspondence between design levels (interface, components, data, etc). Each component is a self-contained entity (strong cohesion). To adapt a design, it must be possible to trace links between components so that change consequences can be analyzed. Gregory Gay CSCE 740 - Fall 2016 46

Adaptability and Inheritance Inheritance improves adaptability. Components may be expanded without change by deriving a sub-class and modifying that derived class. However, as the depth of the inheritance hierarchy increases, so does complexity. Complexity must be periodically reviewed and restructured. Gregory Gay CSCE 740 - Fall 2016 47

Design Traceability For a design to be adaptable and understandable, we must be able to link: Components to their data. Components to their related components. Data to related data. Components to their requirements. Components to their test cases. Gregory Gay CSCE 740 - Fall 2016 48

We Have Learned Design is the process of deciding what components make up the software, and how they connect. The structure of the software. A good design allows change while protecting unchanged components. Coupling and cohesion are central to good software design. Always keep these in mind. Gregory Gay CSCE 740 - Fall 2016 49

Next Time Basics of software architecture. Homework 2 due 10/02. Questions? Gregory Gay CSCE 740 - Fall 2015 50