Welcome Guest, Not a member yet? Register   Sign In
Models, where, when and why?
#2

(This post was last modified: 10-24-2014, 02:40 AM by Rufnex.)

In most of our programms, the model is that what your appliction is. On database driven applications it is the data from the db in other way the filesystem or the memory. Models should/could also used for logic stuff like filtering, calculation, data validations etc. and the controller gets only the maintained data back.

E.g. if you have some calculation stuff you calculation the output inside the model and route it to the controller. No the calculation logic should be changed you only have to change the logic inside the model.

So for me the model for that design pattern is a layer between the application and the data and always god practice to get your code maintable.

BTW: I think this was the first paper to MVC : http://heim.ifi.uio.no/~trygver/themes/m...index.html

(10-24-2014, 12:03 AM)Thyrosis Wrote: Does that mean that I should have a Model and a library for the same blogpost? So that my Controller creates an object from a library, and that library loads the corresponding Model? Then the library calls upon the Model to get the data from the database, which is then stored in the library-object, which is used by the Controller to pass through to the View? Doesn't that mean double work, having to create nearly identical versions of a blog-post, both as a Model and a library?

In your case i think it depends on your taste. in the blogpost example you can do all of the logic with controller methods, than of course with the model. If i program a library (class) for some stuff i would design it with all of the needed logic and dependences even the datastuff (file, db, etc.) so no models are needed.

So you dont have to use M in MVC but its the goal of this pattern .... and every pattern is only a proposal. But if you use one you should work with it as it is scheduled, so other programmers can easy work with it.

Reply


Messages In This Thread
Models, where, when and why? - by Thyrosis - 10-24-2014, 12:03 AM
RE: Models, where, when and why? - by Rufnex - 10-24-2014, 02:39 AM
RE: Models, where, when and why? - by navotjer - 10-24-2014, 04:10 AM
RE: Models, where, when and why? - by InsiteFX - 10-24-2014, 04:44 AM
RE: Models, where, when and why? - by kilishan - 10-24-2014, 08:17 AM
RE: Models, where, when and why? - by Thyrosis - 10-25-2014, 02:16 AM
RE: Models, where, when and why? - by John_Betong - 10-24-2014, 10:04 AM
RE: Models, where, when and why? - by Hobbes - 10-29-2014, 06:41 AM
RE: Models, where, when and why? - by jlp - 10-29-2014, 08:50 PM
RE: Models, where, when and why? - by albertleao - 10-30-2014, 11:41 AM
RE: Models, where, when and why? - by InsiteFX - 10-30-2014, 04:28 PM
RE: Models, where, when and why? - by Thyrosis - 11-01-2014, 01:27 AM
RE: Models, where, when and why? - by alroker - 11-16-2014, 11:55 AM
RE: Models, where, when and why? - by Thyrosis - 11-18-2014, 05:51 AM
RE: Models, where, when and why? - by RobertSF - 11-20-2014, 08:19 PM
RE: Models, where, when and why? - by veedeoo - 11-17-2014, 09:04 PM
RE: Models, where, when and why? - by bclinton - 11-17-2014, 09:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB