Class Diagrams
- A class diagram gives an overview of a system by showing its classes and the relationships among them
- Class diagrams are static -- they display what interacts but not what happens when they do interact
- Class diagrams are a good design tool for the team
What is a Class ?
- A class is something that encapsulates information and behavior
- Classes can be identified by the nouns in the problem statement
- Attributes > Information
- Operations/Methods > Behavior
Primary class stereotypes in the UML
Boundary Class
- Boundary classes are those classes that lie on the boundary between your system and the rest of the world.
- They include all your forms, reports etc.
- There must be at least one Boundary class for every Actor-Use case interaction.
- It is not necessary to create a unique Boundary class for every actor-use case pair.
Entity Class
- Entity classes hold information that will be saved to persistent storage.
- Develop database structure through object model.
This allows us to trace all of the fields in the database back to a requirement.
Control Class
- Control classes are responsible for coordinating the efforts of other class.
- Typically one control class per use case, which controls the sequencing of events through the use case.
- Control classes may be shared among several use cases.
Visibility options
The Visibility option determines whether or not a class members can be seen outside.
- Visibility options for a class
Public (+) | Protected (#) | Private (-)
Multiplicity / Cardinality
A number of instances a class may have is called its multiplicity.
Multiplicity is a specification of the range of allowable cardinalities an entity may assume.
Cardinality options
n (default) 0..0 0..1 0..n 1..1 1..n
Relationships
Associations
- Associations are semantic connections between classes
- person works for a company
- employee has an id
- Classes in an association usually occupy equal places within a hierarchy
- Associations are used to show the relationship between different, independent classes in the overall object-oriented design
- Navigation
- Unidirectional
- Bidirectional
Aggregations
- Whole/Part-of relationship.
- An aggregate object includes (has-a) other objects, each of which is considered to be a part of (part-of) the aggregate object.
Composition
- A form of aggregation where the whole cannot exist without having the parts
- The parts are usually expected to live and die with the whole.
- Aggregation : Library has/contains books.
- Com"http://i1143.photobucket.com/albums/n637/shaanbucket/aggregation.png" height="88" width="431" />
Dependency
- Class references another class.
- Change in the referenced class specification may impact the using class.
- Direction of arrow gives direction of dependency
Generalizations
- Inheritance relationship between two classes.
- Allows one class to inherit the public and protected attributes and operations of another class.
- Save a great deal of time and effort in both development and maintenance.
Example
|
Exercise
Each elevator has a set of m buttons, one for each floor. These illuminate when pressed and cause the elevator to visit the corresponding floor. The illumination is canceled when the elevator visits the corresponding floor.
Each floor, except the first floor and top floor has two buttons, one to request and up-elevator and one to request a down-elevator. These buttons illuminate when pressed. The illumination is canceled when an elevator visits the floor and then moves in the desired direction.
When an elevator has no requests, it remains at its current floor with its doors closed.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.