Is it correct to implement two or more interfaces in the same class in POO?

0

Currently I want to start a project that will scale in the future to an extent that I do not know, so I would like to know if this is the correct way to apply interfaces in the classes

Form (By method):

Generate an interface for each standard method that is carried out as for example (Listings, repetitive CRUDS, Search, etc.).

 VerListado - interfaceListado
CRUD - interfaceCRUD
Busqueda - interfaceBusqueda

The way to implement the interfaces by means of this form would be as follows:

public class Prueba implements interfaceBusqueda, interfaceCRUD  {

}
    
asked by David 21.01.2018 в 22:35
source

1 answer

1

It is entirely correct to associate one or many interfaces with a class. Depending on the design. It should be noted that the interfaces are to define families of common behaviors, so if you have more than one class with that same set of behaviors it is logical that you use them.

I advise you not to look ahead and if you worry that the classes you do today have solid foundations with respect to which they are of a particular nature (do not have many responsibilities), and that have their behaviors well defined. Also if you do unit tests much better.

This is important so that, when the need to extend the system arrives, you can do it with the least possible impact. Do not over design your solution, make the minimum code possible to meet the requirements, and do it in the best way possible.

Greetings and luck

    
answered by 22.01.2018 / 20:52
source