pick of the day 10-Jan-2003 Lecture 2 Crash course on OO Analysis Models
January Lecture 22 Outline Previous Business Survey Results Constructor Challenge Results Reading Questions Crash course in OO modeling Continuing Mini-Example
January Lecture 23 Survey Results Topics of interest Primary OOD Secondary UML, OOP, Design Patterns, Software Architecture Tertiary Security, Swing, Transactions, Quaternary Persistence, Domain Analysis
January Lecture 24 Reading Questions What is the “inherent identity” that Lau considers objects to have? [p. 1] Book b = new Book (); Book b2 = b; Book b3 = new Book(); // identity checked by comparing object references b == b2 // true b2 == b3 // false
January Lecture 25 Equality tangent What is difference between == and equals Book b = new Book (); Book b2 = new Book(); // only Book class knows the answer if (b.equals (b2)) { } equals equals must be reflexive, symmetric, transitive
January Lecture 26 Reading Questions Object state is set by the object’s operations. Is this the only way to set an object’s state? No:1) constructor can set initial state 2) class attributes can be pre-set upon construction 3) Thread of computation within object can alter values
January Lecture 27 Reading Questions What is the difference between uni- directional and bi-directional associations? CategoryBook 1* The underlying link between the objects is one-way for unidirectional associations but two-way for bi-directional associations Category Books:Book[*] Book
January Lecture 28 Reading Questions What is the practical impact of maintaining a bidirectional association? 1) referential integrity 2) simultaneous creation AB AB A
January Lecture 29 Binary Associations Familiar to C programmers Links are realizations of associations Unidirectional: object reference (pointer) Bi-direction: more than doubly-linked list What is access scope of object? What are core operations?
January Lecture 210 Binary Association Alternatives Does Book know of its Category “parent”? Does Category maintain “ownership” over the aggregate set? Can a change to a Book impact/invalidate set? Who is responsible for add/remove? Does the relationship scale to 10,000 books? 10,000,000 books? CategoryBook 1*
January Lecture 211 N-ary associations How common are they? a complex set of binary associations can be greatly simplified through an n-ary association Committee Year Person post Committee Year Person Post * * * * * *
January Lecture 212 Aggregation and Composition Normal Association Aggregation special binary association between aggregate (the set) and its elements “operations on whole are propagated to subparts” Composition stronger than aggregation, implies that a sub-part is integral part of greater whole “whole cannot exist without subpart” but “subpart can exist without whole” Differences are subtle and may be refined later.
January Lecture 213 Aggregate Composition Quiz Category ––––Book Frame –––– Button Canvas –––– Font Course –––– Student Polygon–––– Point Student–––– Identifier
January Lecture 214 Aggregation/Composition Summary CharacteristicNormal Association AggregationComposition UML OwnershipNoneWeakStrong MultiplicityAny One : Any TransitivityNoYes Propagation of properties UndefinedWhole to Part
January Lecture 215 Servant Classes & Delegation To reduce complexity and increase cohesion create new class as servant to existing class servant object has only one “master” operations are delegated to servant object Lau claims this leads to higher abstraction and better reuse. Why?
January Lecture 216 Inheritance vs. Servant Point real x, y Circle Circle uses (x,y) as center But this can’t be right! Point real x, y Circle Point center abstract reuse
January Lecture 217 Monday Assignments Read: TAOO: Chapter 2.1 – 2.4 Modeling exercise try to model Person, Committee, Year as only binary relationships try to model Post as a separate class to manage Person/Committee/Year relationships Exercise 2-1, 2-2
January Lecture 218 References none