Hot answers tagged architecture
A common approach is to have a component-based approach where the base-class "Unit" just implements the most basic aspects all units have in common, while each unit then has a list of multiple component-objects which say what it can do and how it does it. For example, a tank might have the components Mobile, Destructible, Attacker, an immobile turret only ...
A lot of games use a component-based system for entities which is where a bunch of behaviours and abilities can be added to a more generic unit type rather than being coded as part of the entity's class (or equivalent).
The typical approach one - and the one taken to an extreme end by the "ECS" pattern that's hyped these days - is to have your module itself manage the components. That is, UIModule shouldn't have to iterate through the scene to find all UIComponent instances. Instead, the module should just have a list of the components it cares about. It can easily then ...
Only top voted, non community-wiki answers of a minimum length are eligible