This is the question I realized at a little strange at some point that is not authentic implementation of ASP.NET MVC MVC pattern. Or I did not understand this.
Consider the following domains: Power Bulb , Switch and Speed Detector . They are connected together and when you enter the room motion detector, the switch is on the bulb. If I want to represent them as MVC:
- The switch model is because it holds the state and holds the argument
- The bulb view is because this model present situation does
- motion detector controller, because this general model user model that converts commands
a private field in switch (on / off ) Is in a state and two ways (pressone, pressoff ). If you press it, then when you press it, you call, so if you call it, the state is not changing.
The bulb can be replaced by the speed detector with a buzzer, timer or button, but the same logic that the model still represents is ultimately the behavior of the system.
Similarly, I consider classical MVC decomposition, please correct me if I am wrong.
Now dismantle it in the ISPNET MVC route.
- The bulb is still a view
- The controller will switch + the speed detector
- The model is something that will just rule the bulb.
So runs in the controller defines logic
Question 1: What MVC and ASP. My understanding of NET MVC right ?
Question 2: If yes, do you agree that ASP.NET MVC is not 100% correct implementation?
And the last question in life is the question of how to separate the model from the controller in the case of ASP.NET MVC. There can be two extremes, the controller uses the basic stuff and the call model to make all the arguments; another controller makes all the arguments and models, like a class with properties like something that is mapped to DB
Question 3: Where should I draw the line between this extreme? How to balance?
Thank you, Andree
I think it can be done both ways . There will be an implementation of an ASP.NET MVC which puts the logic like you in your first example.
Model (respository)
switchOn () as if the bulb! The Bulb.lightOn so bulb.lightOn = True End If Return bulb end function function Svichof () Blbklait then as bulbs Blbklaiton = False End if returns bulb end function realization as function Motion (bullion) (bulb Perception) (If, of course, the eSharemation and the bulb.LiteOn) then the bulb. LightOn = true end return bulb termination function
Controller
function Return screen ("Bulb "light repository. switchOn) end function PressSwitchOff () ActionResult return as the scene (" bulbs ", lightRepository.switchOff) end function function ActionResult return view (" bulbs ", lightRepository.Motion (hasMoved)) end function Any business logic in my controller, this bus Ajy model is going to V iew.
Yes, I think that you understand it very well No, I do not agree. One of the benefits of ASP.NET MVC is that it is extremely flexible in your implementation. If you really wanted, then you can put all your logic in your view (why, oh, why do you want to do this), but You have the option. I think the lines drag, keeping in mind the dry principles that you have arguments have been repeated several times, make sure that no part of the model or a custom line of business that you refer to a location can do. I'm one of the main driving principles of preparing an MVC app.
Comments
Post a Comment