What is a class diagram
- Static diagram
- Shows what classes of objects are required (NO
interaction, NOimplementation)- Document 2 types of data
- Processing requirement -- how we process things
- Data storage requirement -- what data are we going to store
- Objects must be identifiable -- Object reference: one unique attribute for each object (e.g. SSN)
Class Symbol


Relationship
- Association: same as the Things association.

- Generalization/specialization: "is-a" relationship
- Enables inheritance of attributes and methods
- Aggregation: "has-a" relationship
Association Class
A class attached to an association
Data belongs to the association (but not to either of the classes involved)
Represented by a dotted line

Generalization/Specialization (Inheritance)
- Generalization: Groups similar types of classes that share characteristics such as attributes, associations, or methods
- Superclass can act as abstract class -- does not have any corresponding objects
- Concrete class inherit superclass characteristics -- can have real objects.
- Generalization encourages reuse
- Specialization: subclass existing classes, inherit parent characteristics

- Savings Account has 4 attributes and 3 methods (including those from the super class)
- Checking Account has 5 attributes and 2 methods (including those from the super class)
Multiple Inheritance
A class that inherit from more than 1 superclass
Total attribute comes from both superclasses.
Aggregation (Whole/part)
- Represented by a diamond symbol
- Definition: whole-part relationship between the aggregate (whole) and its components (parts), where the parts can exist separately

** processor, monitors, etc. are all parts of a computer
*** NOTE: all computer parts can exist without being a part of a computer
Composition
- Represented by a solid diamond symbol
- Definition: aggregation relationship but the parts CANNOT exist separately

** Here BoatHull is part of a BoatAssembly but it cannot exist on its own.
Methods
- Standard methods:
- Create (a new object of this class)
- Delete (a existing object of this class)
- Get (attributes of the object)
- Set (attributes of the object)
- Custom methods:
- e.g. students -- pay tuition
Question
- Practice Exam Q46 -- What is the term that describes the number of times that an object can participate in a relationship? -- ______
1万+

被折叠的 条评论
为什么被折叠?



