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.

Slides:



Advertisements
Similar presentations
Based on Java Software Development, 5th Ed. By Lewis &Loftus
Advertisements

Interaction Diagrams CSCI Interaction Diagrams Two Types of Interaction diagrams defined in UML Collaboration Diagram –Emphasizes the structural.
© 2006 ITT Educational Services Inc. SE350 System Analysis for Software Engineers: Unit 9 Slide 1 Appendix 3 Object-Oriented Analysis and Design.
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
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.
1 CS1001 Lecture Overview Homework 3 Homework 3 Project/Paper Project/Paper Object Oriented Design Object Oriented Design.
Unified Modeling Language (UML)
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.
1 CS1001 Lecture Overview Object Oriented Design Object Oriented Design.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
SE-565 Software System Requirements More UML Diagrams.
Teamwork Know each other Compete Leadership Strengths and Weaknesses
Chapter 3 Object-Oriented Analysis of Library Management System(LMS)
CS 8532: Adv. Software Eng. – Spring 2007 Dr. Hisham Haddad Tuesday Class will start momentarily. Please Stand By … CS 8532: Advanced Software.
Object Oriented Software Development
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
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)
Implementation Yaodong Bi. Introduction to Implementation Purposes of Implementation – Plan the system integrations required in each iteration – Distribute.
CS 3610: Software Engineering – Spring 2009 Dr. Hisham Haddad – CSIS Dept. Class Project OO Design Document Here is what you need to do for your class.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 CMPT 275 Phase: Design. Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance.
Chapter 5 Class Design. The Deliverables of the Class Design Process Class diagrams are further refined in this phase of development Object diagrams are.
1 Sub-Phase Low Level Design (cont). Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces.
Computer ScienceSoftware Engineering Slide 1 Today l As3 grading Clarity, completeness, inconsistencies Comments l CVS guru name l Project assignment l.
SWE © Solomon Seifu ELABORATION. SWE © Solomon Seifu Lesson 10 Use Case Design.
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.
Homework Due Next Week Use Case Diagram, Class Diagram, User Interface, State Diagram.
CS 4850: Senior Project Fall 2014 Object-Oriented Design.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
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.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Designing Classes CS239 – Jan 26, Key points from yesterday’s lab  Enumerated types are abstract data types that define a set of values.  They.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
© 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.
Systems Analysis and Design in a Changing World, Fourth Edition
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
OOP Review CS 124.
Refactoring Agile Development Project. Lecture roadmap Refactoring Some issues to address when coding.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
CSIS 4850: CS Senior Project – Spring 2009 CSIS 4850: Senior Project Spring 2009 Object-Oriented Design.
Sub-Phase Low Level Design (cont)
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
From Use Cases to Implementation 1. Structural and Behavioral Aspects of Collaborations  Two aspects of Collaborations Structural – specifies the static.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
1 Kyung Hee University Interaction Diagrams Spring 2001.
7 Systems Analysis – ITEC 3155 The Object Oriented Approach – Use Cases.
From Use Cases to Implementation 1. Mapping Requirements Directly to Design and Code  For many, if not most, of our requirements it is relatively easy.
Unified Modeling Language
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
SNSCT_CSE_PROGRAMMING PARADIGM_CS206
Object-Oriented Design
Slides by Steve Armstrong LeTourneau University Longview, TX
Analysis models and design models
Class Diagrams.
Defining Classes and Methods
CS 8532: Advanced Software Engineering
Design Yaodong Bi.
Presentation transcript:

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 diagram

Where Are We? (cont.) We’ve also produced –Object Persistence specifications –Process Architecture –Human-Computer Interface specifications What’s next? –Class Design (internals)

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

Relationships of SE Phases and UML Diagrams Analysis Use CasesScenariosClass Diagrams Class Design Object Diagrams Interaction Diagrams Class Diagrams Class Skeletons Implementation Class Definitions

Relationships of SE Phases and UML Diagrams Analysis Use CasesScenariosClass Diagrams Class Design Object Diagrams Interaction Diagrams Class Diagrams Class Skeletons Implementation Class Definitions

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 Convert general/abstract models created during the analysis phase into detailed models Stepwise refinement/evolutionary development Leads directly to the system implementation

Class Design Expand on the analysis deliverables to ensure complete functionality coverage –We’re about to commit ourselves so we want to make sure the design is complete and correct Add detail to class diagrams –Attributes –Method signatures Produce a class skeleton which will eventually turn into code

Class Diagrams Revisited Portray the elements of a class and the relationships between classes –Class –Interface –Relationship –Collaborations

Class Diagrams (cont.) Class –May be just a class name –May include attributes and/or access methods class-name attribute1 attribute2 method1() method2(int) method3()

Class Diagrams (cont.) Relationships (between classes) –Association –Generalization –Dependency class-1class-2 does-something-to base-classderived-class change-mechange-me too

Class Diagrams (cont.) Interface –Class interactions –Enforces encapsulation –Generally left out until the design phase class-1class-2 interface-1

Class Diagrams (cont.) Collaboration –Specifies that multiple elements must interact to produce a given behavior class-1 class-2 interface-1 class-3 update-operation

Class Diagrams (cont.) Access modifiers –Specify the mode of access of class methods and attributes Public Private Protected class-name -privateatt0 -privateatt1 +public0() -private0(int) #protected0()

Class Diagrams (cont.) Multiplicity –Cardinality of an association relationship PatronResouce *

Class Diagrams (cont.) Role –Descriptive label about the part an object plays in the association PatronResouce * Borrower

Class Diagrams (cont.) Constraints Tagged values –Special circumstances that must be considered –Versioning of diagrams –Associations with functional requirements –Nonstandard information PatronResource * Borrower {Requirement #5} {Student at most 25 resources} {Faculty and staff – no limit}

Class Diagrams (cont.) Aggregation –Class containment –Filled diamond means the contained class cannot exist on its own –Hollow diamond means the contained class can exist on its own Address Patron Overdue Notice Resource Name

Aggregation Often represented as an association Often represented by inclusion of an object type (class) in the attribute field of the including class All techniques are acceptable –Just make sure your designs are clear and concise

Interaction Diagrams Specify the interactions between classes –This information is absent in the Class Diagrams (only show relationships) –Collaboration Diagrams Structure of interactions –Sequence Diagrams Time ordering of interactions (messages)

Interaction Diagrams (cont.) Consists of –Objects Instance of a class (not the class itself) Links/Messages –Association between instances –Corresponds to an association in the Class Diagram –Likely to be implemented as a method (function) call

Interaction Diagrams (cont.) Loosely speaking Use Case Scenario instance of Class Diagram Interaction Diagram instance of –Analysis phase –Design phase –You’ll have one for each scenario

Interaction Diagrams (cont.) Object-name : class method-name(params) Object Link Message Symbols

Collaboration Diagram Also known as a Communication diagram (UML 2.0) Describe the Structure of interactions between classes

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

Collaboration Diagram :Life :Grid :User Interface CreateGrid(rows, columns) GetSizes(rows, columns) :Cell CreateCell() DrawGrid() EnterSize(rows) EnterSize(columns) User Initiate Game Scenario {Requirement #2}

Collaboration Diagram (cont.) :Grid :User Interface :Cell SetColor(bool occ) DrawGrid() UpdateCell(row, col) Set Cells Scenario User LBCallback(row, col)

Collaboration Diagram (cont.) :Grid :User Interface :Cell UpdateCell() :Ruleset UpdateCell(row, col) DrawGrid() Run Rules Scenario User StartCallback() ApplyRules() :Timer Start()

Collaboration Diagram (cont.) Just another step in the evolution of the system –Class Diagrams outline the general associations –Scenarios provide detailed “stories” –Combining the two provides us with clues to needed classes/methods/attributes/interfaces

Collaboration Diagram (cont.) Development of collaboration diagrams is an art, not a science –Basically, you’re writing programs, you’re just doing it pictorially and at a level a step or two above actual “programming” It all starts with the Use Cases and Scenarios and proceeds by adding detail to the Class Diagrams

LMS Case Study: Collaboration Diagram(Partial) : Patron : Library System : LibraryDatabase Checkout(ResourceI D) validatePatron(MemDat e) ( See deliverable 5.3 for entire diagram ) update(Patron ) create(LibraryDatabas e) getResource(Resource ID) getPatron(PatronID)

Sequence Diagram Describe the timing or ordering of interactions (messages) between classes

Sequence Diagram :Life:User Interface GetSizes(rows, columns) :Grid CreateGrid(rows, columns) :Cell CreateCell() DrawGrid() Initiate Game Scenario {Requirement #2} {Continue only when the rows/columns are less than 100}

Sequence Diagram (cont.) Similar content to Collaboration Diagrams Add the notion of “time” –Time increases from top to bottom –Topmost objects/messages are created/sent first –Objects may come and go over the life of the system Again, it’s an art, not a science

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(LibraryDatabas e) getResource(ResourceID) getPatron(PatronID) validatePatron (MemDate) (See deliverable 5.5 for entire diagram )

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

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

Object Diagram :Life :Grid rows = 12 Cols = 16 :Cell (0,0) occupied :Cell (0,1) occupied :Cell (11,15) unoccupied

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=“Ehrenreic h” ISBN=... (See deliverable 5.7 for entire diagram )

Why All The Diagrams? Code reuse –Identify reusable classes (inheritance/aggregate) Well-designed classes and methods –Private attributes (data) –Proper initialization (constructor) –Abstract data types (aggregates) –Self-documenting (attribute/method names) Assurance of data integrity –Object updates (interrelated transactions)

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 Resourc e Checkabl e Resource Reserve Resourc e BookElectroni c Media

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

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

Why All The Diagrams? (cont.) IT’S EASIER TO CHANGE THESE DIAGRAMS THAN IT IS TO CHANGE CODE! IT’S EASIER TO DEBUG WELL WRITTEN CODE THAN POORLY WRITTEN CODE!