4
In a CRUD where at the time of registration it is necessary to verify if a certain field already exists in the bank, in order not to allow duplicate registration, this rule of verification must be in the DAO class (Exception
if it exists in the act of registration) or Controller (consult via DAO which returns true
or false before registration)?
But it turns out that all registrations are in the bank, not in Model. Model represents a single tuple..
– R. Carvalho
Because the way I did, Controll talks to DAO and Model. and not Model talks to DAO.
– R. Carvalho
What even generated this doubt, both with me and with other friends , if who talks with DAO is Model or Controll.. because a teacher uses one way and another way!
– R. Carvalho
You would need to put it as it is done. The template is to be a representation of what is in DB. I don’t think it’s right (but there are people who think), so if it’s wrong, it makes little difference to me who does what. Sure you can do that and be right, but I don’t know, I haven’t seen anything like it.
– Maniero
But for that to be in Model I would have to define that the one who communicates with DAO would be Model, right? Because the way I did (I do not know if it is misuse) who sends the object to persistence via DAO is Control and not Model. I mean, Model doesn’t know that DAO exists.
– R. Carvalho
That’s right and wrong depends on context. Just because someone said it does not mean it is one thing or the other. You would have to see the concrete case. Some people do as they say, some people are horrified by it.
– Maniero
But starting from the presupposition of his response and the response of the Gypsy, which it is up to Model to make such control, would be inevitable the relationship of the Model with the DAO, because this would not be possible via Control. Why would Model do such a control knowing that it represents only one instance? (I’m thinking about Java)
– R. Carvalho
In my understanding yes. I think that if the controller talks to the DAO, it is not MVC.
– Maniero