3
Personally, I’m kind of having a conceptual doubt.
I started implementing my application (c# - Forms) thinking of following development based on the MVC architecture. But intuitively - and I don’t know if conceptually correct - I ended up making the following division (I put the picture of the class diagram to facilitate):
Class 'formulaPrincipal': responsible for displaying the data and notifying user events and actions in the system interface for the class 'tree Cont'.
'Cont tree 'class: takes form requests, asks database for data by class persistence, applies business rules and returns to view.
Class persistence: makes all communication with the bank for inclusion, alteration, deletion and consultation of data (with filters where
).
'no', 'data' and 'transaction' classes that represent the application objects that are often used to pass data to the interface.
I do not know if conceptually I can consider that I used the MVC, even because, from what I read, the class persistence should be together with the classes that represent the objects. But, for me, it makes sense to separate.
And what I initially treated as controller ('tree Cont' class) has ended up responsible for the centralization of much of the business rule.
Can I say, based on this structure, what MVC use? The initial intention was to use, but in the end, I don’t know if I made it. What do you think?
Do you only have one view? Or do your views extend
formularioPrincipal
?– bfavaretto
I have several views, which represent the forms displayed to the user. I’m only displaying a "piece" so it doesn’t get too much. But the operation for the other views is similar. It interacts with a controler, which in turn interacts with persistence. They do not extend the main form.
– Marcos Freitas
I wouldn’t say it’s MVC if the controller has a business rule - it should have as many app rules as possible.
– Caffé
What you consider as 'application rules'?
– Marcos Freitas
Example of application rule: the user requests a customer list, the application knows which model and select view to send to the user - this is an application rule. So application rules are the navigation flow in the system, access permissions, log management, knowledge of what business rules to trigger to meet user requests... (Obs: when addressing someone, do it through their name with a @ in front, so the user is notified of their message).
– Caffé
@Caffé, thank you for the answers. I understood what you put... So, as I had imagined I ended up not using an architecture "standard"... :( The correct thing would be to move all the business rules to the model entities, namely, class: "Node", "Data Function" and "Transaction Function". Right? It would be 'right' within the MVC to create another hard-core class that would either center access to the bank, or should also be in a single class with business rules - in the model.? Thank you
– Marcos Freitas
MVC is a Pattern presentation design, it does not determine the responsibility of persistence (it just knows that it is not his responsibility). In any case, the more separate the responsibilities are, in all layers, the better - that is, separate the persistence of the business rules at will.
– Caffé
@Caffé, of course. Thank you!
– Marcos Freitas