📘 Class Models (OOAD)
🔹 1. Definition
A Class Model is a static representation of a system that shows:
- Classes
- Attributes (data)
- Methods (functions)
- Relationships between classes
👉 Simple idea:
It describes the structure of the system (what it is made of), not how it behaves.
🔹 2. What is a Class?
A class is a blueprint for creating objects.
Example:
Class: Student
- name
- rollNo
+ study()
+ attendClass()
🔹 3. Components of a Class Model
🔸 3.1 Class
Represented as a rectangle divided into 3 parts:
-----------------
| Class Name |
-----------------
| Attributes |
-----------------
| Methods |
-----------------
🔸 3.2 Attributes
- Properties of a class
- Represented as variables
Example:
🔸 3.3 Methods (Operations)
- Functions that define behavior
Example:
🔹 4. Relationships in Class Models ⭐
🔸 4.1 Association
Definition:
A general relationship between two classes.
Example:
Teacher —— Student
👉 A teacher teaches students
🔸 4.2 Multiplicity
Shows how many objects are involved.
| Notation |
Meaning |
| 1 |
One |
| 0..1 |
Zero or one |
| 1..* |
One or many |
| * |
Many |
🔸 4.3 Aggregation
Definition:
A weak “has-a” relationship (part can exist independently).
Example:
Classroom ◇—— Student
👉 Students can exist without classroom
🔸 4.4 Composition
Definition:
A strong “has-a” relationship (part cannot exist independently).
Example:
House ◆—— Room
👉 Room cannot exist without house
🔸 4.5 Inheritance (Generalization)
Definition:
One class inherits from another.
Example:
Vehicle
↑
Car
🔸 4.6 Dependency
Definition:
One class depends on another temporarily.
🔹 5. Types of Class Models
🔸 5.1 Conceptual Class Model
- High-level
- No implementation details
🔸 5.2 Design Class Model
- Detailed
- Includes methods and data types
🔸 5.3 Implementation Class Model
🔹 6. Steps to Create a Class Model
🔹 Step 1: Identify Classes
- Find nouns in problem statement
🔹 Step 2: Define Attributes
🔹 Step 3: Define Methods
🔹 Step 4: Establish Relationships
- Association, inheritance, etc.
🔹 Step 5: Add Multiplicity
- Define how many objects relate
🔹 7. Example (Library System)
🔹 Classes:
🔹 Class Diagram:
Book
- title
- author
+ issue()
Member
- name
+ borrow()
Relationship:
Member —— borrows —— Book
🔹 8. Advantages of Class Models
- Clear system structure
- Easy to understand
- Supports code development
- Helps in maintenance
🔹 9. Important Rules / Guidelines
- Keep classes simple and meaningful
- Avoid too many attributes
- Use proper relationships
- Maintain high cohesion & low coupling
🔹 10. Likely Exam Questions
- Define class model.
- Explain components of a class diagram.
- What is association? Explain with example.
- Difference between aggregation and composition.
- Explain inheritance in class models.
- What is multiplicity?
- Steps to create a class model.
- Types of class models.
- Draw a class diagram for a simple system.
- Advantages of class modeling.
🔹 11. Quick Revision Summary 🧠
Key Relationships:
- Association
- Aggregation
- Composition
- Inheritance
👉 Trick:
"CAAMID"
(C → Class, A → Attributes, A → Association, M → Methods, I → Inheritance, D → Dependency)