Topic 8Summer 2003 1 ICS 52: Introduction to Software Engineering Lecture Notes for Summer Quarter, 2003 Michele Rousseau Topic 8 Partially based on lecture.

Slides:



Advertisements
Similar presentations
Lecture 6: Software Design (Part I)
Advertisements

Design Concepts and Principles
Software Engineering and Design Principles Chapter 1.
Component-Level Design
Introduction to Software Engineering Lecture 7 André van der Hoek.
Design The goal is to design a modular solution, using the techniques of: Decomposition Abstraction Encapsulation In Object Oriented Programming this is.
Architectural Design Principles. Outline  Architectural level of design The design of the system in terms of components and connectors and their arrangements.
Midterm ReviewSummer ICS 52: Introduction to Software Engineering Lecture Notes for Summer Quarter, 2003 Michele Rousseau Midterm Review Partially.
Chapter 1 Principles of Programming and Software Engineering.
Introduction to Software Engineering Lecture 8 André van der Hoek.
Chapter 1 Program Design
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Computer Science 240 Principles of Software Design.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
C++ fundamentals.
03 - ParnasCSC4071 A Sketchy Evolution of Software Design 1960s –Structured Programming (“Goto Considered Harmful”, E.W.Dijkstra) Emerged from considerations.
Data Structures and Programming.  John Edgar2.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 11 Slide 1 Architectural Design.
The Design Discipline.
Why Analysis Process Refer to earlier chapters Models what the system will do makes it easier for understanding no environment considered (hence, system.
Chapter 5CSA 217 Design in Construction Chapter 5 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Design Patterns OOD. Course topics Design Principles UML –Class Diagrams –Sequence Diagrams Design Patterns C#,.NET (all the course examples) Design Principles.
1/19 Component Design On-demand Learning Series Software Engineering of Web Application - Principles of Good Component Design Hunan University, Software.
Simple Program Design Third Edition A Step-by-Step Approach
1 On the Criteria To Be Used in Decomposing Systems into Modules by D.L.Parnas Dec presented by Yuanhua Qu for spring 2003 CS5391.
An Introduction to Software Architecture
Ceg860 (Prasad)L6MR1 Modularity Extendibility Reusability.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Computer Science 240 © Ken Rodham 2006 Principles of Software Design.
SOFTWARE DESIGN (SWD) Instructor: Dr. Hany H. Ammar
SE: CHAPTER 7 Writing The Program
Cohesion and Coupling CS 4311
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
Design Analysis builds a logical model that delivers the functionality. Design fully specifies how this functionality will be delivered. Design looks from.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
Design Concepts By Deepika Chaudhary.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
1 DATA FLOW DIAGRAM. 2 Outline Process decomposition diagrams Data flow diagram (DFD)
SOFTWARE DESIGN. INTRODUCTION There are 3 distinct types of activities in design 1.External design 2.Architectural design 3.Detailed design Architectural.
Introduction to Design (and Zen) CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Software Design Process
Learners Support Publications Object Oriented Programming.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Software Design Lecture What’s Design It’s a representation of something that is to be built. i.e. design  implementation.
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
“Architecture” The outcome of top-level design, reflecting principal design decisions Can (and should) be modified and updated Analogous to architecture.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
Systems Design.  Application Design  User Interface Design  Database Design.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Design CS 470 – Software Engineering I Sheldon X. Liang, PH.D.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
SOFTWARE DESIGN & SOFTWARE ENGINEERING Software design is a process in which data, program structure, interface and their details are represented by well.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Introduction toData structures and Algorithms
7. Modular and structured design
SOFTWARE DESIGN AND ARCHITECTURE
On the Criteria to Be Used in Decomposing Systems into Modules
On the Criteria To Be Used in Decomposing Systems into Modules D. L
Software Design Lecture : 9.
An Introduction to Software Architecture
Introduction to Data Structures
Software Design Principles
Presentation transcript:

Topic 8Summer ICS 52: Introduction to Software Engineering Lecture Notes for Summer Quarter, 2003 Michele Rousseau Topic 8 Partially based on lecture notes written by Sommerville, Frost, & Easterbrook. Duplication of course material for any commercial purpose without the written permission of the lecturers is prohibited

Topic 8Summer Design Interaction Architectural design (previous lecture) Module design (this lecture)

Topic 8Summer From Architecture to Modules l Repeat the design process Design the internal architecture of a component Define the purpose of each module Define the provided interface of each module Define the required interface of each module l Do this over and over again Until each module has… »…a simple, well-defined internal architecture »…a simple, well-defined purpose »…a simple, well-defined provided interface »…a simple, well-defined required interface l Until all modules “hook up”

Topic 8Summer Module - Definitions l a software fragment of any size (including “subsystem”) l a collection of routines, data, objects l a provider of computational resources or services l Examples: Abstract data type -- data structures with accessing and modifying functions Class (similar to an ADT) Package

Topic 8Summer Abstract Data Type - a kind of module l Goal: Encapsulate the concrete representation of a data structure with functions that access the representation l Users see only the abstract characteristics of the structure l Access to the structure is only through the provided access functions Abstract does not mean “vague” Abstract does not mean highly mathematical Abstract means conceived apart from a particular implementation

Topic 8Summer Stack ADT l Class Stack boolean empty() Object peek() Object pop() Object push(Object obj)

Topic 8Summer Possible Implementations l Array that is enlarged and copied as necessary l Linked list l Linked list of arrays l Sorted tree l Does it matter? l Can change with no impact to users of Stack ADT

Topic 8Summer Module - Alternative Formulation l Something that hides a “secret,” such as Algorithm (e.g. sorting) File format Sequence of processing Character code (e.g. ASCII v. Unicode) External interface (hardware and software) Relation between modules l What is a secret? Any design decision. l Who doesn’t know the secret? All other modules.

Topic 8Summer Determining a Module's Interface l Interface: the set of services a module provides its clients. l Interface design principles Design interface to be insensitive to change Generalize Interfaces abstract implementation details »With respect to what is provided »With respect to what is required l Given the interface, any consistent implementation is OK

Topic 8Summer Module Interfaces l Module exports or provides methods or information for use by other modules these other modules are its “clients” l Module imports or requires: external functionality this module is going to utilize

Topic 8Summer Module to Module Interaction l A module hides implementation details (e.g. data structures) so that the rest of the system is insulated and protected from the details l Modules communicate only through well- defined interfaces (e.g. method calls) l Programming languages typically provide lots of ways to violate this! global variables public member variables pointers shared memory

Topic 8Summer Module Design 101 l Design process: Identify items likely to change Confine these to modules Design module interfaces to be insensitive to change l If internal details change, client units should need no changes themselves l “Information Hiding” Hide information, procedures, and decisions likely to change.

Topic 8Summer Recursive Application of Information Hiding l For each module: List the difficult decisions and decisions likely to change Design a (sub-) module specification to hide each such decision Recursively apply process to all new module specifications until all design decisions hidden

Topic 8Summer Module Design 102 l Select entities from the world model Nouns : modules / classes Verbs: methods Adjectives: properties / attributes / member variables Expletives: exceptions Apply recursively Use objects, entities, and components from the application definition as modules.

Topic 8Summer Module Design 103 l Design for Reuse Rationale: cost, competitiveness, reliability Focus on developing modules for which you can imagine many different uses Risk: too complex, too generic, too hard to learn and use Design reusable modules.

Topic 8Summer Module Design 104 l Program Families Different function sets for different markets »By country, company size, hardware or software platform, price point Bug fixes Feature sets Flexibility is key Design modules to support program families.

Topic 8Summer The USES relation - definition l M1 USES M2 if and only if correct execution of M2 is necessary for M1 to complete the task described in its specification. l M1 is called a client of M2. l The USES relation is not based on flow of control during execution. l It is static. (see p. 275)

Topic 8Summer Example Level 0 Level 1 Level 2 Provided Interface Big Component Required Interface Provided Interface A Component Required Interface Provided Interface Tiny Component Required Interface Provided Interface Yet Component Required Interface

Topic 8Summer The USES Hierarchy l Definition Level 0 : modules not used by other modules Level i ( i > 0): modules used by at least one module on level i -1 and by no modules at level i or greater. l The USES relation is not necessarily a hierarchy l A hierarchy (acyclic) is good Cycles generally are bad »Indication of high coupling »Indication of broken separation of concerns l What do you do with cycles in the USES graph? Group a and b as a single entity in the USES relation. Split a and b apart.

Topic 8Summer Uses – Rules of thumb l Allow a to use b.. …if it makes a simpler …if b is not only used by a but also by other components

Topic 8Summer Observations l Some invocations are not USES Consider a transfer of control l Some USES do not involve invocations Consider interrupt handlers Consider global variables

Topic 8Summer Fan-in and Fan-out High fan-in Low fan-out Low fan-in High fan-out USUALLY GOOD! USUALLY BAD! Provided Interface Component Required Interface Provided Interface Component Required Interface

Topic 8Summer IS-COMPONENT-OF Relation l Definition Module M2 IS-COMPONENT-OF module M1 if M1 is realized by aggregating several modules, one of which is M2 The combined set of all modules that exhibit the IS-COMPONENT-OF relation with respect to module M1 are said to implement module M1 l Use Determine hierarchical decomposition of a component in its subcomponents Abstract details

Topic 8Summer Example Compressor IS-COMPONENT-OF Audio Encoder Encoder IS-COMPONENT-OF Audio Encoder Reader IS-COMPONENT-OF Audio Encoder Compressor, Encoder, and Reader IMPLEMENT Audio Encoder Audio Encoder IS-COMPOSED-OF Compressor, Encoder, and Reader Provided Interface Audio Encoder Required Interface Compressor Provided Interface EncoderReader Required Interface

Topic 8Summer Comprises Diagram Provided Interface Yet Component Required Interface Provided Interface Tiny Component Required Interface Provided Interface B Component Required Interface Provided Interface Mr. Component Required Interface Provided Interface Required Interface Provided Interface Big Component Required Interface Provided Interface A Component Required Interface Provided Interface Required Interface Bla Component Duh Component Doh Component

Topic 8Summer USES Diagram – Step 1 Provided Interface Yet Component Required InterfaceProvided Interface Tiny Component Required Interface Provided Interface B Component Required Interface Provided Interface Mr. Component Required Interface Provided Interface Required Interface Provided Interface Big Component Required Interface Provided Interface A Component Required Interface Provided Interface Duh Component Doh Component

Topic 8Summer USES Diagram – Step 2 Provided Interface Yet Component Required Interface Provided Interface Tiny Component Required Interface Provided Interface B Component Required Interface Provided Interface Mr. Component Required Interface Provided Interface Big Component Required Interface Provided Interface A Component Required Interface

Topic 8Summer USES Diagram – Step 3 Provided Interface Yet Component Required Interface Provided Interface Tiny Component Required Interface Provided Interface B Component Required Interface Provided Interface Mr. Component Required Interface Provided Interface Big Component Required Interface Provided Interface A Component Required Interface

Topic 8Summer USES Diagram – Step 4 Provided Interface Yet Component Required Interface Provided Interface Tiny Component Required Interface Provided Interface B Component Required Interface Provided Interface Mr. Component Required Interface Provided Interface Big Component Required Interface Provided Interface A Component Required Interface

Topic 8Summer Observations l Why do we identify higher-level modules in the first place? Understanding Abstraction through composition l IS-COMPONENT-OF is not is-attribute-of is-inside-of-on-the-screen is-subclass-of is-accessed-through-the-menu-of

Topic 8Summer The Design Process (reviewed) l Repeat the design process Design the internal architecture of a component Define the purpose of each module Define the provided interface of each module Define the required interface of each module l Do this over and over again Until each module has… »…a simple, well-defined internal architecture »…a simple, well-defined purpose »…a simple, well-defined provided interface »…a simple, well-defined required interface l Until all modules “hook up”

Topic 8Summer Techniques to Use l Tools of the trade Apply information hiding Use requirements specification Anticipate change Design for generality/incrementality (reuse) Design for program families Determine usage patterns l Strive for Low coupling/high cohesion A clean IS-COMPOSED-OF structure A clean USES structure High fan-in, low fan-out

Topic 8Summer Design by Stepwise Refinement l The typical alternative to design by information hiding. l A top-down technique l Preliminary design specification --> more elementary levels Divide and conquer: start with system function Break into major sub-functions Concurrently refine algorithms, data structures, flow of control Repeat until design is sufficiently detailed to give to programmers

Topic 8Summer Problems with Stepwise Refinement l What is the basis for choosing the initial decision to make? l Once a representation decision is made, all successive design decisions in that sub-tree of refinements may be dependent on it. l Promotes development of a sequential design solution (as opposed to concurrent) l If the initial function is “huge” how do you start to decompose it? l No help in designing reusable software l Not supportive of program families

Topic 8Summer KWIC Index Example l Input: a file of titles “Voyage of the Dawn Treader”PR6023.E926 V “The Silver Chair”PR6023.E926 S “Mere Christianity”BR123.L l Output: an alphabetized, permuted index Chair, The Silver PR6023.E926 S Christianity, MereBR123.L Dawn Treader, Voyage of the PR6023.E926 V Mere ChristianityBR123.L Silver Chair, The PR6023.E926 S The Silver Chair PR6023.E926 S Treader, Voyage of the Dawn PR6023.E926 V Voyage of the Dawn Treader PR6023.E926 V6 1952

Topic 8Summer Scheme 1: Stepwise Refinement Level 1:Print KWIC List Level 2:a. Input all titles b. Generate and save all interesting circular shifts c. Alphabetize shifts d. Print out Level 3-b:For each line in input file begin generate and save all interesting circular shifts for this line end

Topic 8Summer KWIC Design Input Titles Make Circular Shifts Alphabetize Print KWIC List

Topic 8Summer Data Structures l Array of titles l Array of call numbers l Array of circular shifts a pointer to a title (an array index) a pointer to a character in the title (shift index) avoids repeating title text for each shift This is one approach -- others are certainly possible.

Topic 8Summer Design, with Data Structures Input Titles Make Circular Shifts Alphabetize Print KWIC List Stored titles Index of circular shifts Index of alphabetized circular shifts Arrows go from processing steps to data structures, and from data structures to processing steps.

Topic 8Summer Master Control Procedure Input Titles Make Circular Shifts Alphabetize Print KWIC List Stored titles Index of circular shifts Index of alphabetized circular shifts main() calls

Topic 8Summer Design Decisions Made in Scheme 1 l All shifts will be stored l All circular shifts will be generated before alphabetization begins l Alphabetical orderings will be completed before printing begins l All shifts of one line developed before any shifts of another line l “Uninteresting” shifts eliminated at the time the shifts are generated

Topic 8Summer Design Decisions, Revisited (1) l All shifts will be stored As opposed to computed on demand Assumes you have enough memory to store everything l Circular shifts will be generated before alphabetization Precluding use of an insertion sort running concurrently or as a co-routine with the shift generator l Alphabetical orderings will be completed before printing Precluding concurrency and demanding additional storage e.g. once the first half were printed, their storage could be reused

Topic 8Summer Design Decisions, Revisited (2) l All shifts of one line developed before any shifts of another line Perhaps it would be faster to do all the first shifts first, then alphabetization of them, then second shifts... l “Uninteresting” shifts eliminated at the time the shifts are generated Details of this policy are buried within the shift generator

Topic 8Summer Scheme 2: Information Hiding l Design Decisions to Hide: Internal representation of data to be processed Representation of circular shifts Time at which circular shifts are computed Method of alphabetization (sorting) Time at which alphabetization is carried out Input formats Output formats

Topic 8Summer Modules and “Invokes” TitleCollection. getData( ) ShiftCollection’s enumeration System.out.println KWIC2.main( ) ShiftCollection. record( ) Uninteresting TokenSet. isUninteresting( ) Uninteresting TokenSet. add( ) TitleCollection.getTitle( ).getCallno( ) means “invokes” or “calls”

Topic 8Summer What’s Hidden? l TitleCollection hides how titles are stored, when shifts are created. Interface: String getTitle(int i) // returns title number i String getCallno(int i) // returns callno of title number i l ShiftCollection hides internal data representations (used Enumeration) when sorting is performed sort algorithm

Topic 8Summer UninterestingTokenSet l Why does it hold the delimiters?

Topic 8Summer Differences between schemes l How modules divide work to be done l Module interfaces l Maintainability What’s involved in using a Vector for TitleCollection.title? How about a linked list ? l Independent Development l Comprehensibility l Separation of Concerns l Amount of source code

Topic 8Summer Design Criteria l Scheme 1: each major step in processing is a module l Scheme 2: information hiding; modules need not correspond to processing steps e.g. alphabetization may or may not correspond to a processing phase Every module in Scheme 2 hides a design decision from the others »Start decomposition with a list of design decisions! Scheme 2 interfaces reveal as little as necessary about internal module workings Scheme 1 has important design decisions visible in interfaces

Topic 8Summer Comments on Design l Scheme 2’s implementation is similar to Scheme 1’s same arrays same sort routine same CircularShift utility class similar shiftedTitle method

Topic 8Summer KWIC2’s COMPRISES Diagram KWIC2 Book Information Token Information Sorting Algorithm Titles Call Numbers Shift Information Words to skip Delimiters Shift Shift Collection Title Information Output List Note: ovals for composite modules, rectangles for elementary (leaf) modules.

Topic 8Summer KWIC2’s USES Diagram Sorting Algorithm Titles Call Numbers Words to skip Delimiters Shift Shift Collection Output List 0