MVC: Are Models and Entity objects separate concepts? -
i asked here while ago in understanding mvc, since i'm new topic. thought had decent understanding of it, , documented in blog post wrote on subject. understanding boils down this:
controller: determines needs done fulfill request, , utilizes whatever models needs collect/modify needed. it's manager given process.
views: presentation only. once controller collects needs, creates specific type of view, hands information, , says "show user it."
models: behavior of application. when controller asks extract or modify something, knows how it. knows trigger other models related tasks (in understanding, when model tries "vote something" on stackoverflow, model knows ask if badge should granted because of it. controller doesn't need care that).
my question, assuming of more or less accurate, entity objects come in? models , entities same thing, each object knowing how persist own data, or entities separate concept exist on own , used throughout application?
my money on latter, since allow models act independently, while 3 layers (model, view , controller) utilize entities pass data around needed. also, objects , database persistence seem concerns should separated.
to honest, more read mvc more confused get. i'm ready take core concept (separate presentation logic) , run in whatever way feels right, , not worry "mvc" label.
yes!
my money on latter, since allow models act independently
you don't want bind view entity, because if view needs other piece of data, have entity. model entirely supportive of view, , concerned supporting view , nothing else.
for example, show list of entities, other data might need? current page number? total number of pages? custom message displayed?
this why should bind model, can freely add data items need to.
update
here explanation of mvc in action...
the controller gets of data required request , puts model. passes model view.
the view deals layout of data in model.
Comments
Post a Comment