in java,
What are the two major security issues with aggregation and how are these issues avoided?
Aggregation is used in Java for code reusability. HAS-A relationship between classes is represented by aggregation.
Issues:
1. There is extra code to be written in the first place, which takes more effort. It is also harder to understand the behaviour of the system. The interaction of the system is less at compile time and more at run time.
2. There are more number of objects than usual while you have to implement object composition.
How to avoid?
Object composition can be done where one or more objects are combined to create a new object.
Since, it has a "HAS-A" relationship, which is better than Inhertitance as it has a "IS-A" relationship between classes.
Thus, Aggregation is more sematically correct than Inheritance.
Get Answers For Free
Most questions answered within 1 hours.