A Student Guide to Object-Oriented Development

Slides:



Advertisements
Similar presentations
More Diagramming & Practice with Relationship Modeling
Advertisements

Introduction to Object Orientation System Analysis and Design
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Visual Basic: An Object Oriented Approach 2 – Designing Software Systems.
Use Case Modeling SJTU. Unified Modeling Language (UML) l Standardized notation for object-oriented development l Needs to be used with an analysis and.
Chapter 22 Object-Oriented Systems Analysis and Design and UML Systems Analysis and Design Kendall and Kendall Fifth Edition.
IMS1001 – Information Systems 1 CSE Information Systems 1
Use Case Diagram © copyright 2001 SNU OOPSLA Lab..
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
Use-case Modeling.
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.
Slide 1 Systems Analysis & Design CS183 Spring Semester 2008 Dr. Jonathan Y. Clark Course Website:
Slide 1 Chapter 7 Structural Modeling. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 8 Slide 1 System models.
Lecture 4 Class Responsibility Collaboration Cards
Documenting Requirements using Use Case Diagrams
6/8/991 Analysis Tuesday 09/14/99 Revised: September 11, 2000 (APM)
NJIT 1 Domain Model Visualizing Concepts Chapter 9 Applying UML and Patterns Craig Larman.
SE 555 Software Requirements & Specification Requirements Analysis.
Chapter 7: The Object-Oriented Approach to Requirements
Objects What are Objects Observations
Chapter 9 Domain Models. Domain Model in UML Class Diagram Notation A “visual dictionary”
System Design Chapter 8. Objectives  Understand the verification and validation of the analysis models.  Understand the transition from analysis to.
Object-oriented methodology object models use case modeling unified modeling language the data dictionary the cornucopia case portfolio project Systems.
1 A Student Guide to Object- Orientated Systems Chapter 4 Objects and Classes: the basic concepts.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 7 Slide 1 System models l Abstract descriptions of systems whose requirements are being.
Chapter 4 System Models A description of the various models that can be used to specify software systems.
Introduction to Sequence Diagrams
A GENERIC PROCESS FOR REQUIREMENTS ENGINEERING Chapter 2 1 These slides are prepared by Enas Naffar to be used in Software requirements course - Philadelphia.
Presented by: CHAN LAI SAN ( ) REBAH DAW SARREB ( ) FIDA AL-OBAISI ( ) 08 April 2008 (Tuesday 6pm – 7:30pm)
Describing Process Specifications and Structured Decisions Systems Analysis and Design, 7e Kendall & Kendall 9 © 2008 Pearson Prentice Hall.
Other UML Diagramming Techniques CS 124. UML Diagramming Techniques Class Diagrams Use Case Diagrams Interaction Diagrams Sequence diagrams Collaboration.
Slide 1 Structural Modeling Chapter 7. Slide 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business.
THE CLASS DIAGRAM Pertemuan 10 Matakuliah: Konsep object-oriented Tahun: 2009.
Lecture 3 Uses Cases Topics UML Use Cases pop quiz Readings: Chapter 3 January 24, 2008 CSCE 492 Software Engineering.
CS 4310: Software Engineering Lecture 4 System Modeling The Analysis Stage.
Structural Modeling. Objectives O Understand the rules and style guidelines for creating CRC cards, class diagrams, and object diagrams. O Understand.
Systems Analysis and Design in a Changing World, 3rd Edition
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Conceptual Modeling Modeling the Problem Domain. Conceptual Modeling Decompose problem space into comprehensible concepts. Clarify the terminology or.
Chapter 9 Applying UML and Patterns -Craig Larman
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
1 A Student Guide to Object- Oriented Development Chapter 6 Identifying Functionality.
Lecture 6: Structural Modeling
1 Capturing Requirements As Use Cases To be discussed –Artifacts created in the requirements workflow –Workers participating in the requirements workflow.
1 Chapter 3 1.Quality Management, 2.Software Cost Estimation 3.Process Improvement.
User Interfaces 4 BTECH: IT WIKI PAGE:
Structural Modeling Chapter 7. Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes in.
1 Structural Modeling Chapter 7. 2 Key Ideas A structural or conceptual model describes the structure of the data that supports the business processes.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
Human Computer Interaction
Systems Analysis and Design in a Changing World, Fourth Edition
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Larman chapter 101 Domain Model: Visualizing concepts Larman chapter 10.
USE CASE Pertemuan 7 Matakuliah: Konsep object-oriented Tahun: 2009.
Slide 1 Systems Analysis and Design with UML Version 2.0, Second Edition Alan Dennis, Barbara Haley Wixom, and David Tegarden Chapter 7: Structural Modeling.
Identification of Classes. Object Oriented Analysis (OOA) OOA is process by which we identify classes that play role in achieving system goals & requirements.
1 M206 Chapter 31: An Overview of Software Development 1.Defining the problem 2.Analyzing the requirement – constructing initial structural model 3.Analyzing.
Systems Analysis and Design in a Changing World, Fourth Edition
Elaboration popo.
Chapter 4: Business Process and Functional Modeling, continued
Software Engineering Lecture 4 System Modeling The Analysis Stage.
Chapter 9 Domain Models.
Security Issues Formalization
About the Presentations
OO Domain Modeling With UML Class Diagrams and CRC Cards
Other UML Diagramming Techniques
Chapter 22 Object-Oriented Systems Analysis and Design and UML
Domain Model: Visualizing Concepts
Presentation transcript:

A Student Guide to Object-Oriented Development Chapter 5 The Class Diagram

The Class Diagram The class diagram appears through successive iterations at every stage in the development process. It is used first to model things in the application domain as part of requirements capture. It is used to design a solution. Finally it is used to design the program code.

Stages in building a class diagram There are several approaches depending on the size and type of system being developed the experience and ability of the team procedures of the organisation concerned. Example – Wheels system, we will want to store data about bikes. Bikes will be objects in the system model and eventually in the code

Stages in building a class diagram Two approaches: Use case realisation – identify classes needed to perform functionality identified in use cases. Proceed use case by use case. A domain model – model classes for the whole problem domain The group of classes required by a use case is called a collaboration. Example – Wheels system, we will want to store data about bikes. Bikes will be objects in the system model and eventually in the code

Stages in building a class diagram identify the objects and derive classes from them; identify attributes of classes; identify relationships between the classes; write a data dictionary to support the class diagram; identify class responsibilities using CRC cards; separate responsibilities into operations and attributes; iterate and refine the model.

Identify the objects and derive classes various techniques can be used for object identification none can be guaranteed to produce a definitive list of objects and classes they are just guidelines that might help search for nouns in the documentation a good starting point

Object identification using nouns Find a complete description of system requirements Underline all the nouns and noun phrases (person, place or thing) This gives a list of candidate objects Reject objects that will not make suitable classes

Description of problem: BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS USING NOUNS Description of problem: R1 keep a complete list of all bikes and their details including bike number, type, size, make, model, daily charge rate, deposit; (this is already on the Wheels system); R2 keep a record of all customers and their past hire transactions; R3 work out automatically how much it will cost to hire a given bike for a given number of days; R4 record the details of a hire transaction including the start date, estimated duration, customer and bike, in such a way that it is easy to find the relevant transaction details when a bike is returned; R5 keep track of how many bikes a customer is hiring so that the customer gets one unified receipt not a separate one for each bike; R6 cope with a customer who hires more than one bike, each for different amounts of time; R7 work out automatically, on the return of a bike, how long it was hired for, how many days were originally paid for, how much extra is due; R8 record the total amount due and how much has been paid; R9 print a receipt for each customer; R10 keep track of the state of each bike, e.g. whether it is in stock, hired out or being repaired; R11 provide the means to record extra details about specialist bikes.

Underline the nouns and noun phrases BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS USING NOUNS Underline the nouns and noun phrases R1 keep a complete list of all bikes and their details including bike number, type, size, make, model, daily charge rate, deposit; (this is already on the Wheels system); R2 keep a record of all customers and their past hire transactions; R3 work out automatically how much it will cost to hire a given bike for a given number of days; R4 record the details of a hire transaction including the start date, estimated duration, customer and bike, in such a way that it is easy to find the relevant transaction details when a bike is returned; R5 keep track of how many bikes a customer is hiring so that the customer gets one unified receipt not a separate one for each bike; R6 cope with a customer who hires more than one bike, each for different amounts of time; R7 work out automatically, on the return of a bike, how long it was hired for, how many days were originally paid for, how much extra is due; R8 record the total amount due and how much has been paid; R9 print a receipt for each customer; R10 keep track of the state of each bike, e.g. whether it is in stock, hired out or being repaired; R11 provide the means to record extra details about specialist bikes

List of nouns: list of bikes details of bikes: bike number, type, size, make, model, daily charge rate, deposit Wheels system record of customers past hire transactions bike number of days details of a hire transaction: start date, estimated duration customer receipt different amounts of time return of a bike total amount due state of each bike extra details about specialist bikes

Remove attribute nouns: BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS USING NOUNS Remove attribute nouns: list of bikes details of bikes: bike number, type, size, make, model, daily charge rate, deposit Wheels system record of customers past hire transactions bike number of days details of a hire transaction: start date, estimated duration customer receipt different amounts of time return of a bike total amount due state of each bike extra details about specialist bikes Specialist Bike is probably going to be a class … information about a class, not a class itself

Remove redundancy/duplicates list of bikes Wheels system record of customers past hire transactions bike hire transaction customer receipt return of a bike specialist bike list of bikes Wheels system record of customers bike hire transaction customer receipt return of a bike specialist bike Different amounts of time, number of days, estimated duration are probably the same thing, but we already removed them because they sounded like attributes. … different names for the same thing

Remove vague nouns: … words without precise meaning list of bikes BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS USING NOUNS Remove vague nouns: list of bikes Wheels system record of customers bike hire transaction customer receipt return of a bike specialist bike list of bikes Wheels system record of customers bike hire transaction customer receipt specialist bike If we don’t know exactly what is meant by a term it it cannot be basis of useful class. … words without precise meaning

Remove nouns too tied up with physical inputs and outputs: BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS UISNG NOUNS Remove nouns too tied up with physical inputs and outputs: list of bikes Wheels system record of customers bike hire transaction customer receipt specialist bike Receipt is an output from the system. List of bikes and record of customers should also be considered. Bike and Customer are good candidate nouns, but lists are too physical at this stage. … data inputs or system products

Remove association nouns: Is hires an association or a class? If there is data associated, probably a class Hire: start date, number of days, so Keep Hire as a class

Remove nouns that represent the whole system: BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS USING NOUNS Remove nouns that represent the whole system: Wheels system bike hire customer specialist bike things which EXIST not part of the intended system outside the BOUNDARY Car Park system not require details of these things … we want to divide the system into separate objects

Remove nouns outside scope of system: BUILDING A CLASS DIAGRAM > IDENTIFY OBJECTS USING NOUNS Remove nouns outside scope of system: From the Problem Definition (Chapter 2) we know that the system will not cover: - payroll - personnel - general accounting things which EXIST not part of the intended system outside the BOUNDARY Car Park system not require details of these things … not part of the intended system

Identified objects, derive classes BUILDING A CLASS DIAGRAM > DERIVE CLASSES USING NOUNS Identified objects, derive classes bike customer hire specialist bike SIGN renamed to be more specific … these nouns are left as potential classes

Add missing classes Add Payment class Not all classes appear as nouns in the problem description Apply common sense

Identify attributes of classes BUILDING A CLASS DIAGRAM Identify attributes of classes Many nouns will appear in the text being analysed e.g. bike number, available, type etc are attributes of bike. Avoid Attributes not relevant to current system – e.g. Customer passport number Derivable attributes – e.g. cost of hire (dialyHireRate*numberOfDays) Implementation attributes - pointers ‘available’ appeared as ‘state of bike’ in the problem description - renamed for clarity

Identify relationships between classes BUILDING A CLASS DIAGRAM Identify relationships between classes During analysis we have not yet got an exact notion of how objects will need to communicate with each other The relationships that we include at this stage model real-life relationships that we think might be useful We will not have an exact idea of the navigable paths we need to build in until after looking at the interaction diagram.

Identify relationships between classes During analysis we have not yet got an exact notion of how objects will need to communicate with each other; the relationships that we include at this stage model real-life relationships that we think might be useful. We will not have an exact idea of the navigable paths we need to build in until after looking at the interaction diagram.

Associations and Multiplicity BUILDING A CLASS DIAGRAM > IDENTIFY RELATIONSHIPS Associations and Multiplicity The Hire class holds data about the hiring of a bike. It needs to communicate with the Bike class to work out the cost of a hire (numberDays*dailyHireRate) To perform this calculation there must be a relationship between Hire and Bike

Associations and Multiplicity BUILDING A CLASS DIAGRAM > IDENTIFY RELATIONSHIPS Associations and Multiplicity Relationship between Hire and Bike showing that a :Hire is for only one :Bike but a :Bike can be hired 0, 1 or many times

Wheels class diagram with initial associations

Generalization and inheritance Many shared attributes type same as specialistType ,

Inheritance Shared attributes inherited by SpecialistBike BUILDING A CLASS DIAGRAM > IDENTIFY RELATIONSHIPS Inheritance Shared attributes inherited by SpecialistBike Distinguishing attributes (epoch and insurance) are unique to SpecialistBike

Data dictionary to support class diagram The data dictionary notation that we use in this book is semi- formal, and suitable for documenting the data of a small information system. We want to be able to define classes in terms of their attributes including:

Data dictionary to support class diagram The order in which they are listed (e.g. name, address, phone number)  Whether an attribute is repeated (e.g. a customer may have more than one phone number)  Any restrictions on the number of repetitions  Whether an attribute is optional (e.g. a customer may or may not have an email address)  The set of possible values for an attribute (e.g. in some businesses a customer may be individual or wholesale)  Selection between alternative values for an attribute (e.g. a customer is either individual or wholesale).

Data dictionary to support class diagram the data dictionary is constructed in parallel with the other models, details are added to the dictionary definitions as more information becomes available, the main UML models are cross-referenced via entries in the data dictionary as a means of ensuring consistency between them. more detail will be needed as we move closer to implementation

Data dictionary notation MEANING SYMBOL DESCRIPTION EXAMPLE consists of = introduces the definition of a data item Customer = and + joins components of the definition in sequence Customer = name + address one or more { } attribute may be repeated; any restrictions on the number of repetitions are written in subscript Customer = name + address + {phone}2 zero or one ( ) attribute is optional Customer = name + address + {phone}2 + (email) alternatives [ ] selection is indicated by enclosing the alternative attributes in square brackets [ ] Name = [initial | firstname] + surname either.. or | alternatives for selection in [ ] are separated by a vertical bar specific value “ ” indicates specific values “individual”, “wholesale” *…* comment comments are enclosed between asterisks Customer = name + address + {phone}2 + (email) + ["individual" | "wholesale"] *Wholesale customers are entitled to special discounts*

titleSection customerDetails hireDetails total Wheels Bikes Receipt for Hire Date______________ Customer name ______________________________________________ Address ______________________________________________ ______________________________________________ Bike No. Bike description Rate per day No. of days Hire cost Deposit Total cost Amount due Paid with thanks. customerDetails hireDetails total receipt = titleSection + customerDetails + {hireDetails} *a customer may hire more than one bike at a time* + total titleSection = "Mikes Bikes Receipt for Hire" + receiptDate customerDetails = customerName + customerAddress hireDetails = bikeNo. + bikeDescription + ratePerDay + noOfDays + hireCost + deposit + totalCost total = amountDue + "Paid with thanks“ We can decompose to further levels as needed, for example we could add: bikeDescription = make + model + type + size

What makes a good class? Problem domain During analysis, classes should correspond to things in the real world of the problem domain Functionality A class (at least during analysis) usually has both attributes and behaviour. Cohesion One of the qualities of a good software construct, listed at the beginning of this chapter, is cohesion. A class is cohesive if it is concerned with only one thing, if all its attributes and operations relate to the same topic.

Summary The class diagram defines the software architecture and the internal structure of the objects in an object- oriented system the classes we model in the class diagram form the basis of the classes in the code The stages in the construction of a class diagram are identifying objects and deriving classes identifying attributes identifying relationships writing a data dictionary identifying operations writing operation specifications.