09-18-2019 08:04 AM
@cbutcher wrote:
For ease of clicking, the link above should probably be this one: thols' link (What are the advantages of Composition and Aggregation over Inheritance?)
Interesting that the article conflicts itself:
In the end, I think just having the right relationship is what matters most (is a = inheritance, has a = composition). Anything in the middle is a nightmare waiting to happen.
09-18-2019 10:09 AM - edited 09-18-2019 10:10 AM
I'd guess the suggestion is that a class is a template for objects whilst an object is an instantiation of a class.
If you have lots of objects as private data members of your class, you can conceivably imagine a situation in which the number of objects rises even as the number of classes falls (particularly if you would otherwise have multiple levels of inheritance leading to significant numbers of "abstract" or abstract-like classes that are never instantiated (either as a language limitation/constraint, or just practically as in LabVIEW)).
Despite the above paragraph (seemingly defending the article) I still wouldn't necessarily say I think it's stunningly well written or overly insightful. Without some knowledge of the author I'd be tempted to point out that (like for example, all of my posts in this thread, more or less) the author is just rehashing what others have already said/written elsewhere in a less convincing fashion.
I quite like the first 3 summary points, which give an overview of the comparison. I'm not sure the 4th is really supported by the article contents, even if it might be true (in some cases).
09-18-2019 10:43 AM
@crossrulz wrote:
@cbutcher wrote:
For ease of clicking, the link above should probably be this one: thols' link (What are the advantages of Composition and Aggregation over Inheritance?)
Interesting that the article conflicts itself:
Advantages of object composition and aggregation over inheritance
- A design based on object composition usually will have less classes.
Downsides of composition and aggregation are:
- A design based on object composition usually will have more objects.
In the end, I think just having the right relationship is what matters most (is a = inheritance, has a = composition). Anything in the middle is a nightmare waiting to happen.
Those are not conflicting statements. A class != object. The class is the definition/description. An object is a concrete instance of a class.
09-18-2019 12:12 PM
@Mark_Yedinak wrote:
Those are not conflicting statements. A class != object. The class is the definition/description. An object is a concrete instance of a class.
Yeah, I misread it this morning. Too many other things happening.