Download presentation
Presentation is loading. Please wait.
Published byRalf Barton Modified over 9 years ago
1
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 1 classes a class describes a group of objects with: similar properties (attributes) common behavior common relationships to other objects common meaning class diagrams show classes with their attributes and operations, together with the associations between classes
2
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 2 what might be a class? concept event organization person place physical item business concept logical entity application computer behavior inventory system replenishment sale supplier stock clerk loading dock item for sale purchase order storage pattern physical count scanner stale dating airline reservation system reservation arrival travel agency customer travel office aircraft reservation flight timetable reservation transaction index reservation cancellation
3
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 3 finding classes in use cases look for nouns and noun phrases in the description of the use cases include them in the model if they explain the nature or structure of information in the application but don’t create concepts which: are beyond the scope of the system refer to the system as a whole duplicate other classes are too vague or specific (few instances)
4
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 4 describing a class unique simple name or path name (if it’s in a package) named property describing the range of values instances may hold behaviors the class can exhibit contract or obligation the class may have optional
5
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 5 class name name of object simple namee.g. order, customer, campaign path namee.g. business rules::FraudAgent, java::awt::Rectangle A package is a general purpose mechanism for organizing elements (in this case classes) into groups client order +OrderForm +TrackingForm -Order
6
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 6 attributes + public = can access from other classes - private = cannot access from other classes # protected = can access from subclasses Wall + material : string + height : Float + width : Float + thinkness : Float + isLoadBearing : Boolean = false - density : Float + dateBuilt : Date
7
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 7 [visibility] name [multiplicity] [: type] [= initial-value] [{property-string}] visibility name multiplicity type initial-value property-string + (public), # (protected), - (private) e.g. CustomerName, DiscountRate e.g. [0..1], [2..*] e.g. Point, String, Date, etc. e.g. =(0,0), = null changeable (default), addOnly, frozen 6 examples of legal attribute declarations originorigin : Point = (0,0) + originid : integer {frozen} origin : Pointname : [0..1] : String Booch, jacobson, Rumbaugh. The Unified Modeling Language User Guide. Addison Wesley. 1999. pg 127-128. attribute declaration
8
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 8 operations + public # protected - private ( ) operation parameter Patient + makeAppointment ( ) + calculateLastVisit ( ) + changeStatus ( ) + provideMedicalHistory ( ) examples of operations change the value of attributes change state change links invoke other objects
9
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 9 operation signatures [visibility] name [(parameter-list)] [ : return-type] visibility name parameter-list return-type + (public), # (protected), - (private) e.g. restart, addStudent see below e.g. Integer, String, etc each parameter looks like this [direction] name : type [= default-value] direction name type default-value in, out, inout e.g. getId, calculateBonus Boolean, Money, etc. e.g. 42, John
10
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 10 an example parameters in signatures returned value Campaign title : String campaignStartDate : Date campaignFinishDate : Date estimatedCost : Money actualCost : Money completionDate : Date datePaid : Date completed (completionDate : Date, actualCost: Money) setFinishDate ( FinishDate : Date) recordPayment ( datePaid : Date ) costDifference ( ) : Money
11
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 11 classes and instances
12
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 12 classes and subclasses
13
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 13 types of classes
14
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 14 salesStaffclient sales staff liaises with 1 0..* staffPositionstaffMember is allocated to 1..* 0..* memberPosition
15
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 15 links FoodCo is the client in the World Tradition campaign and associations staff members are assigned client(s) each client has one staff assigned to it
16
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 16 class diagram
17
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 17 class diagram
18
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 18 class diagram
19
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 19
20
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 20 Class-Responsibility-Collaboration cards CLASS NAME RESPONSIBILITIESCOLLABORATING CLASSES operation 1 operation 2 operation 3 etc. class A none class B, class C CRC cards
21
University of Toronto at Scarborough © Kersti Wain-Bantin CSCC40 classes 21 actor action 1.0 enter customerNumber 2.0 enter itemCode 3.0 enter itemQuantity 4.0 indicate order is complete E1.0 enter customerNumber E1.1 select addCustomer system response display customerName display itemDescription display itemPrice display orderAmount and orderNumber display “not found” message offer selection of exit or add customer invoke addCustomer exceptions basic flow
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.