educative.io

Admin , Account composition

Admin and Account classes are shown using composition.
Account can exist without Admin class right?
Rather it should be Admin and Account classes use Aggregation?

Hi @sivarama_sarma, u asked a very valid question because many of us face the same confusion while studying the Has-A relationship (association, aggregation & composition).
The described system of Amazon - Online Shopping shows the Admin-Account with composition because Admin has an account that stores the information of that particular Admin object, in case of deleting that admin his account info will also be erased. In that perspective, the Account has to be composed within that Admin object.
Note: The selection composition or aggregation is actually based on the requirement of the system (whether u want to save info after the deletion or not).