You are here

Ballworld, composition-based

15 January, 2016 - 09:02
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/402b20ad-c01f-45f1-9743-05eadb1f710e@37.6

This content is available online.

In this module we will explore what is gained by modifying the inheritance-based Ballworld system (***Section 2.2***) into a composition-based system.

In the inheritance-based Ballworld system, we were able to generate quite a bit of flexibility and extensi bility. For instance, we could develop new kinds of balls and add them into the system without recompiling the rest of the code. This was accomplished by having the invariant ball creation and management code deal only with the abstract ball while the variant behaviors were encapsulated into the concrete subclasses.