I am developing COM. A factory need to be initialized first by providing a ID. I can not pass arguments to IFactory instance via CoCreateInstance. So IFactory may need add a init method to be called then. (as approach 2)I don't want to require client to call init explicitly (they may forget). So that I add a layer named IEntryPoint. This ensures GetFactory will return a verified IFactory without called init first. Then the IFactory instance will not have the state denoted it is valid or invalid. All its methods can be const. (as approach 1)Is it over encapsulated if IEntryPoint only has GetFactory method?Approach 1: IEntryPoint::GetFactory ensures IFactory instance is valid if S_OK is returned.interface IEntryPoint{    HRESULT GetFactory(size_t id, IFactory** ppFactory) const;};interface IFactory{    HRESULT GetInstance(size_t id, IInstance** ppInstance) const;};interface IInstance{    HRESULT Getter1() const;    HRESULT Getter2() const;    HRESULT Getter3() const;};vsApproach 2: IFactory instance requires client to call init first.interface IFactory{    HRESULT Init(size_t id);    HRESULT GetInstance(size_t id, IInstance** ppInstance) const;};interface IInstance{    HRESULT Getter1() const;    HRESULT Getter2() const;    HRESULT Getter3() const;};
Should I add a layer to keep object always valid and immutable?
c++;validation;immutability