Chapter 5 Class Design. The Deliverables of the Class Design Process Class diagrams are further refined in this phase of development Object diagrams are.

Slides:



Advertisements
Similar presentations
Interaction Diagrams CSCI Interaction Diagrams Two Types of Interaction diagrams defined in UML Collaboration Diagram –Emphasizes the structural.
Advertisements

OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Systems Analysis and Design in a Changing World, Fourth Edition
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 5: Restaurant.
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 1 Software Development. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 1-2 Chapter Objectives Discuss the goals of software development.
Computer Science CS425/CS6258/23/20011 The Architecting Phase Class diagrams are further refined in this phase of development Object diagrams are created.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
© Copyright Eliyahu Brutman Programming Techniques Course.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Chapter 10 Class and Method Design
Teamwork Know each other Compete Leadership Strengths and Weaknesses
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Object-Oriented Analysis and Design
Object-Oriented Analysis and Design
Chapter 3 Object-Oriented Analysis of Library Management System(LMS)
CMPT 275 Software Engineering
Chapter 7: The Object-Oriented Approach to Requirements
Object-Oriented Design. From Analysis to Design Analysis Artifacts –Essential use cases What are the problem domain processes? –Conceptual Model What.
UML Collaboration Diagram. Recap System Sequence Diagrams (SSD) UML for SSD Examples.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
SOFTWARE ENGINEERING BIT-8 APRIL, 16,2008 Introduction to UML.
1 Phase Implementation. Janice Regan, Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine subphases)
CIT241 Prerequisite Knowledge ◦ Variables ◦ Operators ◦ C++ Syntax ◦ Program Structure ◦ Classes  Basic Structure of a class  Concept of Data Hiding.
Chapter 3 Object-Oriented Analysis. Requirements Analysis A requirement is a feature of the system Requirements analysis seeks to assess and specify the.
Introduction to Sequence Diagrams
1 CMPT 275 Phase: Design. Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
1 Sub-Phase Low Level Design (cont). Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
Dynamic Modeling Chapter 11 Part of Analysis Modeling Designing Concurrent, Distributed, and Real-Time Applications with UML Hassan Gomaa (2001)
Computer ScienceSoftware Engineering Slide 1 Today l As3 grading Clarity, completeness, inconsistencies Comments l CVS guru name l Project assignment l.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 9: Interaction.
Copyright 2002 Prentice-Hall, Inc. Chapter 2 Object-Oriented Analysis and Design Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey.
Lecture 3 Uses Cases Topics UML Use Cases pop quiz Readings: Chapter 3 January 24, 2008 CSCE 492 Software Engineering.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13: Introduction to Classes.
Homework Due Next Week Use Case Diagram, Class Diagram, User Interface, State Diagram.
Systems Analysis and Design in a Changing World, 3rd Edition
CS3773 Software Engineering Lecture 04 UML Class Diagram.
1 CMPT 275 Phase: Design. Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance.
Department of Informatics, UC Irvine SDCL Collaboration Laboratory Software Design and sdcl.ics.uci.edu 1 Informatics 43 Introduction to Software Engineering.
Class Design Phases. Where Are We? We’ve done our Product Design resulting in –Use Cases/Use Case diagrams –Class diagrams (initial) –State diagrams –Deployment.
Chapter 16 Applying UML and Patterns Craig Larman
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
Part VII: Design Continuous
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
Phase 6 Start: Saturday14 April End: Saturday 21 April
Systems Analysis and Design in a Changing World, Fourth Edition
Chapter 3: Introducing the UML
Chapter 7 Classes and Methods III: Static Methods and Variables Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition)
Sub-Phase Low Level Design (cont)
McGraw-Hill/Irwin© 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 17 Object-Oriented Design and Modeling Using the UML.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 13: Introduction to Classes.
1 Kyung Hee University Interaction Diagrams Spring 2001.
7 Systems Analysis – ITEC 3155 The Object Oriented Approach – Use Cases.
ITEC1301 Object-Oriented Systems Construction Lecture Notes #4 1.
 2007 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Introduction to Classes
Interactions.
Introduction to Classes
Defining Classes and Methods
Presentation transcript:

Chapter 5 Class Design

The Deliverables of the Class Design Process Class diagrams are further refined in this phase of development Object diagrams are created Interaction diagrams are created Class skeletons are created to embody all analysis and design information created to this point in the development process

Class Skeletons We will preview class skeletons to better understand the objectives of design Class skeletons are partial class definitions Class skeletons should be heavily commented, so that the purpose of all attributes, methods, and constructors is clear Class skeletons are the basis for the implementation phase of development

Contents of Class Skeletons A list of the roles the class plays within the system Information concerning when objects of the class are created and deleted (information maintenance) For each role, the semantics of the class All attributes with access modifiers, types, names, and semantics For all constructors and methods, their signature, semantics, preconditions and postconditions

LMS Class Skeleton public class Patron { // Class Semantics and roles // Library Patrons function in two primary // roles, as researchers who use index, // reference and database materials, and as // borrowers of loanable resources. // Information maintenance // Creation: new patrons are introduced // into the system by library staff when // presented with a library membership // application or from information // retrieved from a web-based application

More LMS Class Skeleton // Information maintenance continued // Deletion: patrons are removed from the // library database 3 years after their // membership expires // // Instance variables private String name; // Patron name in // last, first, middle initial format private long PatronID; // Patron library ID // number. Automatically generated...( See deliverable 5.1 for other instance variables )

More LMS Class Skeleton // Class variables private static long nextPatronID; // Keeps // track of next patronID to be assigned // Constructors public Patron(String n, long home, Date m, Date e, String street, String city, String state, long zip) { // Parameters: n = name, home = homephone // PatronID = getnextPatronID() // street,city, state, and zip are used // to create an address object for // homeAddress

More LMS Class Skeleton // Constructors continued // Precondition: for constructor: // Library database can accept an // additional entry and memory allocation // succeeds // Postcondition: Library database will // contain an additional Patron and Address // entry } // Static methods public static long getnextPatronID() { return nextPatronID; nextPatronID++;}

More LMS Class Skeleton // Non-static methods public boolean validatePatron(Date e) { // ensure membership is not expired // Precondition: expireDate != null // if expireDate <= Today return false // else return true }...( See deliverable 5.1 for other non-static methods ) } // end class Patron

System Decomposition Adds detail to the previous system representation Can be done iteratively or in a traditional, waterfall manner Each phase in the system development decomposes the system further Leads to a blueprint for implementation

More UML Access Modifiers + means public - means private # means protected Constraints (restriction on the class) { } E.g {Students may check out at most 25 items} Tagged values also use { } E.g. {Requirement #5}

More UML: Multiplicity Multiplicity or cardinality is represented above by the 0..1 and 0..* The above diagram indicates that a resource is checked out by 0 or 1 patrons and that each patron may check out 0 to many resources PatronResource 0..1 checks out 0..*

More UML: Aggregation Patron Resource The solid diamond indicates that the Overdue form letter class consists of Patron and Resource objects The diamond is solid to indicate that the Patron and Resource classes exist in their own right Overdue form letter

Interaction Diagrams Interaction diagrams model dynamic aspects of the system by specifying the interaction among objects to produce a particular behavior Two types of interaction diagrams are defined in UML –Collaboration diagrams, which emphasize the structural organization of objects that send and receive messages –Sequence diagrams, which emphasize the time ordering of the messages passed between objects

Notational Elements of Interaction Diagrams Object Link Message method(parameters) Object: class The object name is optional in the depiction of an object in UML notation An object is distinguished from a class in UML notation by the colon and underlining of the class name

LMS Case Study: Collaboration Diagram(Partial) : Patron : Library System : LibraryDatabase Checkout(ResourceID) validatePatron(MemDate) ( See deliverable 5.3 for entire diagram ) update(Patron) create(LibraryDatabase) getResource(ResourceID) getPatron(PatronID)

Steps for Creating Collaboration Diagrams Identify a behavior to model Identify participating class and their relevant interrelationships Identify a specific scenario to model determine necessary message passing to carry out the behavior Introduce solution for object persistence, if needed

Sequence Diagrams Like collaboration diagrams, sequence diagrams model dynamic aspects of the system by specifying the interaction among objects to produce a particular behavior Sequence diagrams specify the time ordering of messages Sequence diagrams show the life span of each object

LMS Case Study: Sequence Diagram(Partial) : Patron : Library System : LibraryDatabase create(LibraryDatabase) getResource(ResourceID) getPatron(PatronID) validatePatron (MemDate) (See deliverable 5.5 for entire diagram )

Evaluating Design Modeling software helps us produce correct, well- structured systems The resultant models can also be scrutinized for potential data integrity problems For example, in the LMS system, having update methods execute separately for the Patron and Resource objects may result in data integrity errors if system failure occurs between the initiation of the first method and the termination of the second method

Object Diagrams Models a set of objects and their interrelationships during a system snapshot A system snapshot is the state of the software system at a selected moment of time Object diagrams model another static perspective of the system Unlike other diagrams, object diagrams may contain multiple instances of the same class

LMS Case Study: Object Diagram (partial) currentP: Student: List name=“Gert Stein” libraryID= homephone= workphone= membership= expire= :Book name = “SOTY” author=“b. hooks” ISBN=... :Book name = “FOF” author=“Ehrenreich” ISBN=... (See deliverable 5.7 for entire diagram )

Steps for Creating Object Diagrams Identify a system snapshot within a scenario to model Identify participating classes and their interrelationships Identify all allocated objects at the time of the snapshot Show the state of each object in the snapshot Determine all interobject links

Code Reuse Collaboration diagrams are of particular use in pattern scavenging Pattern scavenging involves studying the various diagrams produced during analysis and class design to identify patterns of class interaction Once such patterns are found, they should be evaluated to determine if they can be effectively reused

Reuse in LMS Resource Checkable Resource Reserve Resource BookElectronic Media

Guidelines for Class Design Always keep data private Always initialize data in a constructor Do not use too many related primitives Not all attributes need individual accessor or mutator methods Order elements comprising class definitions consistently Break up overly complex classes into multiple classes Name classes, methods and attributes well

Verification of the Class Design All system requirements developed during analysis must be addressed during design –All design documents must cross reference requirements from the requirements specification All required attributes and methods must be used properly –E.g. data integrity of attributes must be enforced by update methods The modules comprising the system must work together properly