Jump to content

Recommended Posts

Hi all,

 

I'm making the move towards PHP 5 and OOP programming, I've been increasingly interested in MVC patterns and current frameworks available for PHP. Although I've done some general reading on MVC patterns, I've still yet to design my own and don't think I'd really know where to start. I appreciate this probably comes after much experience and I'm looking to start on the right track.

 

At my place of employment i maintain a website and I'm looking to do a new version with OOP (which is still quite new to me) and an MVC framework. I know there are quite a few out there to choose from (Zend, Cake etc), which I'd like to start using, but at the same time I'd like to learn from it too. Most of the sites I've done have been from scratch and I can't use any libraries such as PEAR as I use a shared server and I'm not allowed to install anything on it. It's a little frustrating, cause im sure I keep trying to reinvent the wheel. So I'm wondering..

 

1) What would be the best way to start? Has using ready-made frameworks helped in you understanding and learning of MVC?

 

2) How would using open source libraries 'tie in' to most frameworks? (Hope that makes sense)

 

Ultimately I want to become a better programmer, and also be able to use the current open source stuff thats out there.

 

Link to comment
https://forums.phpfreaks.com/topic/42133-mvc-design-patternsframeworks/
Share on other sites

I can only talk from personal experience, as MVC/OOP (in PHP, at least) are still relatively new to me. When I first starting coding in PHP, I downloaded a copy of phpBB to learn from, as it was pretty much the only obvious php package I knew of back at the time. I remember being confused. Very confused.

 

Last year, I downloaded a copy of Cake and tried to use it. Again, I was extremely confused by it - it introduced many new concepts to me, as I was still used to using dreamweaver's templates and throwing all my PHP code at the top of the page. The whole idea of coding at least 2 or 3 files to render 1 page (Controller, Template and possibly a Model, depending on the nature) just didn't sink in.

 

I had a look at Smarty, as i'd been reading about seperation of business and presentation logic. However, learning a whole new syntax put me off until I found this article: http://www.massassi.com/php/articles/template_engines/ .

 

Once I'd understood the reasons behind seperation, and after playing around with my own little "template engine", I moved on to CodeIgniter (http://www.codeigniter.com ) and found both the source and the manual quite refreshing - and learnt TONNES from it. Not just about OOP practices, but the whole MVC concept relative to what I was doing with template engines. When I then revisited Cake, it was a million times easier to understand. Deciding to code my own framework, I took the best bits from what I picked up from those two and that's pretty much it.

 

the hardest thing I find about these large frameworks is trying to get your head around the "core", as it's very often lost underneath lots and lots of bells and whistles. Also, trying to find out the whole flow, from the beginning when the page has been requested, through to the end where the view is output, can be a little daunting, not to mention time consuming.

 

Another fantastic article helped me jump straight into Cake with a better understanding of what I was supposed to be looking for:

http://www.thinkingphp.org/2006/09/25/learning-from-the-cakephp-source-code-part-i/

 

I'd definitely recommend playing around with BOTH CodeIgniter and Cake (in that order) and taking a good look at their manuals. I have a personal dislike for Zend framework, as I see it as far to bulky, and more of a "best practice showcase" than something I'd like to use for my projects. Having said that, I'm sure there's plenty of little tricks and tips that could be picked up from it.

 

In summary:

1, start with template engines to get your head around basic OOP and seperation of business/presentation logic. at it's simplest, MVC is then only an extra degree of seperation.

2, Play with CodeIgniter/Cake. Both are so similar, they may as well have sprung from the same core, but both have their own quirks. Look at the screencasts too. Worth also looking at the Ruby on Rails screencasts due to the similarities with Cake.

3, Get stuck in to your own!

 

Apologies for the life story, but hope it helps ;)

Cheers

 

Thanks for your very informative reply :)

 

I already use a type of template system (although really just a set of functions to separate the html from the php code and not so much the seperate layers). I never quite thought of it from an MVC perspective until now. I'll try out some other template engines and move on to CodeIgniter/Cake once I get a better idea.

 

Out of interest, have you found what you learned of MVC/OOP in PHP to have helped with programming in other languages too?

 

I havent done any OOP in PHP4 (ive stayed clear of it as I heard its a bit confusing, and not strictly OOP either) and instead I've learned it in PHP5. As most of it has been re-written, I'm a little concerned that using CodeIgniter/Cake would be a little confusing due to its compatibility with PHP4. Presumably if its backwardly compatible, would that mean it would use PHP 4's OOP syntax? If this is the case, perhaps it would be better to stick with frameworks only for PHP 5?

 

Thanks!

to be honest, if you've got a good understanding of OOP on PHP5, you'll find PHP4's OOP quite easy to get your head around. The only real noticable difference is the form that constructors are defined (same name as the class, not __construct) and the scope of vars/function is not specified (public/private/protected, etc) - i believe all the vars and methods are just assumed to be public.

 

I've not strictly moved on to PHP5, just dribs and drabs, as I'm still very aware that most hosts are still set up on PHP4. Cake has some nice tricks up its sleeve to simulate many of the useful features. Either way, don't be put off from visiting these frameworks at all - they're extremely powerful and shouldnt be underestimated because of their support for v4. TBH, I don't see much special about v5 anyway, apart from its 'autoload' function.

 

I don't really do much with other languages these days, so can't really answer that, but I have a "general" approach when it comes to programming anyway, so yeah it probably would. At least for web coding anyway.

 

As for template engines, seriously give the one in the article I mentioned a go (not the bTemplate one he mentions, but the one at the bottom of the page). My own template engine within my framework is based on the ideas in that, and I've just built on it from there.

 

Cheers

i think best way to learn design patterns is to read "Head first design patterns" (o reilly),

a good 600 pages, talking about all kinds of design patterns, their pro's, their contra's, how and when to use them, and so on

code examples are Java tough, but still even without very knowledge of Java very understandable, and very usefull to see what they are actualy talk about

 

 

the big pro on using that book is that its reads quiet fluently, and that they use alot of real-life examples wich makes it alot easier on remembring what to do when you need it

 

patterns they talk about are: strategy, observer, decorator, factory, singleton (very intresting one when using databases!!), command, adapter, facade, template method, iterator, composite, state, proxy

next to that they talk about composite patterns, MVC is one of them, it uses strategy, and observer

and at last there is a chapter about some less important leftover patterns, being: bridge, builder, chan of responsibility, flyweight, interpreter, mediator, memento, prototype & visitor

 

Well im after a week. Ok lets get back to the topic.

Mark said it all.

 

I actually never heard of mvc before i took those frameworks.  And now it seems mvc is the best framework for web. Ya to me. All those other framworks are suitable but basically they for gui app that needs to handle events.MVc is just what a web app is. The db, the script and the html. Just it is called model-controller-view thats it. So this framework really helped me to grasp mvc and now im really not seeing any other pattern so capable as this(i do love singeleton though).

 

Yes u can use external libs easily with cake. just put them in vendor folder and import by changing $vendors var from ur controller.

 

How closely are design patterns linked to OOP?

Design patterns are NOT object oriented programming they are not tools but a writen record of common patterns that appear in code, if you are learning oop the patterns will most likely help you put some things into context quicker than it would otherwise take more experience to put into context.

 

I've not strictly moved on to PHP5, just dribs and drabs, as I'm still very aware that most hosts are still set up on PHP4. Cake has some nice tricks up its sleeve to simulate many of the useful features. Either way, don't be put off from visiting these frameworks at all - they're extremely powerful and shouldnt be underestimated because of their support for v4. TBH, I don't see much special about v5 anyway, apart from its 'autoload' function.

 

Advantages of PHP5's oop vs PHP4

1. its faster

2. its faster

3. abstract\private\public\protected the static keyword too?? I think so (I havent touched php4s oop in over a year but im sure its not in php4)

4. magic methods\overlaoding http://www.php.net/manual/en/language.oop5.overloading.php

5. objects are referenced by default

 

 

If you want to learn oop start by learning php5 dont waste time on php4, php4 should just roll over and die the only reason php4 is doing so good is because php is only a success because of the free scripts and cheap webhosting that exists becuase of these scripts. php has brought forums\blogs to the masses and a lot of these blogs and forums and such were designs in and for php4 because of this the webhosts prefer to run php4. This is no reason to write php4 scripts if you have a choice.

 

to any beginner considering to learn php4 because they think it will be easier keep in mind if you do not understand references you will find php4 more annoying. php5 has more features granted (not enough for my liking) but you do not have to use these features the only ones I think you are forced to use is public\private\protected but if you really wanted you could just replace var with public and and it would work just fine as everything besides attributes default to public

 

Thats interesting. I only recently discovered MVC patterns, I didnt know there were so many different types.

 

Mvc is really really over hyped. When you look at all the frameworks and see their controllers and their directory structure that IS NOT mvc that is an implemention of the concept but it can be done in different ways also yet for some reason when ever people go around moaning about mvc they are referring to the implementation used in all the current frameworks. I find it quite funny how all the frameworks seem to copy each other instead of coming up with new and orignal ideas.

Nameless, I'm going to agree with you on most points.

 

However (yeah there's always a however)

 

1, Overloading is supported by php4, albeit with a little extra with the overload function. CakePHP does PHP5 simulation very well for PHP4, within reason.

2, 'var' (rather than specifically stating public/private/protected, etc) still works on PHP5.

3, PHP5 is much better with OOP, but PLEASE dont just write off php4 as an "entry point" to OOP. remember, like it or not, most are still on v4. I'd prefer to be the chap writing a nice big project without the comebacks along the lines of what version I wrote it in.

4, MVC is over hyped for a particular reason, not to mention it helps prevent you churning out lots of spaghetti shit, by enforcing certain practices. However, I personally use the whole MVC thing very loosely - in that I practice seperation between DB/Logic/Presentation, but break lots of the "rules". Either way, don't ignore the ideas behind MVC, even if the pattern itself doesnt seem useful to you personally.

 

cheers

Mark

I dont ignore mvc, my framework is also mvc I just dont like the fact the words mvc and framework seem to be interchangeable these days. When people say they are thinking of learning mvc they are usually referring to the implementation their fav framework uses that is not learning mvc, that is learning how to use an implementation of mvc when in fact they should be learning the below uml diagram.

http://upload.wikimedia.org/wikipedia/en/7/7c/ModelViewControllerDiagram.png

 

I see where you are coming from when it comes to you advocating php4 and it is bias, we are both bias. But I think the fact php4 requires beginners to have an understanding of references is probably the best and least bias argument for a beginner learning php5 straight up instead of php4.

I dont ignore mvc, my framework is also mvc I just dont like the fact the words mvc and framework seem to be interchangeable these days. When people say they are thinking of learning mvc they are usually referring to the implementation their fav framework uses that is not learning mvc, that is learning how to use an implementation of mvc when in fact they should be learning the below uml diagram.

http://upload.wikimedia.org/wikipedia/en/7/7c/ModelViewControllerDiagram.png

 

I see where you are coming from when it comes to you advocating php4 and it is bias, we are both bias. But I think the fact php4 requires beginners to have an understanding of references is probably the best and least bias argument for a beginner learning php5 straight up instead of php4.

 

I wonder why you have so much Aw with beginners or someone who have not learned your "proper" way?

Trust me, php was really not intended to be an oop language. It is still a form  and database processor and thats it should be. I bet u remember what the manual says about php, It is for building web apps not like perl which was for loads of other purposes and made it "overhould" and php is specifically for webs and web is linear. Php is not event driven like asp.net where u need all those oop.

 

The reason for saying all this is simple. accept the fact that php is not the language that "perfectionist" like u should look at. Its c# that is for you. It is the most secure, strongly typed and most organised of them all.

 

And mvc frameworks?

Why wouldn't people use mvc for frameworks just tell me? Is there any other pattern that can be ported into a "framework" so easily? Yes framework not an application. In an appliation u have the freedom to choose any pattern u want. Not in frameworks. Frameworks need to be easy enough to deployed with little design as well as being "effective" in every sorts of application u can write. Thats what mvc is all about. I really dont see any type of web application that can NOT be implemented with mvc. MVC is really for the web.

I'm thinking of applying Code Igniter for rebuilding a section of a website. It's not feasible to re-do the whole site at the moment (although it would be ideal).

 

I'm not sure how it would link in to the other parts (theres already auth,db and template fuctions), but if I have to do it anyway, why not start with this? Otherwise, I'm just continuing this messy cycle of procedural code and 100s of functions. Or perhaps another way, would be to customise the framework to work with my existing site, and make it backwardly compatible with my old functions and includes and eventually move it to the new classes etc.

 

Or I could just forget about the framework for now, and build new parts using classes in OOP.

 

Opinions?

I wonder why you have so much Aw with beginners or someone who have not learned your "proper" way?

Trust me, php was really not intended to be an oop language. It is still a form  and database processor and thats it should be. I bet u remember what the manual says about php, It is for building web apps not like perl which was for loads of other purposes and made it "overhould" and php is specifically for webs and web is linear. Php is not event driven like asp.net where u need all those oop.

 

The reason for saying all this is simple. accept the fact that php is not the language that "perfectionist" like u should look at. Its c# that is for you. It is the most secure, strongly typed and most organised of them all.

 

And mvc frameworks?

Why wouldn't people use mvc for frameworks just tell me? Is there any other pattern that can be ported into a "framework" so easily? Yes framework not an application. In an appliation u have the freedom to choose any pattern u want. Not in frameworks. Frameworks need to be easy enough to deployed with little design as well as being "effective" in every sorts of application u can write. Thats what mvc is all about. I really dont see any type of web application that can NOT be implemented with mvc. MVC is really for the web.

 

I wonder why you have so much Aw with beginners or someone who have not learned your "proper" way?

I have nothing against beginners as long as they don't charge for money, once they charge for money or start cutting and pasting large portions of other peoples code in an attempt to plagiarize I think they fit under the category of code monkey. http://en.wikipedia.org/wiki/Code_monkey. I have nothing against beginners at all but the fact remains it has to be learned for them to advance in that particular area even if they are unware what the name of what they have learned is they have to learn it if they ever want to no longer be known as a "beginner"

 

first up your statements about programming languages are riddled with flaws and propaganda. You say the php manual says php was designed to build webapps, I do not dispute this. I dont think you understand the difference between the difference between a programming language and a "web programming language" The difference is nothing more then functions\classes designed to simplify tasks in relation to the web where as other programming languages have frameworks or libraries to provide this functionality the only difference is that php has a lot of this functionality built in.

 

You say php is not for perfectionism and I know this will sound harsh but you must not be a very good programmer if you honestly believe this. Programming is about perfectionism but keep in mind that perfectionism is an art and in different situations or when using different languages what is considered best will vary. I suggest you read this article on code monkeys http://en.wikipedia.org/wiki/Code_monkey

 

I think the reason a few posts have thought I underestimate MVC is because I do not like how all the frameworks copy each other and what I really mean is all the frameworks are three things

1. a big api

2. the mvc part

3. the glue that holds it together

 

It is very rare to see any innovation when it comes to frameworks some of you may not realize there is room for innovation but trust me there is. And no I am not saying throw mvc out I am just saying that the list should try to get a little bigger then the three points on the above list. Most of the larger frameworks are a blatant rip off of ruby on rails...

 

You talk about not being able to implement patterns in some places with frameworks but being able to do it otherwise I think this is bs because if you cannot use a pattern odds are you do not need to use the pattern to begin with.

 

In answer to poshpaws last post I think you will find it hard to redo a portion of your site in a framework why leaving the rest how it was you should probably consider porting the whole thing or just improving it, trying to do both could get messy.

I have nothing against beginners as long as they don't charge for money, once they charge for money or start cutting and pasting large portions of other peoples code in an attempt to plagiarize I think they fit under the category of code monkey. http://en.wikipedia.org/wiki/Code_monkey. I have nothing against beginners at all but the fact remains it has to be learned for them to advance in that particular area even if they are unware what the name of what they have learned is they have to learn it if they ever want to no longer be known as a "beginner"

 

first up your statements about programming languages are riddled with flaws and propaganda. You say the php manual says php was designed to build webapps, I do not dispute this. I dont think you understand the difference between the difference between a programming language and a "web programming language" The difference is nothing more then functions\classes designed to simplify tasks in relation to the web where as other programming languages have frameworks or libraries to provide this functionality the only difference is that php has a lot of this functionality built in.

 

You say php is not for perfectionism and I know this will sound harsh but you must not be a very good programmer if you honestly believe this. Programming is about perfectionism but keep in mind that perfectionism is an art and in different situations or when using different languages what is considered best will vary. I suggest you read this article on code monkeys http://en.wikipedia.org/wiki/Code_monkey

 

I think the reason a few posts have thought I underestimate MVC is because I do not like how all the frameworks copy each other and what I really mean is all the frameworks are three things

1. a big api

2. the mvc part

3. the glue that holds it together

 

It is very rare to see any innovation when it comes to frameworks some of you may not realize there is room for innovation but trust me there is. And no I am not saying throw mvc out I am just saying that the list should try to get a little bigger then the three points on the above list. Most of the larger frameworks are a blatant rip off of ruby on rails...

 

You talk about not being able to implement patterns in some places with frameworks but being able to do it otherwise I think this is bs because if you cannot use a pattern odds are you do not need to use the pattern to begin with.

 

In answer to poshpaws last post I think you will find it hard to redo a portion of your site in a framework why leaving the rest how it was you should probably consider porting the whole thing or just improving it, trying to do both could get messy.

Just what i thought. U are just another bookish perfectionist.

Well, So tell me did you ever done any professional project?

If so wasn't there a situation when u had to grasp, learn, read, web search or whatever to find a solution?

I doubt so, I just see you talking only about the conceptual things here. Because if u really had the experience of real life "professional" projects, then all this would sound crap, obsolete or whatever u say it.

You talk about OOP, patterns, perfection.

Do u even understand what the real consept of OOP?

Search your bookish knowledge.

You will see it says the goal of OOP is modularity and  reusability.

What is reusability?

It means peoples can use other peoples code.

What is open source?

It means peoples can see what u wrote and can change it, sell it, copy it or whatever they want.

 

Does that makes them "code monkey"?

Man, It seems u go the exact opposite where the world's going.

 

You say perfection is an art. I say programming is an art.

What is art?

Art is something that comes from inner intellect.  Something that can't be measured by an unit.

 

I think everyone who have programmed a decent app or script would have the experience of being amaized by seeing his code after a month and say "How the hell i wrote that. How i made it happen?". He can never write it the same way he did that time. That is art.

Sometimes u create an wonderfull master piece out of no where. Sometimes u just can't.

 

There is no "perfect" in art. Yes there is good. There is great.

 

U probably read the law of the preservation of energy. Everything in this world has a balance. If u want something, u have to give something.

So does in programming.

If u want speed? u have to sacrifice readability and sometimes even security.

If u want code readabilty, modularity and all that. Then u have to sacrifice speed.

 

Nothing is best. It depends on your need. Thats why Assembly is the most powerful and speedy while being the most error prone and insecure. Tell me why php is written in c instead of c++?

C++ is a lot lot secure, modular, type safe then c.

its because its fast. And for an interpretter u need that speed.

 

This entire basic question-answar is to make u understand onething. There is perfectionism in programming. Its just depends on ur need. U need to sacrifice something to get something.

 

So please try to be a bit more practical. atleast do a little freelancing. U will know how radiculous problems arise and u have to become a "beginner" to solve them.

Just what i thought. U are just another bookish perfectionist.

lol how hypocritical, but you are so wrong here. Perfectionism and books have little in common ANYONE can write a book if they really really want to.

 

If so wasn't there a situation when u had to grasp, learn, read, web search or whatever to find a solution?

I doubt so, I just see you talking only about the conceptual things here. Because if u really had the experience of real life "professional" projects, then all this would sound crap, obsolete or whatever u say it.

or maybe i seem to appreciate seeing things at a lower level more than you?? But in answer to your question I have been avoiding going out working in the field because I do not want to be a code monkey. I have instead tried to learn everything ahead of time so that I do not have to learn any new concepts that would be time consuming on the job. I have used the knowledge to create a framework that is very profession and very very elegant it is has pretty much reached the finish line I only really need to finish the scriptaculous integration when I get around to it.

 

U probably read the law of the preservation of energy. Everything in this world has a balance. If u want something, u have to give something.

So does in programming.

If u want speed? u have to sacrifice readability and sometimes even security.

If u want code readabilty, modularity and all that. Then u have to sacrifice speed.

this is just not true at all. I have been creating my current project with the goal of programming for speed. I wanted a system of creatng webpages as fast as possible so that clients did not need to wait and so I did not have to redo stuff over and over. I can bang up a very high quality web page very fast with it. I dont believe i sarcafice on readability and anyone that does is an idiot. I do agree that coding fast sacrifices a lot of documentation and such though but that is different to readability. Modularity takes me absolutely no effort because I have learned how to do it properly and I just do it, it is not something that takes me longer if anything it is actually faster.

 

You talk about execution speed why don't you go write a web page in C, its actually quite easy and its faster than php. Your whole argument about the php language being written in C because speed is so important is flawed because you are comparing a programming language to a web page, to compare the two is just stupid. Speed of development is better than speed of execution unless you are writing a programming language and a quick and speedy development does not have to result in messy unreadable code and if it does odds are you are a code monkey.

 

You will not find ANY operating systems or programming languages that take the code first, fix later attitude, if you think php\perl fit this category I suggest you learn some of the php internals.

 

You say perfection is an art. I say programming is an art.

What is art?

Art is something that comes from inner intellect.  Something that can't be measured by an unit.

I never said there was such thing as perfection my argument was against people who dont try to do things as perfect as they possibly can. People who are not perfectionists always write bad code because they usually do not care enough to take the proper steps and spend the appropriate amount of time to learn to do it properly.

 

I couldnt be bothered arguing the issue of art with you so instead I thought i would cut and paste from the dictionary

3. (uncountable) Activity intended to make something special  #in other words an attempt at perfectionism

6. (uncountable) Aesthetic value.        #in the form of clean maintainable easy to read and use code and elegant design

10. (countable) Skill that is attained by study, practice, or observation.  #in other words the skill that is required to not messy unreadable code that should be deleted

 

So please try to be a bit more practical. atleast do a little freelancing. U will know how radiculous problems arise and u have to become a "beginner" to solve them.

Freelancers are code monkeys COUGH COUGH I am also more then aware of what problems come up and this is one of the main reasons i have been spending my time studying up rather then ripping off clients. And no, I have no intention of becoming a freelance programmer. Instead I intend to make my way through internet marketing and working for businesses(not over the internet like a freelancer).

 

Oh and one last comment, when i said perfectionism I was not talking about perfectionism in relation to oop as perfection in relation to programming and oop are two completely different things.

 

Nameless, the diagram from wikipedia that you gave is only one implementation of MVC. The idea of MVC is simply to separate the data, the logic, and the view, which of course you know. How those three interact however is entirely up to you, the programmer. The implementation you showed is where the model is observed by the view -- typical in non-web languages. However in a web language the model being updated will not affect the view whatsoever, at least not until the page is refreshed, thus there is no reason to have the view observe the model. An implementation where the controller passes the data from the model to the view is what is most commonly used, and I see no problem with it.

oh how they probably laughed out load when the idea of MVC was first proposed.

 

"Hahaha!! So you want us to write 3 files for every page we have right now? And use lots of complex terminology? Haha, you should be doing it this way, as this way is correct..."

 

Most of the time, when many mention patterns and bits, I'm often scratching my head wondering what the gist of things really is and what the point is. Sometimes, I realise I'm doing some of the stuff anyway, but havent put a name to it. No biggie, it works.

 

My point is - I've found the MVC framework via firstly realising the benefits of templates and then taking it a step further and examining frameworks. Now - many purists out there will look at my framework and laugh whilst chanting stuff like "that's wrong, that's not the correct implementation of this or that". But the point is, the end result is a site that's quickly deployed, secure, functional, stable and cash in my pocket.

 

So where does the right vs. wrong stop?

 

I'm not going to have a dig at the "purists" or the "educated" - but I will say that even doing this whole web stuff part time nowadays, I do make more money than alot of people I know who are more concerned with making sure it's "correct."

 

Before anyone jumps in and gets offended by that last statement, I'm not having a dig at anyone at all - as everyone who's contributing here is helping a great deal. Nameless too - have picked up a few bits and pieces from your responses that I can learn from.

 

So I don't wanna sound all hypocrytical or anything, as I have my opinions about how code should be generally structured and written, but I personally (strongly) believe that rules (even the proven ones) are made to be broken. Else, everything will just go down the same old path, with no further thinking, no innovation, etc, etc, etc.

MVC is taking OO to a further degree, that is separating behaviour. Good OO practice is considered to be isolating application behaviours into separated objects. MVC is a pattern - it is not a framework. The only Framework to have ever existed under the title of "MVC" was a SmallTalk framework many moons ago.

 

Model View Controller Pattern. That pattern simply implies that the Model logic is separate from the View logic, and the Controller logic (and so forth.)

 

MVC is also not a proponent of the other design patterns, although it is what sparked it all off.

MVC is taking OO to a further degree, that is separating behaviour. Good OO practice is considered to be isolating application behaviours into separated objects. MVC is a pattern - it is not a framework. The only Framework to have ever existed under the title of "MVC" was a SmallTalk framework many moons ago.

 

Model View Controller Pattern. That pattern simply implies that the Model logic is separate from the View logic, and the Controller logic (and so forth.)

 

MVC is also not a proponent of the other design patterns, although it is what sparked it all off.

I don't think that anyone was saying that it is a framework, by saying MVC frameworks I believe that they mean frameworks that make use of the MVC architecture.

Nameless, the diagram from wikipedia that you gave is only one implementation of MVC. The idea of MVC is simply to separate the data, the logic, and the view, which of course you know. How those three interact however is entirely up to you, the programmer. The implementation you showed is where the model is observed by the view -- typical in non-web languages. However in a web language the model being updated will not affect the view whatsoever, at least not until the page is refreshed, thus there is no reason to have the view observe the model. An implementation where the controller passes the data from the model to the view is what is most commonly used, and I see no problem with it.

 

yes yes i think mvc is so stupid as it is really just abstraction, i think you missed the point and yes i was aware of that. My point was not that ppl should memorize that diagram but that ppl should understand what it is and how it works rather than an implementation as the code in frameworks is an implementation of an idea, but the point is its an implementation.

 

MVC is taking OO to a further degree, that is separating behaviour. Good OO practice is considered to be isolating application behaviours into separated objects. MVC is a pattern - it is not a framework. The only Framework to have ever existed under the title of "MVC" was a SmallTalk framework many moons ago.

We all know that all the frameworks out there treat mvc the way web designers treat xhtml validation. And when web designers validate their html they shove that xhtml validated link at the bottom of their page, frameworks are doing that but with "MVC" I find it rather stupid hence my comments.

 

The only reason that it appears that most frameworks use MVC is because the most popular ones do. Popularity is not something stolen, it is something given. Programmers have given these frameworks the popularity because they like them. Sure, you may not like them, but that is no reason to bash them using the MVC pattern. The MVC pattern may be what made them popular, but I don't believe that it was the reason they used it.

 

As to understanding how it works? It's not that complex, I think you're not exactly sure of your own point.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.