educative.io

Extend behaviour in Admin, UMpire and Referee

Thinking y these doesn’t extend person?

Admin is a person or Admin has a person?

Checked previous posts, usually actors extends the person class.


Course: Grokking the Object Oriented Design Interview - Learn Interactively
Lesson: Design Cricinfo - Grokking the Object Oriented Design Interview

Hi @Ayush_Gupta
The person class has attributes of the name, address, email, and phone number. The classes Admin, Player, Umpire, Referee, and Commentator represent the different people that interact with our system that’s why these classes take the person attributes (name, address, email, and phone number) from the person class as their private data member/attribute.
private Person person;
So, don’t need to extend the person.
Hope it will help :blush:.

How is this behaviour different from other examples, where it extends?


Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers

@Ayush_Gupta
Here the aggregation (has a relationship) concept is used. It is a type of association. If in a process, one class defines another class as any entity reference then it is known as Aggregation. With the help of aggregation, you can also reuse the class. We do not inherit the class that’s why it doesn’t extend.
Thank you