1/15
Looks like no tags are added yet.
Object Relationships
Describe how two or more objects are connected or interact with one another in an object-oriented program. They determine how objects use, contain, or inherit characteristics from other objects.
Association
It is known as a "Has-a" relationship because one object has or uses another object. relationship between two objects where one object uses another object, or both objects use each other.
Inheritance
It is known as an "Is-a" relationship because one object belongs to a more general category. A relationship where one class is a more specific version of another class.
Has-a Relationship
Association
Composition
Aggregation
Types of Association.
Composition
A strong ownership relationship where one object depends on the existence of another object. The dependent object is considered part of the owner, and its lifecycle is tied to that owner.
Aggregation
A weak or loose association between two independent objects. Both objects can exist separately, even when their relationship ends.
Object Lifecycle
Refers to the period during which an object exists, from its creation until it is no longer part of the program's object model. It helps determine whether a relationship should be classified as composition or aggregation.
Dependent Object
An object whose existence or usefulness depends on another object in a composition relationship.
Independent Object
An object that can exist and function without depending on another object.
Object Reusability
The ability of an object to be used or referenced in another relationship.
Field Created Inside the Owner's Constructor
A common Java implementation of composition. The owning class creates the dependent object as part of its initialization, suggesting that the owner controls the object's lifecycle.
Field Passed from Outside
A common Java implementation of aggregation. An existing object is passed into another class through a constructor or method, allowing both objects to exist independently.
Object Reference
A way for one object to refer to another object without necessarily owning it. In aggregation, objects are commonly connected through references. Example: A Teacher object can hold references to Student objects.
No
Can the related object still exist independently when the relationship ends in composistion?
Yes
Can the related object still exist independently when the relationship ends in Aggregation?