Default MVC and DAO

3

I have a layered system.

I'm using MVC and inside the MODEL folder I have a DAO folder. Let's say I have a file named Professor_DAY and another called Aluno_DAO.

Question: Can I include the student file in Teacher to call any method present in this? Would that break the pattern?

    
asked by anonymous 30.06.2018 / 00:05

1 answer

4
  

Can I include the student file in teacher to call any method present in this? Would that break the pattern?

Yes you can, this does not break the MVC standard. The MVC standard tells you just how the model, view, and controller layers should communicate. However, Aluno and Professor are objects that are both within the model layer, and therefore the MVC pattern is not broken by an interaction between them. In fact, it is quite common for several classes within the model layer to interact with each other and there is no problem at all.

Regarding DAO, if you are not breaking the rule that Aluno_DAO contains persistence methods of Aluno and that Professor_DAO contains persistence methods of Professor , that's fine. It is allowed that Aluno_DAO may need to know something of Professor or that Professor_DAO may need to know something of Aluno , since one does not end up worrying about the persistence of what should be on the other.     

30.06.2018 / 00:17