CTIS 359 Principles of Software Engineering SOFTWARE DESIGN OO(A)D

Similar documents
Object-Oriented Functional Analysis and Design for POS Example

Information Expert (or Expert)

Mapping Designs to Code

Goal: build an object-oriented model of the realworld system (or imaginary world) Slicing the soup: OOA vs. OOD

COMP 6471 Software Design Methodologies

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

OO Design2. Design Artifacts

Operations Contracts and Preliminaries on Design

Domain Model and Domain Modeling

Domain Modeling. CSSE 574: Week 1, Part 3. Steve Chenoweth Phone: Office (812) Cell (937)

Domain Modeling- 2. Generalization

Constantinos Constantinides Computer Science and Software Engineering Concordia University Montreal, Canada

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

Domain Modeling: Associations and Attributes

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

Software Modeling & Analysis

GRASP: Patterns for. chapter18

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

PART 5 Elaboration Iteration 3 Intermediate topics. Iteration 3

Object-Oriented Software Engineering Practical Software Development using UML and Java

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

References: Applying UML and patterns Craig Larman

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

Designing for Visibility & Mapping to Code CSSE 574: Session 4, Part 3

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

Download FirstOODesignPractice from SVN. A Software Engineering Technique: (Class Diagrams)

From designing to coding

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

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 5: Modelling with Classes

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

Some Software Engineering Techniques (Class Diagrams and Pair Programming)

Principles of Software Construction: Objects, Design and Concurrency. Object-Oriented Design: Assigning Responsibilities.

Object Oriented Software Development CIS Today: Object Oriented Analysis

Software Design and Analysis CSCI 2040

Creating Class Definitions from Design Class Diagrams: public class SalesLineItem // Java { private int quantity;

Assigning Responsibilities by Larman

Design Engineering. Dr. Marouane Kessentini Department of Computer Science

ROEVER ENGINEERING COLLEGE DEPARTMENT OF INFORMATION TECHNOLOGY CS2353-OBJECT ORIENTED ANALYSIS AND DESIGN. Unit-I. Introduction to OOAD

COMP 6471 Software Design Methodologies

Sequence Diagram. A UML diagram used to show how objects interact. Example:

Sequence Diagram. r: Register s: Sale

OBJECT ORIENTED ANALYSIS AND DESIGN SYLLABUS

A - 1. CS 494 Object-Oriented Analysis & Design. UML Class Models. Overview. Class Model Perspectives (cont d) Developing Class Models

COMP 354: INTRODUCTION TO SOFTWARE ENGINEERING

CS6502-OBJECT ORIENTED ANALYSIS AND DESIGN Two Marks Question with Answers Unit-I Introduction to OOAD

Chapter 10. Object-Oriented Analysis and Modeling Using the UML. McGraw-Hill/Irwin

What is a Model? Copyright hebley & Associates

Tutorial notes on. Requirements analysis

2 GRASP Patterns and basic OO Design. Roel Wuyts OASS

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING CS2353-OBJECT ORIENTED ANALYSIS AND DESIGN. Unit-I. Introduction to OOAD

SE203b: OO Design for Software Engineers. Office: TEB349, Ext

Chapter 1: Programming Principles

Object-Oriented Analysis and Design

GRASP Design Patterns A.A. 2018/2019

Chapter 1: Principles of Programming and Software Engineering

Logical Architecture & Design Preliminaries

CSSE 374: Logical Architecture. Shawn Bohner Office: Moench Room F212 Phone: (812)

Introduction - SENG 330. Object-Oriented Analysis and Design

4 Software models. often more than what people can handle not necessary to know all details at all times

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

Modeling Dynamic Behavior

On to Object-oriented Design

System Sequence Diagrams. Based on Craig Larman, Chapter 10 and Anuradha Dharani s notes

Chapter 3: Object Oriented Design

MechEng SE3 Lecture 7 Domain Modelling

Modelling with Classes. CITS1220 Software Engineering

Object Fundamentals Part Three. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 4 09/06/2007

Applying UML & Patterns (3 rd ed.) Chapter 15

Advanced Class Diagrams and Intro to Interaction Modeling

Software Design and Analysis CSCI 2040

The OO Solution. Objects

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

Äriprotsesside modelleerimine ja automatiseerimine Loeng 7 Valdkonna mudel

Object-Oriented Design

Lecture 2 and 3: Fundamental Object-Oriented Concepts Kenneth M. Anderson


Object-Oriented Design I - SOLID

user.book Page 45 Friday, April 8, :05 AM Part 2 BASIC STRUCTURAL MODELING

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

1: Introduction to Object (1)

SE 1: Software Requirements Specification and Analysis

Sommerville Chapter 7 Fowler Chapters 1, 3, 5, and 6. Conceptual Modeling and Class Diagrams

Module Outline. What is Object-Oriented? Some Possible Definitions. Why Object-oriented? Fundamentals of Object Orientation

Object-Oriented Systems Development: Using the Unified Modeling Language

Software Modeling & Analysis

Information Technology Audit & Cyber Security

CSSE 374: Design Class Diagrams. Shawn Bohner Office: Moench Room F212 Phone: (812)

Principles of Software Construction: Objects, Design, and Concurrency

Software Life-Cycle Models

Chapter 10 Object-Oriented Design Principles

Modeling Dynamic Behavior

CS350 Lecture 2 Requirements Engineering. Doo-Hwan Bae

1 OBJECT-ORIENTED ANALYSIS

CS 215 Software Design Sample midterm solutions

Inheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L

Building custom components IAT351

Object-Oriented Design

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

MSO Lecture 3. Wouter Swierstra. September 14, 2015

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Transcription:

CTIS 359 Principles of Software Engineering SOFTWARE DESIGN OO(A)D

Today s Objectives To explain the basic concepts of OO(A)D To describe some best practices regarding to OO(A)D

What is NOT UML? The UML is NOT OOA/D or a method, it is just a diagramming notation. It is useless to learn UML and perhaps a UML CASE tool, but not really know how to create an excellent OO design, or evaluate and exisiting one. Source: Applying UML & Patterns, Craig Larman Page 4

You may follow... 1. Domain Model 2. Domain Model Refinement 3. System Sequence Diagrams (=SSD) 4. Operation Contracts (=OC) 5. UML Code Mapping 6. Software Class GUI Classes

What is a domain model? OOAD Applying UML notation, a domain model is illustrated with a set of class diagrams in which NO operations (method signatures) and NO software artifacts (e.g., a window, a database) are defined. Source: Applying UML & Patterns, Craig Larman Page 134

What is a domain model? OOAD (Cont.) Domain model may show Conceptual classes (or domain objects) Associations Attributes of Conceptual Classes Source: Applying UML & Patterns, Craig Larman Page 134

What is a domain model? OOAD (Cont.) A Domain Model is an OOA construct that: Shows abstractions (conceptual classes) in the problem domain, NOT the solution domain Is best kept at high level so as to verify with end users, and other stakeholders Is built over several iterations

What is a domain model? OOAD (Cont.) X X

Strategies for building a conceptual classes Method 1)Reuse or modify the existing models Method 2) Draw from a list of existing conceptual class categories best practices Method 3) From nouns in the use cases text (=descriptions)

What is a domain model? OOAD (Cont.) 1. List the candidate conceptual classes using the Conceptual Class Category List and noun phrase identification techniques related to the current requirements under consideration. 2. Draw them in a domain model. 3. Add the associations necessary to record relationships for which there is a need to preserve some memory. 4. Add the attributes necessary to fulfill the information requirements

List of existing conceptual class categories Method 2 Conceptual Class Categories business transactions Guideline: These are critical (they involve money), so start with transactions. transaction line items Example(s) Sale Payment Reservation SalesLineItem Guideline: Transactions often come with related line items, so consider these next. product or service related to a transaction or transaction line item Guideline: Transactions are for something (a product or service). Consider these next. Flight Seat Meal Item Source: Applying UML & Patterns, Craig Larman Page 140-1

List of existing conceptual class categories (Cont.) Conceptual Class Categories where is the transaction recorded? Guideline: Important. roles of people or organizations related to the transaction; actors in the use case Guideline: We usually need to know about the parties involved in a transaction. place of transaction; place of service Store Example(s) Register Ledger FlightManifest Cashier Customer Store MonopolyPlayer Passenger Airline Airport Plane Seat Source: Applying UML & Patterns, Craig Larman Page 140-1

List of existing conceptual class categories (Cont.) conceptual class categories catalogs Guideline: Descriptions are often in a catalog. containers of things (physical or information) things in a container other collaborating systems Example(s) ProductCatalog FlightCatalog Store Bin Board Airplane Item Square (in a Board) Passenger CreditAuthorizationSystem AirTrafficControl Source: Applying UML & Patterns, Craig Larman Page 140-1

List of existing conceptual class categories (Cont.) conceptual class categories noteworthy events, often with a time or place we need to remember physical objects Guideline: This is especially relevant when creating device-control software, or simulations. descriptions of things Guideline: See p. 147 for discussion. Example(s) Sale Payment MonopolyGame Flight Item Register Board Piece Die Airplane ProductDescription FlightDescription Source: Applying UML & Patterns, Craig Larman Page 140-1

List of existing conceptual class categories (Cont.) conceptual class categories records of finance, work, contracts, legal matters financial instruments schedules, manuals, documents that are regularly referred to in order to perform work Example(s) Receipt Ledger MaintenanceLog Cash Check, LineOfCredit TicketCredit DailyPriceChangeList RepairSchedule Source: Applying UML & Patterns, Craig Larman Page 140-1

From nouns in the use cases text Method 3 Linguistics Analysis Identify nouns & noun phrases in the textual description of domain, and consider them as candidate conceptual classes or attributes. Source: Applying UML & Patterns, Craig Larman Page 140-1

From nouns in the use cases text Method 3 Example Source: Applying UML & Patterns, Craig Larman Page 140-1

From nouns in the use cases text Method 3 (Cont.) Guideline: Care must be applied with this method; a mechanical noun-to-class mapping isn t possible, and words in natural languages are ambiguous. Source: Applying UML & Patterns, Craig Larman Page 140-1

Partial Domain Model Example Source: Applying UML & Patterns, Craig Larman Page 133

Benefit of Using Domain Models Lower the representation gap with OO modeling Source: Applying UML & Patterns, Craig Larman Page 138

Description Classes Add a description (conceptual) class (for example, ProductSpecification) when: There needs to be a description about an item or service, independent of the current existence of any examples of those items or services. Deleting instances of things they describe (for example, Item) results in a loss of information that needs to be maintained, due to the incorrect association of information with the deleted thing. It reduces redundant or duplicated information. Source: Applying UML & Patterns, Craig Larman Page 147

Description Classes WORSE BETTER Source: Applying UML & Patterns, Craig Larman Page 147

UML Association Notation Associations in a Domain Model Associations for which knowledge of the relationships needs to be preserved for some duration (miliseconds, maybe years) Associations derived from the Common Associations List Source: Applying UML & Patterns, Craig Larman Page 151

UML Association Notation (Cont.) An association is represented by a line between classes with Capitalized association name. An association is inherently bidirectional = Capitalized Source: Applying UML & Patterns, Craig Larman Page 151

UML Association Notation (Cont.) Association Name Reading Direction Arrow (Optional) Default Left Right Top Bottom Multiplicity Source: Applying UML & Patterns, Craig Larman Page 152

Common Association List Category A is a transaction related to another transaction B A is a line item of a transaction B A is a product or service for a transaction (or line item) B A is a role related to a transaction B A is a physical or logical part of B A is a description for B Examples CashPayment Sale Cancellation - Reservation SalesLineItem - Sale Item SalesLineItem (or Sale ) Flight Reservation Customer - Payment Passenger - List Seat Airplane Square Board Drawer Register ProductDescription Item FlightDescription Flight Square Board Source: Applying UML & Patterns, Craig Larman Page 155

Common Association List(Cont.) Category A is physically or logically contained in/on B A is known/logged/recorded/reported/c aptured in B A is a member of B A is an organizational subunit of B A uses or manages or owns B A is next to B Examples Register Store Passanger Airplane Sale Register Reservation FlightManifest Piece Square Cashier Store Pilot Airline Department Store Maintenance Airline Pilot Airplane Player Piece SalesLineItem SalesLineItem Square-Square City-City Source: Applying UML & Patterns, Craig Larman Page 155

No Attributes Representing Foreign Keys Attributes should NOT be used to relate concepts in the conceptual classes in domain model. The most common violation of this principle is to add a kind of foreign key attribute, as it is typically done in relational database designs, in order to associate two types. Source: Applying UML & Patterns, Craig Larman Page 165

No Attributes Representing Foreign Keys (Cont.) WORSE BETTER Do not use attributes as foreign keys Source: Applying UML & Patterns, Craig Larman Page 165

Domain Model (2) Refinement Generalization and specialization are fundamental concepts in domain modeling. Conceptual class hierarchies are often the basis of the inspiration for software class hierarchies that exploit inheritance. Source: Applying UML & Patterns, Craig Larman Page 501

Domain Model (2) Refinement (Cont.) Class hierarchy with separate and shared arrow notations. Source: Applying UML & Patterns, Craig Larman Page 505

Domain Model (2) Refinement (Cont.) Legal conceptual class partition, but is it useful in our domain? Source: Applying UML & Patterns, Craig Larman Page 505

Domain Model (2) Refinement (Cont.) Guideline Create a conceptual subclass of a superclass when: 1. The subclass has additional attributes of interest. 2. The subclass has additional associations of interest. 3. The subclass concept is operated on, handled, reacted to, or manipulated differently than the superclass or other subclasses, in ways that are of interest. 4. The subclass concept represents an animate thing (for example, animal, robot) that behaves differently than the superclass or other subclasses, in ways that are of interest. Source: Applying UML & Patterns, Craig Larman Page 508

Domain Model (2) Refinement (Cont.) Guideline Create a superclass in a generalization relationship to subclasses when: 1. The potential conceptual subclasses represent variations of a similar concept. 2. The subclasses will conform to the 100% and Isa rules. 3. All subclasses have the same attribute that can be factored out and expressed in the superclass. 4. All subclasses have the same association that can be factored out and related to the superclass. Source: Applying UML & Patterns, Craig Larman Page 508

Domain Model (2) Refinement (Cont.) Justifying Payment subclasses Source: Applying UML & Patterns, Craig Larman Page 511

Domain Model Refinement (2) Abstract Conceptual Classes Definition If every member of a class C must also be a member of a subclass, then class C is called an abstract conceptual class. Source: Applying UML & Patterns, Craig Larman Page 513

Domain Model Refinement (2) Abstract Conceptual Classes (Cont.) Source: Applying UML & Patterns, Craig Larman Page 514

Domain Model (2) Refinement Association Classes Multivalued Guideline In a domain model, if a class C can simultaneously have many values for the same kind of attribute A, do not place attribute A in C. Place attribute A in another class that is associated with C. For example: A Person may have many phone numbers. Place phone number in another class, such as PhoneNumber associate many of these to Person. Source: Applying UML & Patterns, Craig Larman Page 517

Domain Model (2) Refinement Association Classes (Cont.) Source: Applying UML & Patterns, Craig Larman Page 518

Domain Model (2) Refinement Association Classes Guideline Clues that an association class might be useful in a domain model: 1. An attribute is related to an association. 2. Instances of the association class have a lifetime dependency on the association. 3. There is a many-to-many association between two concepts and information associated with the association itself. Source: Applying UML & Patterns, Craig Larman Page 519

Domain Model (2) Refinement Association Role Names Guideline Each end of an association is a role, which has various properties, such as: name multiplicity Source: Applying UML & Patterns, Craig Larman Page 522

Domain Model (2) Refinement Association Role Names (Cont.) An explicit role name is NOT required it is useful when the role of the object is not clear. It usually starts with a lowercase letter. If not explicitly present, assume that the default role name is equal to the related class name, though starting with a lowercase letter. Source: Applying UML & Patterns, Craig Larman Page 519

Domain Model (2) Refinement Association Role Names (Cont.) Source: Applying UML & Patterns, Craig Larman Page 519

Domain Model (2) Refinement Association Role Names (Cont.) Same instance of a person takes on multiple (and dynamically changing) roles in various associations Source: Applying UML & Patterns, Craig Larman Page 519

You have done enough on STATIC modeling Need some DYNAMIC modeling

System Sequence Diagrams (=SSD) Having explored domain modeling, SSD will be used to identify SYSTEM operations. (their effect on the domain model objects will be discussed in OCs) An SSD shows, for a particular course of events within use case. Guideline: Draw an SSD for a main success scenario of each use case, and frequent or complex alternative scenarios. Source: Applying UML & Patterns, Craig Larman Page 175

System Sequence Diagrams (Cont.) Source: Applying UML & Patterns, Craig Larman Page 177

System Sequence Diagrams (=SSD) Don t draw an SSD for all scenarios, UNLESS you are using an estimation technique (such as Function Point Counting) that requires identification of all system operations. Source: Applying UML & Patterns, Craig Larman Page 180

Operation Contracts Having explored SSDs and system operations, Operation Contracts takes the system operations and define their effect of the domain object models. Source: Applying UML & Patterns, Craig Larman Page 181

Operation Contracts Example Operation: Cross References: Preconditions: Postconditions: Contract CO2: enteritem enteritem(itemid: ItemID, quantity: integer) Use Cases: Process Sale There is a sale underway. - A SalesLineItem instance sli was created (instance creation). - sli was associated with the current Sale (association formed). - sli.quantity became quantity (attribute modification). - sli was associated with a ProductDescription, based on itemid match (association formed). Source: Applying UML & Patterns, Craig Larman Page 183

Analogy: The Spirit of Postconditions: The Stage and Curtain Why write postconditions in the past tense? Think about them using the following image: The system and its objects are presented on a theatre stage. 1. Before the operation, take a picture of the stage. 2. Close the curtains on the stage, and apply the system operation (background noise of clanging, screams, and screeches ) 3. Open the curtains and take a second picture. 4. Compare the before and after pictures, and express as postconditions the changes in the state of the stage (A SalesLineItem was created ). Source: Applying UML & Patterns, Craig Larman Page 186

UML Code Mapping The enteritem interaction diagram Source: Applying UML & Patterns, Craig Larman Page 249

UML Code Mapping (Cont.) Source: Applying UML & Patterns, Craig Larman Page 249

UML Code Mapping (Cont.) Source: Applying UML & Patterns, Craig Larman Page 377

UML Code Mapping (Cont.) class Payment // all classes are probably in a package named // something like: package com.foo.nextgen.domain; public class Payment { private Money amount; public Payment( Money cashtendered ){ amount = cashtendered; } public Money getamount() { return amount; } } Source: Applying UML & Patterns, Craig Larman Page 377

UML Code Mapping (Cont.) Class ProductCatalog public class ProductCatalog { private Map<ItemID, ProductDescription> descriptions = new HashMap()<ItemID, ProductDescription>; public ProductCatalog() { // sample data ItemID id1 = new ItemID( 100 ); ItemID id2 = new ItemID( 200 ); Money price = new Money( 3 ); ProductDescription desc; desc = new ProductDescription( id1, price, "product 1" ); descriptions.put( id1, desc ); desc = new ProductDescription( id2, price, "product 2" ); descriptions.put( id2, desc ); } public ProductDescription getproductdescription( ItemID id ) { } return descriptions.get( id ); } Source: Applying UML & Patterns, Craig Larman Page 377

UML Code Mapping (Cont.) public class Register { private ProductCatalog catalog; private Sale currentsale; public Register( ProductCatalog catalog ) { this.catalog = catalog; } public void endsale() { currentsale.becomecomplete(); } public void enteritem( ItemID id, int quantity ) { ProductDescription desc = catalog.getproductdescription( id ); currentsale.makelineitem( desc, quantity ); } public void makenewsale() { currentsale = new Sale(); } public void makepayment( Money cashtendered ) } { currentsale.makepayment( cashtendered ); } Source: Applying UML & Patterns, Craig Larman Page 377

Software Class GUI Classes Source: Applying UML & Patterns, Craig Larman Page 313

OO Design OO Programming Language During the OO Design process, you should also consider the characteristics of the programming language that you are going to implement. Characteristics of the programming language impose critical constraints on the overall system design.

Characteristics of some widely used OO PL Feature Smalltalk C++ Eiffel Java C# Strong Typing optional Static/dynamic Typing D S S S+D S+D Garbage Collection X Multiple Inheritence X X X Pure Objects X X X Dynamic Loading X X Standardized class libraries Correctness Costructs X X X X X X Source: Object Oriented Systems Analysis and Design using UML, 3/e Page 87

End Any questions/suggestions?