CSci 375/11 Class Diagrams
Table| Date | # | Topic (Participation 2pt) | Study pages (2 pts) | Quiz(15 pts) | Project Work(10 pts)
|
|---|
| Previous | 10 | Interactions | 221-247 | - | W4(Transition to Design)
|
| Today | 11 | Class Diagrams | 248-270 | Q5(221-270) | -
|
| Next | 12 | GRASP | 271-319 | - | W5(Interaction & Class Diagrams)
|
(Close Table)
Revision History
Table| Version# | Date | Description | Author
|
|---|
| 0 | 2005-01-03 | Used boiler plate to make template | RJB
|
| 1 | 2005-02-07 | Added section Headings | RJB
|
| 2 | 2005-02-16 | Adding questions | RJB
|
| 3 | 2006-02-13 | Updated | RJB
|
(Close Table)
Project W4 -- SSD and Packages due
[ w4.html ]
How do all these diagrams and documents work together?
First look inside the front cover of the book:
[ artifactrelationships.gif ]
16 Class Diagrams
Introduction
- *** Class diagrams are used for many purposes: domain models, object oriented designs, models of code, defining component interfaces, ...
- DCD::acronym="Design Class Diagram", a class diagram that models the
classes that will appear inside the code for the software.
[ watch?v=Vy_gLkxuCnw&feature=related ]
(YouTube with robotic voice and one error (no void in UML!)).
- Static model: what is possible. Also need models of dynamics:
what happens. Need to relate them.
- Make sure that what should happen in the machine is possible!
- Develop interactions and classes in parallel: Each object is in a
class so put the class in the class diagram. Each message points at an
object in a class.... add the message as an operation in the class. Each
message links two objects and if they are in different classes then there
will be a path in the class diagram. Data (in messages or returned)
may become attributes in the class diagram. See session
[ 13.html ]
onward.
- Your first attempts will be hesitant and messy.
Later in this class the attempts will be just messy.
- In a real project, let the problem drive the diagrams.
- We will cover a set of Patterns for placing operations into classes.
These are called the
GRASP
patterns. The first is simple enough that you can use it in your projects,
right now:
(Information_Expert): An operation should be done by the class that has the information that is needed by the operation.
- Process: Each use case becomes many scenarios.
Each scenario becomes one SSD. Each SSD makes many Interaction diagrams.
One interaction per message (max) in the SSD. One DCD for all the interactions.
See
[ UC2Code.png ]
for an informal sketch of the flow.
16.1 - 16.6 Important notations and definitions for class Diagrams
- *** 16.1 Notations (Q5) Put a sticky note on this section
- * 16.2 Definitions: Design vs domain
- 16.3 Definition: Classifier (UML Jargon)
- ** 16.4 Attributes and associations (Q5)
- **** The idea is to make the connections between classes OBVIOUS.
- *** use role names in designs and association names in domain models.
- * 16.5 Notes and comments (Q)
- ** explain, constrain, and code!
- *** 16.6 Operations and methods (Q5)
16.7 - 16.9 Notations used later
- * 16.7..9 Properties: keywords, stereotypes, profiles, and tags, ...
(Used later in this class)
16.10 Generalization, Dependency, and Abstraction
- *** 16.10 Generalization and Abstraction (Q)
(some sample generalizations)
- * 16.11 Dependency (Q)
One class depends on another if changing one can effect the correct
operation of the other.
- * 16.12 Interfaces (Q)
An
interface
is a set of operations that gives access to objects that realize that interface.
It is a socket into which other objects can plug-in.
- ++ Think sockets and plugs --
16.13-16.16 Associations etc
- * 16.13 Composition (Q)
- "is a part of" -- like data in an object.
- + Use in designs not domain models.
- *** avoid <>-- aggregation. Use ----> instead!
- ** 16.14 Constraints (Q)
- 16.15 Qualified Associations
- ** 16.16 Association classes
- +++ or make into a class that links the associated classes.
- ++ For example: SalesOrder and Stock are linked by a many-many relationship
by SalesOrderItem:
16.17 - 16.20 Advanced stuff: singletons, templates, ...
- 16.17 Singleton Classes (Future)
- 16.18 Template classes and Interfaces (Future)
- ** 16.19 User-Defined compartments
- * 16.20 Active Classes (Future)
16.21 Relating interaction and class diagrams
- ***** A vital skill(Q5).
Each part of an interaction diagram tells you something about the
design class diagram (DCD).
Table| Interaction Diagram | Class Diagram
|
|---|
| Object life line | Class
|
| Message to object | Operation in target class
|
| Data | May be an attribute of sending class
|
| Returned Data | May be an attribute of class that returned it
|
(Close Table)
- Example
[ 11getStatusses.gif ]
(Interaction -- finding the statusses of a customer's orders)
[ 11StatussesDCD.gif ]
(Changed DCD).
- +++ One DCD for many interaction diagrams.
- ++ Each interaction adds to the DCD.
. . . . . . . . . ( end of section 16 Class Diagrams) <<Contents | End>>
My notes on Class Diagram Notation
[ ../samples/uml1.html ]
(generic)
[ ../samples/uml1b.html ]
(C++ oriented)
[ ../papers/20050502Body.html#Class and Object Diagrams ]
(UML2.0 changes)
Be careful to use arrows correctly in the UML
Example if time
Developing a communication diagram, a sequence diagram and a class
diagram in parallel.
Exercises on Interaction Diagrams if time
Translate given communication diagram to a sequence diagram.
Use interaction diagrams to develop a class diagram that supports
the interactions.
Use a pair of a communication and a sequence diagram of the same
collaboration to fill in blanks.
See
[ 11Exs.png ]
Here is a domain model and a communication diagram from the last class
[ 10ExGetUnfilledInteract.html ]
(thank you Visio). Redraw the Domain class diagram as a Design Class Diagram that
supports the communications shown.
Time to recall or reconstruct the domain model of the objects in a classroom for
an inventory of the CSUSB campus. Add some generalizations and more general classes.
Project Step 5 Interactions and Classes -- Next Week
[ w5.html ]
is due next week.
Quiz on Interaction Diagrams and Classes
(Q5): May be tested in Quiz 5 (will be tested sooner or later).
Make a set of diagrams fit together. OPEN BOOK.
Note:
(Q): Some topics will be tested later...
Questions and Answers
[ 11q.html ]
Next: How to make a good design
[ 12.html ]
Review Questions
[ 11r.html ]
Standard Definitions
- CS202::= See http://cse.csusb.edu/dick/cs202/.
- CS372::= See http://cse.csusb.edu/dick/cs372/.
- DCD::diagram="Design Class Diagram", shows the classes that will be implemented in code.
- DRY::XP="Don't Repeat Yourself".
- ESSUP::Process= See http://www.ivarjacobson.com/essup.cfm,
Ivar Jacobsen simplified "Essential" UP.
- Glossary::= See http://cse.csusb.edu/dick/cs375/uml.glossary.html.
- GoF::="Gang of Four",
[ patterns.html#GoF ]
- GRASP::patterns="General Responsibility Assignment Software Patterns",
a set of guidelines for designing objects and classes. They take a single
event that the system must handle and determine a good class to carry it out.
See
[ patterns.html#GRASP -- General Responsibility Assignment Software Patterns ]
- Grades::= See http://cse.csusb.edu/dick/cs375/grading/.
- KISS::Folk_law="Keep It Simple, Stupid", in agile processes this means never
drawing a diagram or preparing a document that doesn't provide value
to the clients and stakeholders. In all processes it means never
designing or coding what is not needed, see YAGNI.
- OO::shorthand="Object-Oriented".
- OOAD::="Object-Oriented Analysis and Design", See chapter 1 in text.
- patterns::="Documented families of problems and matching solutions", see
Patterns.
- Patterns::= See http://cse.csusb.edu/dick/cs375/patterns.html.
- Process::="How to develop software".
- RJB::=The author of this document,
RJB="Richard J Botting, Comp Sci Dept, CSUSB".
- RUP::Process="Rational UP", a proprietary version of UP.
- SSD::="System Sequence Diagrams", see chapter 10.
- TBA::="To Be Announced".
- UML::="Unified Modeling Language".
[ Unified_Modeling_Language ]
- UP::="Unified Process", an iterative, risk-driven, and evolutionary way to develop OO software.
- YAGNI::XP="You Ain't Gonna Need It", an XP slogan that stops you
planning and coding for things that are not yet needed. As
a rule the future is not predictable enough to program a feature
until the stakeholders actually need it now. In this class it means
"It won't be on the final or in quizzes".
- XP::="Extreme Programming", the ultimate iterative code-centric, user-involved
process.