abstract methods of the same signature

0

Hello, I'm building for my college work a WebService based on MVC architecture. For a better understanding of the problem I will explain a little how the classes are currently:

  • The abstract class Model has as one of the abstract methods the getTableName that returns the actual table name for the model.
  • This class uses trait DML .
  • Trait DML depends on the getTableName method to tell the table the select, insert, update, and delete functions.

My problem is that it is not possible to define the getTableName method as abstract in trait and in the class that uses trait and do not want to be dependent on trait DML for this method to be abstract.

In short: I need the getTableName method to be abstract in trait because it needs it, but if the class that uses trait also needs this method to be abstract what can be done?

    
asked by anonymous 27.10.2015 / 12:57

1 answer

1

If both the class and the trait need the same method, the error lies in the modeling design, since trait is a horizontal inheritance.

You need to evaluate your model and define where you stand and see why there is a need for each one to have this same method.

If you do not need both, just set the method owner.

Another suggestion would be to implement a base class that has these characteristics.

    
27.10.2015 / 13:37