I am trying to understand if there are best practices around than the one below.
So in our project we had created an interface IForm
like below:
class IForm {
protected:
IForm() {}
public:
virtual ~IForm() {}
virtual const std::string& GetId() const = 0;
virtual const std::string& GetTitle() const = 0;
virtual void SetTitle(const std::string& title) = 0;
virtual void SetFormError(const std::string& error_text) = 0;
virtual void ClearFormError() = 0;
};
And then the requirement came to have more functions and therefore we created new interface IForm2
:
class IForm2: public IForm {
protected:
IForm2() = default;
public:
virtual ~IForm2() = default;
virtual void RemoveWidget(const std::string &id) = 0;
virtual void Clear() = 0;
};
My question is:
Is there a way around this ? Instead of adding new interface, is there some design pattern that I can use to implement newer requirements rather than adding newer interfaces?
I know the above method works fine. I am just looking for alternatives to implement functionalities.