CSE 240 Lecture 5. © Lethbridge/Laganière 2001 Chapter 5: Modelling with classes2 Overview Discuss Assignment 1 Discuss more of chapter 5, possibly finish.

Slides:



Advertisements
Similar presentations
Use Case Diagram © copyright 2001 SNU OOPSLA Lab..
Advertisements

Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
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.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes (continued)
© Copyright Eliyahu Brutman Programming Techniques Course.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
03/12/2001 © Bennett, McRobb and Farmer Use Case Diagrams Based on Chapter 6 of Bennett, McRobb and Farmer: Object Oriented Systems Analysis and.
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
PRJ566: PROJECT PLANNING AND MANAGEMENT Class Diagrams.
Software Engineering Case Study Slide 1 Introductory case study.
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
Introduction To System Analysis and design
Unified Modeling Language User Guide Section 2—Basic Structural Modeling Chapter 4—Classes.
Computer Science II 810:062 Section 01 Session 2 - Objects and Responsibilities.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
What is a domain model? “A domain model captures the most important types of objects in the context of the business. The domain model represents the ‘things’
Software Engineering Chapter 8 Fall Analysis Extension of use cases, use cases are converted into a more formal description of the system.Extension.
OHTO -99 SOFTWARE ENGINEERING LECTURE 5 Today: - An overview to OO Analysis and OO Design - Introduction of Assignment 2.
Big Java Chapter 12. Software Process - Waterfall Analysis Design Implementation Testing Deployment Does not work well when rigidly applied! established.
Chapter 5: Modelling with Classes
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Chapter 6 Use Cases. Use Cases: –Text stories Some “actor” using system to achieve a goal –Used to discover and record requirements –Serve as input to.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
ICONIX P ROCESS FOR S OFTWARE D EVELOPMENT Hoang Huu Hanh, Hue University hanh-at-hueuni.edu.vn 1.
Uml is made similar by the presence of four common mechanisms that apply consistently throughout the language. After constructing or developing the architecture.
Lecture 5: Modelling with Classes. © Lethbridge/Laganière 2005 Chapter 5: Modelling with classes2 5.1 What is UML? The Unified Modelling Language is a.
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Lecture 3 Uses Cases Topics UML Use Cases pop quiz Readings: Chapter 3 January 24, 2008 CSCE 492 Software Engineering.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Systems Analysis and Design 8 th Edition Chapter 6 Object Modeling.
Conceptual Modeling Modeling the Problem Domain. Conceptual Modeling Decompose problem space into comprehensible concepts. Clarify the terminology or.
UML-1 3. Capturing Requirements and Use Case Model.
UML Use Case Diagramming Guidelines. What is UML? The Unified Modeling Language (UML) is a standard language for specifying, visualizing, constructing,
UML-1 8. Capturing Requirements and Use Case Model.
Conceptual Model or Domain Models Chapter10 Applying UML and pattern.
Discovering object interaction. Use case realisation The USE CASE diagram presents an outside view of the system. The functionality of the use case is.
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
Design Model Lecture p6 T120B pavasario sem.
Object Oriented Analysis and Design Class and Object Diagrams.
The Unified Modeling Language (UML)
© The McGraw-Hill Companies, Software Project Management 4th Edition Step Wise: An approach to planning software projects Chapter 2.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Domain Classes – Part 1.  Analyze Requirements as per Use Case Model  Domain Model (Conceptual Class Diagram)  Interaction (Sequence) Diagrams  System.
Systems Analysis and Design in a Changing World, Fourth Edition
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Domain Model A representation of real-world conceptual classes in a problem domain. The core of object-oriented analysis They are NOT software objects.
21/1/ Analysis - Model of real-world situation - What ? System Design - Overall architecture (sub-systems) Object Design - Refinement of Design.
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
CSCI 383 Object-Oriented Programming & Design Lecture 7 Martin van Bommel.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
DOMAIN MODEL—PART 2: ATTRIBUTES BTS430 Systems Analysis and Design using UML.
CSCE 240 – Intro to Software Engineering Lecture 3.
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes.
Elaboration popo.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Chapter 4 – Requirements Engineering
Classes and their relationships
Chapter 9 Domain Models.
ATM OO Design and Implementation Case Study
Unified Modeling Language
Week 10: Object Modeling (1)Use Case Model
OO Domain Modeling With UML Class Diagrams and CRC Cards
Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract, Computer,
Presentation transcript:

CSE 240 Lecture 5

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes2 Overview Discuss Assignment 1 Discuss more of chapter 5, possibly finish. Split into groups(exchange s, contact info)

Quote of the day “Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” -Rich Cook

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes4 Assignment 1 – Developing UML Class Diagrams Due June 16 th, at the beginning of class. You may submit a hand drawn version of your diagrams, or you may use a tool such as rational rose to generate the diagrams. All other parts of assignment must be typed. This is a group assignment. Each group need submit only one copy. E5.18 a and c. E5.19 a and c. E5.20 a and c. E5.21 a and c. E5.22 a and c. E5.24 a and c. You need to do the above exercises for only the Bank account management system and Geographical information system.

Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 5: Modelling with Classes (author’s slides – modified here and there by Orren Mckay) -continued-

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes6 Interfaces An interface describes a portion of the visible behaviour of a set of objects. An interface is similar to a class, except it lacks instance variables and implemented methods Interpret an interface as “can be seen as” «interface» Cashier withdraw deposit Machine ATMEmployee Person Machine ATMEmployee Person Cashier

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes7 Notes and descriptive text Descriptive text and other diagrams —Embed your diagrams in a larger document —Text can explain aspects of the system using any notation you like —Highlight and expand on important features, and give rationale Notes: —A note is a small block of text embedded in a UML diagram —It acts like a comment in a programming language

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes8 Object Constraint Language (OCL) OCL is a specification language designed to formally specify constraints in software modules An OCL expression simply specifies a logical fact (a constraint) about the system that must remain true A constraint cannot have any side-effects —it cannot compute a non-Boolean result nor modify any data. OCL statements in class diagrams can specify what the values of attributes and associations must be

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes9 OCL statements OCL statements can be built from: References to role names, association names, attributes and the results of operations The logical values true and false Logical operators such as and, or, =, >, (not equals) String values such as: ‘a string’ Integers and real numbers Arithmetic operations *, /, +, -

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes10 Show example of constraints on board Notes to me: {is valid SSN} for Employee {not NULL} for something Show note(don’t forget folded over corner) OCL can be freeform. Just as long as it’s understandable and you are consistent.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes The Process of Developing Class Diagrams You can create UML models at different stages and with different purposes and levels of details Exploratory domain model: —Developed in domain analysis to learn about the domain System domain model: —Models aspects of the domain represented by the system System model: —Includes also classes used to build the user interface and system architecture

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes12 System domain model vs System model The system domain model omits many classes that are needed to build a complete system —Can contain fewer than half the classes of the system. —Should be developed to be used independently of particular sets of -user interface classes -architectural classes The complete system model includes —The system domain model —User interface classes —Architectural classes —Utility classes

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes13 Suggested sequence of activities Identify a first set of candidate classes Add associations and attributes Find generalizations List the main responsibilities of each class Decide on specific operations Iterate over the entire process until the model is satisfactory —Add or delete classes, associations, attributes, generalizations, responsibilities or operations —Identify interfaces —Apply design patterns (Chapter 6) Don’t be too disorganized. Don’t be too rigid either.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes14 Identifying classes When developing a domain model you tend to discover classes When you work on the user interface or the system architecture, you tend to invent classes —Needed to solve a particular design problem —(Inventing may also occur when creating a domain model) Reuse should always be a concern —Frameworks —System extensions —Similar systems

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes15 A simple technique for discovering domain classes Look at a source material such as a description of requirements Extract the nouns and noun phrases Eliminate nouns that: —are redundant —represent instances —are vague or highly general —not needed in the application Pay attention to classes in a domain model that represent types of users or other actors

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes16 Identifying associations and attributes Start with classes you think are most central and important Decide on the clear and obvious data it must contain and its relationships to other classes. Work outwards towards the classes that are less important. Avoid adding many associations and attributes to a class —A system is simpler if it manipulates less information

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes17 Tips about identifying and specifying valid associations An association should exist if a class -possesses -controls -is connected to -is related to -is a part of -has as parts -is a member of, or -has as members some other class in your model Specify the multiplicity at both ends Label it clearly.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes18 Actions versus associations A common mistake is to represent actions as if they were associations * LibraryPatron borrow Loan borrowedDate dueDate returnedDate Bad, due to the use of associations that are actions **** * return CollectionItem * * LibraryPatronCollectionItem * * Better: The borrow operation creates a Loan, and the return operation sets the returnedDate attribute.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes19 Identifying attributes Look for information that must be maintained about each class Several nouns rejected as classes, may now become attributes An attribute should generally contain a simple value —E.g. string, number

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes20 Tips about identifying and specifying valid attributes It is not good to have many duplicate attributes If a subset of a class’s attributes form a coherent group, then create a distinct class containing these attributes

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes21 Identifying generalizations and interfaces There are two ways to identify generalizations: —bottom-up -Group together similar classes creating a new superclass —top-down -Look for more general classes first, specialize them if needed Create an interface, instead of a superclass if —The classes are very dissimilar except for having a few operations in common —One or more of the classes already have their own superclasses —Different implementations of the same class might be available

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes22 Allocating responsibilities to classes A responsibility is something that the system is required to do. Each functional requirement must be attributed to one of the classes —All the responsibilities of a given class should be clearly related. —If a class has too many responsibilities, consider splitting it into distinct classes —If a class has no responsibilities attached to it, then it is probably useless —When a responsibility cannot be attributed to any of the existing classes, then a new class should be created To determine responsibilities —Perform use case analysis [we haven’t covered yet] —Look for verbs and nouns describing actions in the system description

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes23 Categories of responsibilities Setting and getting the values of attributes Creating and initializing new instances Loading to and saving from persistent storage Destroying instances Adding and deleting links of associations Copying, converting, transforming, transmitting or outputting Computing numerical results Navigating and searching Other specialized work

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes24 Prototyping a class diagram on paper As you identify classes, you write their names on small cards As you identify attributes and responsibilities, you list them on the cards — If you cannot fit all the responsibilities on one card: -this suggests you should split the class into two related classes. Move the cards around on a whiteboard to arrange them into a class diagram. Draw lines among the cards to represent associations and generalizations.

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes25 Identifying operations Operations are needed to realize the responsibilities of each class There may be several operations per responsibility The main operations that implement a responsibility are normally declared public Other methods that collaborate to perform the responsibility must be as private as possible

© Lethbridge/Laganière 2001 Chapter 5: Modelling with classes26 For Next Time Finish reading chapter 5 if you haven’t already. Don’t get bogged down with the authors example of using OCL. Freeform constraints are acceptable as long as they are understandable and consistent. You can skip the section on converting UML class diagrams to java for now. Begin reading chapter 4. Read 4.1 – 4.5. This chapter starts on requirements (which will be your next group assignment).