Unit 2: Class Modeling
Object and Class Concepts
Introduction to Class Modeling
• Class modeling describes the static structure
of a system
• Shows classes, objects, and their relationships
• Forms the foundation of Object-Oriented
Design
Objects
• Object is an instance of a class
• Represents a real-world entity
• Has:
– Identity
– State (attributes)
– Behavior (methods)
Classes
• Class is a blueprint for creating objects
• Defines:
– Attributes (data)
– Operations (functions)
• Multiple objects can be created from one class
Relationship Between Object and Class
• Class defines structure and behavior
• Object represents actual entity at runtime
• Example:
– Class: Student
– Object: Student1, Student2
Class Diagrams
• Graphical representation of classes
• Shows:
– Class name
– Attributes
– Methods
• Also displays relationships between classes
Values and Attributes
• Attribute:
– Property of a class
• Value:
– Data stored in an attribute
• Example:
– Attribute: marks
– Value: 85
Operations and Methods
• Operation:
– Declared function in a class
• Method:
– Implementation of operation
• Defines object behavior
Links and Associations
• Link:
– Connection between objects
• Association:
– Relationship between classes
• Shows how classes interact
Multiplicity
• Specifies number of objects in an association
• Common multiplicities:
– 1
– 0..1
– 1..*
– 0..*
Association Names and Ordering
• Association name:
– Describes meaning of relationship
• Ordering:
– Sequence of associated objects
• Improves clarity of model
Association Classes
• Used when association has its own attributes
• Combines class and association
• Example:
– Student — Course
– Association class: Enrollment
Qualified Association
• Uses a qualifier to reduce multiplicity
• Acts like a key
• Example:
– Bank → Account (accountNumber)
Generalization and Inheritance
• Represents IS-A relationship
• Child class inherits attributes and methods
• Example:
– Person → Student, Teacher
Use of Generalization & Sample Class Model
• Promotes:
– Reusability
– Extensibility
• Parent class contains common features
• Child classes contain specialized features
Thank You

Unit 2_Class Modeling(objects and class concepts).pptx

  • 1.
    Unit 2: ClassModeling Object and Class Concepts
  • 2.
    Introduction to ClassModeling • Class modeling describes the static structure of a system • Shows classes, objects, and their relationships • Forms the foundation of Object-Oriented Design
  • 3.
    Objects • Object isan instance of a class • Represents a real-world entity • Has: – Identity – State (attributes) – Behavior (methods)
  • 4.
    Classes • Class isa blueprint for creating objects • Defines: – Attributes (data) – Operations (functions) • Multiple objects can be created from one class
  • 5.
    Relationship Between Objectand Class • Class defines structure and behavior • Object represents actual entity at runtime • Example: – Class: Student – Object: Student1, Student2
  • 6.
    Class Diagrams • Graphicalrepresentation of classes • Shows: – Class name – Attributes – Methods • Also displays relationships between classes
  • 7.
    Values and Attributes •Attribute: – Property of a class • Value: – Data stored in an attribute • Example: – Attribute: marks – Value: 85
  • 8.
    Operations and Methods •Operation: – Declared function in a class • Method: – Implementation of operation • Defines object behavior
  • 9.
    Links and Associations •Link: – Connection between objects • Association: – Relationship between classes • Shows how classes interact
  • 10.
    Multiplicity • Specifies numberof objects in an association • Common multiplicities: – 1 – 0..1 – 1..* – 0..*
  • 11.
    Association Names andOrdering • Association name: – Describes meaning of relationship • Ordering: – Sequence of associated objects • Improves clarity of model
  • 12.
    Association Classes • Usedwhen association has its own attributes • Combines class and association • Example: – Student — Course – Association class: Enrollment
  • 13.
    Qualified Association • Usesa qualifier to reduce multiplicity • Acts like a key • Example: – Bank → Account (accountNumber)
  • 14.
    Generalization and Inheritance •Represents IS-A relationship • Child class inherits attributes and methods • Example: – Person → Student, Teacher
  • 15.
    Use of Generalization& Sample Class Model • Promotes: – Reusability – Extensibility • Parent class contains common features • Child classes contain specialized features
  • 16.