Moonzoo Kim CS Division of EECS Dept. CS350 Intro. to SE Spring

Similar documents
Component-Level Design. Slides copyright 1996, 2001, 2005, 2009, 2014 by Roger S. Pressman. For non-profit educational use only

Component-Level Design

09. Component-Level Design

Component-Level Design. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman. For non-profit educational use only

SE300 SWE Practices. Lecture 10B Component Design (Abstraction, Interface/Implementation, Cohesion, Coupling, Refactoring) Tuesday, March 17, 2015

CS485/540 Software Engineering Architecture and Component Design (Chs. 9,10)

!"#$%&'()*+,-*,--)./00#'1)2)345"645"%()

Chapter 14 Testing Tactics

Component-Level Design. Slides copyright 1996, 2001, 2005, 2009 by Roger S. Pressman (revised by Seung- Hoon Na) For non-profit educational use only

Chapter 9 Design Engineering

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

Design Concepts and Principles

Moonzoo Kim CS Division of EECS Dept.

Faculty of Information Technology Department of SE Marking Scheme

UNIT III DESIGN CONCEPTS AND PRINCIPLES

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

Requirements Modeling (Ch. 6)

Introduction to Software Engineering

Introduction to Software Engineering

Introduction to UML What is UML? Motivations for UML Types of UML diagrams UML syntax Descriptions of the various diagram types Rational Rose (IBM.. M

Post Experiment Interview Questions

Slides copyright 1996, 2001, 2005, 2009, 2014 by Roger S. Pressman. For non-profit educational use only

Helping the Compiler Help You. Thomas Dy

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

CHAPTER 9 DESIGN ENGINEERING. Overview

Lecture 8: Chapter 8!

Chapter 5 Practice: A Generic View

Software Engineering

CS485/540 Software Engineering Requirements Modeling (Ch. 6)

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

CSEB233: Fundamentals of Software Engineering. Software Design

copyright 1996, 2001, 2005 R.S. Pressman & Associates, Inc.

Object- Oriented Design with UML and Java Part I: Fundamentals

Object-Oriented Design

UNIT-II Introduction to UML

Programming II (CS300)

MITOCW MIT6_01SC_rec2_300k.mp4

Principles of Object-Oriented Design

CHAPTER 5: PRINCIPLES OF DETAILED DESIGN

Ingegneria del Software Corso di Laurea in Informatica per il Management. Software quality and Object Oriented Principles

08. DESIGN PRINCIPLES. Originality is Overrated PRINCIPLES OF SOFTWARE BIM209DESIGN AND DEVELOPMENT

5 R1 The one green in the same place so either of these could be green.

In today s video I'm going show you how you can set up your own online business using marketing and affiliate marketing.

Metamodeling. Janos Sztipanovits ISIS, Vanderbilt University

SOLID Principles. Equuleus Technologies. Optional Subheading October 19, 2016

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

CSC207H: Software Design SOLID. CSC207 Winter 2018

MITOCW watch?v=kvtlwgctwn4

MITOCW watch?v=flgjisf3l78

Object-Oriented Design

CS 292 Software Development

02291: System Integration

What are the characteristics of Object Oriented programming language?

INTERNAL ASSESSMENT TEST III Answer Schema

06. Analysis Modeling

MITOCW watch?v=w_-sx4vr53m

2015 HSC Software Design and Development Marking Guidelines

Concept as a Generalization of Class and Principles of the Concept-Oriented Programming

Class-based Modeling. Analysis Classes. Building the Analysis Model 4

Unit-3 Software Design (Lecture Notes)

CS485/540 Software Engineering Design Concepts (Ch. 8)

CHAPTER 1. Topic: UML Overview. CHAPTER 1: Topic 1. Topic: UML Overview

6.001 Notes: Section 6.1

UNIT II. Syllabus. a. An Overview of the UML: Visualizing, Specifying, Constructing, Documenting

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

Object-Oriented Systems Analysis and Design Using UML

Accessibility. EEC 521: Software Engineering. Classes and Objects. Inheritance. Classes and Objects (OO Analysis)

Method & Tools for Program Analysis & Design

17.11 Bean Rules persistent

MITOCW watch?v=ytpjdnlu9ug

Software Engineering with Objects and Components Open Issues and Course Summary

CS 160: Evaluation. Professor John Canny Spring /15/2006 1

CS 160: Evaluation. Outline. Outline. Iterative Design. Preparing for a User Test. User Test

For 100% Result Oriented IGNOU Coaching and Project Training Call CPD TM : ,

Object-Oriented Design

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Intro to: Design Principles

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

OO Package Design Principles

Design of Embedded Systems

MITOCW watch?v=4dj1oguwtem

Single Responsibility Principle (SRP)

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

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

Chapter : Analysis Modeling

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

Agile Software Development

9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?

Chapter01.fm Page 1 Monday, August 23, :52 PM. Part I of Change. The Mechanics. of Change

Software Development

Blog post on updates yesterday and today:

Fundamental Concepts (Principles) of Object Oriented Programming These slides are based on:

UNIT II Requirements Analysis and Specification & Software Design

MITOCW watch?v=0jljzrnhwoi

Outline Key Management CS 239 Computer Security February 9, 2004

MITOCW watch?v=kz7jjltq9r4

Zombies! In Google SketchUp

Outline. Program development cycle. Algorithms development and representation. Examples.

mismatch between what is maybe possible today and what is going on in many of today's IDEs.

Design and Information Hiding

Transcription:

Chapter 11 Component-Level Design Moonzoo Kim CS Division of EECS Dept. KAIST moonzoo@cs.kaist.ac.kr http://pswlab.kaist.ac.kr/courses/cs350-07 Spring 2008 1

Overview of Ch 11. Modeling Component-level l Design 11.1 What is a component An object-oriented oriented view 11.2 Designing class-based components Basic design principles p Component-level design guidelines Cohesion Coupling 11.3 Conducting component-level design 11.4 Object constraint language (OCL) 11.5 Designing conventional components Graphical design notation Tabular design notation Program design language Spring 2008 2

What is a Component? OMG Unified Modeling Language g Specification [OMG01] defines a component as a modular, deployable, and replaceable part of a system that encapsulates implementation and exposes a set of interfaces. OO view: a component contains a set of collaborating classes Conventional view: logic, the internal data structures that are required to implement the processing logic, and an interface that enables the component to be invoked and data to be passed to it. Spring 2008 3

OO Component Analysis class Print Job numberofpages numberofsides papertype magnification productionfeatures computejob Design component computejobcost() passjobtoprinter() Print Job initiatejob Elaborated ated design class <<int<i erf ace>> > computejob comput epagecost ( ) computepapercost ( ) computeprodcost ( ) computetot aljobcost ( ) < < in t er f ace> > in it iat ejo b buildwor kor der ( ) checkpriority ( ) passjobt o Pr oduct ion( ) PrintJ ob numberof Pages numberof Sides paper Type paper Weight paper Size paper Color magnif icat ion colorrequirement s productionfeat ures collat ionopt ions bindingopt ions coverst ock bleed pr ior it y totaljobcost WOnumber comput epagecost ( ) comput epaper Cost ( ) comput epr odcost ( ) comput etot aljobcost ( ) buildwor kor der ( ) checkpriority ( ) passjobt o Pr oduct ion( ) Spring 2008 4

Basic Design Principles The Open-Closed Principle (OCP). A module [component] should be open for extension but closed for modification. The Liskov Substitution Principle (LSP). Subclasses should be substitutable for their base classes. Dependency Inversion Principle (DIP). Depend on abstractions. Do not depend on concretions. The Interface Segregation Principle (ISP). Many client-specific interfaces are better than one general purpose interface. The Release Reuse Equivalency Principle (REP). The granule of reuse is the granule of release. The Common Closure Principle (CCP). Classes that change together belong together. The Common Reuse Principle (CRP). Classes that aren t reused together should not be grouped together. Spring 2008 5

Source: Martin, R., Design Principles and Design Patterns, downloaded from http://www.objectmentor.com, 2000. Spring 2008 6

The scene: Vinod's cubicle. The players: The OCP in Action (pg332) Vinod, Shakira members of the SafeHome software engineering team. The conversation: Vinod: I just got a call from Doug [the team manager]. He says marketing wants to add a new sensor. Shakira (smirking): Not again, jeez! Vinod: Yeah... and you're not going to believe what these guys have come up with. Shakira: Amaze me. Vinod (laughing): g) They call it a doggie angst sensor. Shakira: Say what? Vinod: It's for people who leave their pets home in apartments or condos or houses that are close to one another. The dog starts to bark. The neighbor gets angry and complains. With this sensor, if the dog barks for more than, say, a minute, the sensor sets a special alarm mode that calls the owner on his or her cell phone. Shakira: You're kidding me, right? Spring 2008 7

Vinod: Nope. Doug wants to know how much time it's going to take to add it to the security function. Shakira (thinking a moment): Not much... look. [She shows Vinod Figure 11.4] We've isolated the actual sensor classes behind the sensor interface. As long as we have specs for the doggie sensor, adding it should be a piece of cake. Only thing I'll have to do is create an appropriate component... uh, class, for it. No change to the Detector component at all. Vinod: So I'll tell Doug it's no big deal. Shakira: Knowing Doug, he'll keep us focused and not deliver the doggie thing until the next release. Vinod: That's not a bad thing, but can you implement now if he wants you to? Shakira: Yeah, the way we designed the interface lets me do it with no hassle. Spring 2008 8

Components Design Guidelines Naming conventions should be established for components that are specified as part of the architectural model and then refined and elaborated as part of the component-level model Interfaces Interfaces provide important information about communication and collaboration (as well as helping us to achieve the OPC) Dependencies and Inheritance it is a good idea to model dependencies from left to right and inheritance from bottom (derived classes) to top (base classes). Spring 2008 9

OO view: Cohesion cohesion implies that a component or class encapsulates only attributes t and operations that t are closely related to one another and to the class or component itself Levels of cohesion Functional Layer Communicational Sequential Procedural Temporal utility Spring 2008 10

The scene: Jamie's cubicle. The players: Cohesion in Action (pg336-337) 337) Jamie, Ed members of the SafeHome software engineering team who are working on the surveillance function. The conversation: Ed: I have a first-cut design of the camera component. Jamie: Wanna do a quick review? Ed: I guess... but really, I'd like your input on something. (Jamie gestures for him to continue.) Ed: We originally defined five operations for camera. Look... [shows Jamie the list] determinetype() tells me the type of camera. translatelocation() allows me to move the camera around the floor plan. displayid() gets the camera ID and displays it near the camera icon. displayview() shows me the field of view of the camera graphically. displayzoom() shows me the magnification of the camera graphically. Ed: I've designed each separately, and they're pretty simple operations. So I thought Spring 2008 11

it might be a good idea to combine all of the display operations into just one that's called displaycamera()-- --it'll show the ID, the view, and the zoom. Whaddaya think? Jamie (grimacing): i Not sure that's such a good idea. Ed (frowning): Why? All of these little l ops can cause headaches. h Jamie: The problem with combining them is we lose cohesion. You know, the displaycamera() op won't be single-minded. Ed (mildly exasperated): So what? The whole thing will be less than 100 source lines, max. It'll be easier to implement, I think. Jamie: And what if marketing decides to change the way that we represent tth the view field? Ed: I'll just jump into the displaycamera() op and make the mod. Jamie: What about side effects? Ed: Whaddaya mean? Jamie: Well, say you make the change but inadvertently create a problem with the ID display. Spring 2008 12

Ed: I wouldn't be that sloppy. Jamie: Maybe not, but what if some support person two years from now has to make the mod. He might not understand the op as well as you do and, who knows, he might be sloppy. Ed: So you're against it? Jamie: You're the designer... it's your decision... just be sure you understand the consequences of low cohesion. Ed (thinking a moment): Maybe we'll go with separate display ops. Jamie: Good decision. Spring 2008 13

Coupling Conventional view: The degree to which a component is connected to other components and to the external world OO view: a qualitative measure of the degree to which classes are connected to one another Level of coupling Content Common Control Stamp Data Routine call Type use Inclusion or import External Spring 2008 14

Component Level Design-I Step 1. Identify all design classes that correspond to the problem domain. Step 2. Identify all design classes that correspond to the infrastructure domain. Step 3. Elaborate all design classes that are not acquired as reusable components. Step 3a. Specify message details when classes or component collaborate. Step 3b. Identify appropriate interfaces for each component. Step 3c. Elaborate attributes and define data types and data structures required to implement them. Step 3d. Describe processing flow (activity diagram) within each operation in detail. Spring 2008 15

Component-Level Design-II Step 4. Describe persistent data sources (databases and files) and identify the classes required to manage them. Step 5. Develop and elaborate behavioral representations (statechart) for a class or component. Step 6. Elaborate deployment diagrams to provide additional implementation detail. Step 7. Factor every component-level design representation and always consider alternatives. Spring 2008 16

Collaboration Diagram :ProductionJob 1: buildjob ( WOnumber ) [x>1] y:= f(wonumber) 2: submitjob ( WOnumber ) :WorkOrder :JobQueue Spring 2008 17

Processing Flow in Activity Diagram validate attributes input accesspaperdb(weight) returns basecostperpage papercostperpage = basecostperpage size = B papercostperpage = papercostperpage * 1.2 size = C papercostperpage = papercostperpage * 1.4 size = D papercostperpage = papercostperpage * 1.6 color is custom papercostperpage = papercostperpage * 1.1 4 color is standard returns ( papercostperpage ) Spring 2008 18

Behavioral Representation in Statechart datainputincomplete datainputcompleted [all data it ems consist ent ] / displayuseropt ions buildingjobdat a ent ry/ readjobdat a () exit / displayjobdat a () do/ checkconsist ency() include/ dat ainput behavior within the st at e b u ild in g Jo b Dat a comput ingjobcost ent ry/ comput ejob exit / save t ot aljobcost jobcostaccepted [customer is authorized]/ get Elect ronicsignat ure formingjob ent ry/ buildjob exit / save WOnumber do/ submit t ingjob entry/ submitjob exit / init iat ejob do/ place on JobQueue jobsubmitted[ all au t h o rizat io n s acq u ired ] / Spring 2008 printworkorder 19

Object Constraint Language g (OCL) complements UML by allowing a software engineer to use a formal grammar and syntax to construct unambiguous statements about various design model elements simplest OCL language g statements are constructed in four parts: (1) a context that defines the limited situation in which the statement is valid; (2) a property that represents some characteristics of the context (e.g., if the context is a class, a property might be an attribute) (3) an operation (e.g., arithmetic, ti set-oriented) t that t manipulates or qualifies a property, and (4) keywords (e.g., if, then, else, and, or, not, implies) that are used to specify conditional expressions. Spring 2008 20

OCL Example context PrintJob::validate(upperCostBound : Integer, custdeliveryreq : Integer) pre: uppercostbound > 0 and custdeliveryreq > 0 and self.jobauthorization = 'no' post: if self.totaljobcost <= uppercostbound and self.deliverydate <= custdeliveryreq then self.jobauthorization = 'yes' endif Spring 2008 21

the closest design activity to coding the approach: review the design description for the component use stepwise refinement to develop algorithm use structured programming to implement procedural logic use formal methods to prove logic Algorithm Design open walk to door; reach for knob; open door; walk through; close door. repeat until door opens turn knob clockwise; if knob doesn't turn, then take key out; find correct key; insert in lock; endif pull/push door move out of way; end repeat Spring 2008 22

Algorithm Design Model represents the algorithm at a level of detail that can be reviewed for quality options: graphical (e.g. flowchart, box diagram) pseudocode d (e.g., PDL)... choice of many programming language decision table conduct walkthrough to assess quality Spring 2008 23

Structured Programming for Procedural Design uses a limited set of logical constructs: sequence conditional if-then-else, else, select-case case loops do-while, hl repeat until leads to more readable, testable code can be used in conjunction with proof of correctness important for achieving high quality, but not enough Spring 2008 24

A Structured Procedural Design a add a condition Z, if true, exit the program b x3 x1 x2 d c f e x 4 g x5 Spring 2008 25

Decision Table Rule s Conditions 1 2 3 4 5 6 regular customer T T silver customer T T gold customer T T special discount F T F T F T Rules no discount apply 8 percent discount apply 15 percent discount apply additional x percent discount Spring 2008 26

Program Design Language (PDL) if-then-else if condition x then process a; else process b; endif PDL Easy to combine with source code Can be represented in great detail Machine readable, no need for graphics input Graphics can be generated from PDL Enables declaration of data as well as procedure Easier to review and maintain Spring 2008 27

Spring 2008 28