Let's say I have class Veiculo
and class Fabricante
. Each vehicle has a manufacturer as an attribute, among other attributes.
I have the views to keep (register, edit and delete) and fetch vehicle and also manufacturer.
Each model class has its controller (I decided to create 1 control per model, instead of creating a control by view ). That is, the controlVeiculo
class will be accessed by more than one view and will have
+listarVeiculos()
+salvarVeiculo(Veiculo v)
+editarVeiculo(Veiculo v)
+excluirVeiculo(Veiculo v)
(...)
Which in turn accesses the DAO classes. As well as the controlFabricante
class will have the same methods for manufacturer.
When I call view to register vehicle, for example, I will need to list the manufacturers already registered in the bank for the user's choice. This list of manufacturers should come from where?
- I create an instance of
controlFabricante
withinviewVeiculo
and call the method normally? - I leave my
viewVeiculo
only by accessing your control (controlVeiculo
) and I create a method incontrolVeículo
to accessDAOFabricante
? - I leave my
viewVeiculo
only by accessing its control (controlVeiculo
) and, instead of creating a method incontrolVeículo
, I create an instance ofcontrolFabricante
withincontrolVeiculo
and call the method between the controllers (since it already has a method defined in the other control, avoiding duplicate methods) - Any other suggestions?