php - I'm confused, what is the TRUE way to build an MVC or MVVM design pattern? -


so i've been looking more tutorials , articles mvc design pattern deepen understanding of them , i'm starting doubt if have been doing wrong. yeah goal of patterns make code reusable , minimize repeated code, correct?

i've been seeing various ways of how design patterns explained confusing me bit. in past thought controller-as-a-mediator-between-model-and-view way, i'm learning that wrong , view more template. read somewhere (i think here) in true mvc pattern, there definition 1 model , other "models" different facets of single model. case? best way separate code , make reusable? how in code? , again somewhere else read web-applications better stick mvvm pattern.

so i'm bit confused. effective pattern separate concerns in web-application , make code reusable? prefer not see description of pattern, short example in code understand better.

so yeah goal of patterns make code reusable , minimize repeated code, correct?

is best way separate code , make reusable?

nope. isn't.

the goal in mvc , mvc-inspired patterns isolate business logic (model layer) user interface. , within ui - divide managing input , output.

basically, mvc , mvc-inspired patterns arcitectural design patterns implement principle know separation of concerns.

then read somewhere (i think here) in true mvc pattern, there definition 1 model , other "models" different facets of single model. case?

no. model not "thing" (class, object). layer. same way of controllers , views contained in presentation layer or ui layer.

what people refer "models" either domain objects or (much worse case) form of active record implementation.

and again somewhere else read web-applications better stick mvvm pattern.

mvvm pattern add layer between views , model layer. it's best used situations, when either cannot controller implementation of views or/and model layer.

most of people confuse use of presentation object (m.fowler has nasty habit of adding "model" everything, create boundless confusions) concept. presentation objects meant isolate reusable parts of ui logic.

how in code?

mvc , mvc-inspired patterns created manage large codebases. apply mvc patter when simple use of object oriented practices not enough make code understandable. adding additional constraints codebase. mvc not add new application. instead restricts , code can written.

and "sort code example" not illustrate pattern. understand, how works, should read poeaa book .. or similar.

what effective pattern separate concerns in web-application , make code reusable?

it's matter of opinion.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -