componentsystem icon indicating copy to clipboard operation
componentsystem copied to clipboard

when is IInterface necessary?

Open xbaosong opened this issue 2 years ago • 1 comments

I have a question regarding the necessity of class IInterface. As mentioned in the doc, all objects must implement IInterface, but on the other hand, all components must also implement IComponent. So, doesn't it make more sense to let IComponent inherite from IInterface? Therefore simpler to just merge IInterface into IComponent?

Ps: I looked into the project pingnoo, seems IInterface is not used anyway.

xbaosong avatar Apr 02 '23 05:04 xbaosong

As per the comment and also written in the README.md file it's for adding future functionality system wide.

By having IInterface you have a common base defined for every object in the component system.

With IInterface being the root object it is very easy to add new common behaviour across all objects, not just components, conversely if IInterface doesn't exist then it would be considerably more effort to do it.

It doesn't add any complexity to anything.

If you remove IInterface from IComponent then you break the common ancestor for all objects inside the component system.

    /**
     * @brief       The IInterface class is the root level object for all objects.
     *
     * @details     All objects that reside in the component system should inherit this interface for future
     *              compatibility.
     *
     * @class       Nedrysoft::ComponentSystem::IInterface IInterface.h <IInterface>
     */

fizzyade avatar Apr 02 '23 09:04 fizzyade