Skip to main content

Force implementation of an interface to use a function, to enable functionality that's transparent to the user

I am the designer of an interface IModel, which will be used by the implementer of a the controller (MVC). The interface contains funcA(). Another programmer needs to implement a specific class for the IModel.

I want to direct the implementation of funcA() to use another function, funcB(). This forces some functionality of the specific model class to be transparent. For example, the interface contains openFile(), but the specific class must contain the transparent functionality of encrypting the file.

What is better?

  1. Defining two interfaces: I1 for the controller side, and another one, I2, for those who implement the model class, where I2 extends I1.
  2. My own implementation of an abstract class like AbsModel which implements Imodel and contains abstract functions.