Professional Documents
Culture Documents
Slide 13 ClassDesign
Slide 13 ClassDesign
Analyze Behavior
(Optional)
Refine the
Architecture
Class
Design Designer Define Design the
Components Database
Project Specific
Guidelines
Class
Design Design Classes
Supplementary
Specifications
MainWindow SubWindow
MainForm
Button DropDownList
1 0..1
FatClassDataHelper FatClassLazyDataHelper
- commonlyUsedAttr1 - rarelyUsedAttr1
- commonlyUsedAttr2 - rarelyUsedAttr2
Private
operations
Public Protected
operations operations
Class1
- privateAttribute
+ publicAttribute
# protectedAttribute
- privateOperation ()
+ publicOPeration ()
# protecteOperation ()
<<Entity>>
Student
- name
- address
- studentID
- nextAvailID : int
0..* 0..*
<<Entity>>
Student
+ getTuition() : double
+ addSchedule ( [in] aSchedule : Schedule) +alternateCourses
+ getSchedule ( [in] forSemester : Semester) : Schedule 1
+ deleteSchedule ( [in] forSemester : Semester) +primaryCourses
+ hasPrerequisites ( [in] forCourseOffering : CourseOffering) : boolean 0..2 0..4
# hasPassed ( [in] aCourseOffering : CourseOffering) : boolean
+ getNextAvailID() : int <<Entity>>
+ getStudentID() : int CourseOffering
+ getName() : String
+ getAddress() : String
Transition
State State
Final state
Indicates the object’s end
of life State2
Optional
May have more than one
Open Closed
Unassigned
removeProfessor addProfessor
Assigned
Unassigned
closeRegistration
cancel Canceled
addProfessor
do: Send cancellation notices
close
removeProfessor cancel
[ numStudents = 10 ]
cancel
Full
close Canceled
Unassigned do: Send cancellation notices
cancel
cancel
substate
Full
close[ numStudents < 3 ]
remove a professor
[ numStudents = 10 ] close
add a professor
closeRegistration [ has Professor assigned ]
(continued)
Purpose
Determine where structural relationships are
NOT required
Things to look for :
What causes the supplier to be visible to the
client
ClassA :ClassA
+ op1 ( )
ClassB :ClassB
ClassA :ClassA
ClassB :ClassB
ClassA :ClassA
+ op1 ( )
ClassB :ClassB
+ utilityOp ( )
Whole Part
Whole Part
Composition
Non-shared Aggregation
Multiplicity = 1 Multiplicity = 1
Composition
Class1 Class2
aggregation
Class1 Class2
composition
Student 1 Schedule
0..*
RegisterForCoursesForm 1 RegistrationController
1
Attribute
<<entity>>
Student <<entity>>
- name Schedule
- address - semester : Semester
- nextAvailID : int
1 + submit ()
- StudentID : int
- dateofBirth : Date + //save ()
0..*
# any conflicts? ()
+ addSchedule () + //create with offerings ()
+ getSchedule () + new ()
+ delete Schedule () Composition of + passed ()
+ hasPrerequisites ()
separate class
# hasPassed ()
<<Entity>> <<Entity>>
Schedule CourseOffering
?
<<Entity>> <<Entity>> <<Entity>> <<Entity>>
Schedule + primaryCourses CourseOffering Schedule + primaryCourses CourseOffering
0..* 0..4 0..* 0..4
Total number of
CourseOfferings is small, or <<Entity>> <<Entity>>
Schedule + primaryCourses CourseOffering
Never need a list of
CourseOfferings on a 0..* 0..4
Schedule
Total number of
CourseOfferings and <<Entity>> <<Entity>>
Schedules are not small Schedule + primaryCourses CourseOffering
“attached” to an
ScheduleOfferingInfo
- status
association + // is selected ()
+ // mark as selected ()
Contains
+ // mark as cancelled ()
properties of a + alternateCourses
0..2
relationship <<Entity>>
Schedule
0..*
+ primaryCourses
<<Entity>>
CourseOffering
+ // is enrolled in? ()
+ // mark as enrolled in ()
+ // mark as committed ()
<<Entity>>
PrimaryScheduleOfferingInfob
- grade
+ // is enrolled in? ()
+ // mark as enrolled in ()
+ // mark as committed ()
Design Decisions
1 1
- theCourseOffering 0..*
0..4
- primaryCourseOfferingInfo <<Entity>>
PrimaryScheduleOfferingInfob
- grade
+ // is enrolled in? ()
+ // mark as enrolled in ()
+ // mark as committed ()
Multiplicity > 1
Cannot use a simple value or pointer
Further “design” may be required
Needs a <<Entity>> <<Entity>>
container for Professor 0..1 0..* CourseOffering
CourseOfferings + Instructor
<<Entity>> <<Entity>>
Professor 0..1 0..* CourseOffering
+ Instructor
Formal Arguments
ParameterizedClass
<<bind>> (ActualArgument)
InstantiatedClass ActualArgument
After Item
List
<<bind>> (CourseOffering)
1 <<Entity>>
CourseOfferingList ActualArgument
0..*
0..*
+ isTeaching () : boolean + hasProfessor () : boolean
+ getInterest ()
Subclasses
(Child)
(Descendants)
Lion Tiger
+ communicate () + communicate ()
AnimateObject
Animal FlyingThing
+ color + color
+ getColor () + getColor () Animal FlyingThing
+ color + color
+ getColor () + getColor ()
Bird
Bird
{disjoint,complete} {disjoint}
Stock Bond
Savings Checking
Multiple Vehicle
inheritance
supported
{overlapping}
LandVehicle WaterVehicle
AmphibiousVehicle
Window Scrollbar
Is this correct?
WindowWithScrollbar
Window Scrollbar
WindowWithScrollbar
1
WindowWithScrollbar Scrollbar
1
Lion Tiger
Stack
+ communicate () + communicate ()
Animal List
Lion Tiger
Stack
+ communicate () + communicate ()
Stack List
1
Stack List
Manufacturer B
Manufacturer A Manufacturer C
OO Principle:
Encapsulation
+ communicate ()
Lion Tiger
+ communicate () + communicate ()
PartTimeStudent FullTimeStudent
+ name + name
+ address + address
+ studentID + studentID
+ maxNumCourses + gradDate
PartTimeStudent FullTimeStudent
+ maxNumCourses + gradDate
Student Student
+ name + name 1
Classification
+ address + address
+ studentID + studentID 1
1 : \changeToFullTime\
2 : \delete\
3 : \create\
ResidentInformation Student
+ dorm 0..1 + name 1
+ room + address Classification
+ roomKeyID + studentID
1 1
studentID
ParttimeClassification FulltimeClassification
+ maxNumCourses + gradDate
Legacy
Persistency JDBC
Data
SomeDesignClass
RDBMS
New
Persistency ObjectStore
Data
Design
OODBMS
Guidelines
Remote Method
Distribution Java 1.2 from Sun
Invocation (RMI)
(continued)
Object Oriented Analysis and Design 107
Exercise 2: Class Design (cont.)
Identify the following:
The required navigability for each
relationship
Any additional classes to support the
relationship design
Any associations refined into
dependencies
Any associations refined into
aggregations or compositions
Any refinements to multiplicity
Any refinements to existing
generalizations
Any new applications of generalization
• Make sure any metamorphosis is
considered (continued)
Object Oriented Analysis and Design 108
Exercise 2: Class Design (cont.)
Produce the following:
An updated VOPC, including the
relationship refinements
(generalization, dependency,
association)
(continued)
Object Oriented Analysis and Design 109
Exercise 2: Review
Compare your results
Do your dependencies represent
context independent
relationships?
Are the multiplicities on the
relationships correct?
Does the inheritance structure
capture common design
Payroll System
abstractions, and not
implementation considerations?
Is the obvious commonality
reflected in the inheritance
hierarchy?
Object Oriented Analysis and Design 110