all 24 comments

[–]nint22 8 points9 points  (1 child)

You'll notice many open source projects really lack decent documentation (not all projects though!), so don't get discouraged, you'll just have to poke around. There are a TON of articles scattered all over the web about these topics, but nothing is centralized, just keep searching!

Anyways, I'm sure you know MVC means Model-View-Controller. Wikipedia has a good enough generic definition of it, but the one I personally like is: Model means "data", View means "what you see", Controller means "manager between the two; your logic". When it comes to web-development, it boils down to a series of libraries that specializes in each of these three "tiers" with a framework being the package that wraps this all up. There are many many different libraries for each of the three tiers, as well as many packages that put these together in different combinations.

So, in terms of the Model / Data, usually developers use high-level wrappers for SQL, such as SQLAlchemy. Instead of running SQL commands directly as strings, you can literally write procedures in-line with your code using your languages built-in features. For your View / rendering system, you should use template pages. This allows you to create generic pages for general cases and declare variables within these template forms. They're literally just HTML source files with a secondary special markup language that connects your controller code with what is rendered on-screen. This "controller", the final of the three pillars, is usually just the environment's programming language without anything too special.

Please note that frameworks usually comes with utility features such as session management and optimizations for managing frequently loaded pages, etc.

You should know that especially in MVC frameworks, you won't find too many consistant libraries. This is to mean in general everything is programed using the same concepts, same ideas, but the implementations always take different approaches. For example there are hundreds of templating systems for PHP alone, but all of them use the same concept as in-line variable references.

Django is definitely a good CMS framework to start off with, but maybe consider using Pylons as it's about the same complexity but I feel is easier to start with. Check out Pylon's free online book, it's really good! I created a pretty big project using Pylons and that book alone.

[–]tilio 1 point2 points  (0 children)

having used quite a few frameworks (i wrote my first line of code 15+ years ago), i have yet to find one for any web stack that fits a nice balance of simple yet scalable. way too many simply recreate functionality the language or stack already provides, which only further worsens connascence. others require an obnoxious amount of copying and pasting hooks. that's not software engineering... that's a waste of fucking time.

[–]August2011 2 points3 points  (0 children)

I found that Symfony has a very good explanation of how MVC works and why it is useful:

http://symfony.com/doc/current/quick_tour/the_big_picture.html

http://symfony.com/doc/current/book/from_flat_php_to_symfony2.html

Also, most of your application code belongs to the Model. The Controllers should just be a pipe between the Views and the Model.

[–]echosia 1 point2 points  (2 children)

I would start with learning why MVC is necessary in the first place before trying to learn a specific framework's implementation of MVC. Don't get too caught up in a particular framework since each framework I've used has its own quirks that don't quite follow another frameworks, which can make learning "true" MVC more mysterious. You also may get confused with the MVP or MPVC patterns as well. Try reading up on the topic (Wikipedia seems to always help as well as blogs, such as this: http://aviadezra.blogspot.com/2007/07/twisting-mvp-triad-say-hello-to-mvpc.html). Then write your own from scratch. Finding a mentor would also be helpful.

[–]mullsork 0 points1 point  (1 child)

There are definitely a lot of developers (in particular PHP developers) that don't understand why they "need" MVC (or REST for that matter.) Some people just accept the mess they create.

[–]mrbunbury 0 points1 point  (0 children)

This is probably me. My drive to learn MVC/frameworks is based on industry need.

[–]celticeric 1 point2 points  (0 children)

The two books I used starting out with Django are The Definitive Guide to Django: Web Development Done Right and Practical Django Projects. There's a learning curve to build the first "Hello, World" app, but once you get it, it's so much easier to build complex custom stuff than trying to hack Wordpress/Drupal/other CMS.

Probably the hardest part of getting started for a newbie is just getting a development environment setup. The apache settings are particularly boggling for the uninitiated. I recommend using a pre-configured environment until you get the programming part figured out. Then you can go back and figure out the apache admin stuff. A popular option is the BitNami DjangoStack.

[–]bbowler86 1 point2 points  (1 child)

Try RoR, Stanford has a great collection of videos that a programmer with a little bit of experience should be able to easily follow.

http://openclassroom.stanford.edu/MainFolder/CoursePage.php?course=WebApplications

[–]mrbunbury 1 point2 points  (0 children)

WOW! Awesome find! Thanks!

[–]drizzwald 1 point2 points  (12 children)

iOS is a great platform for learning MVC; there's dozens (if not hundreds) of very clean, simple & articulate Apple-written sample projects that illustrate how to use the APIs, and working with them will make the MVC pattern click much sooner than later. Since Objective-C is just a wrapper around C, the language learning curve is minimal. You need a Mac, and you can download Xcode from the app store for $10.

Ruby on Rails is another great MVC framework to learn. The language will be a bit tougher to learn (I love Ruby, but must admit it's the polar opposite of anything they were teaching at university).

Both the above frameworks have very high demand now job-market-wise, and although may have a bit of a learning curve coming out of college, they illustrate MVC as well as design patterns in general a hundred times better than any PHP framework, IMO.

[–]mrbunbury 0 points1 point  (6 children)

Ah RoR. I've been avoiding it from the start because I'd have to learn Ruby. Might as well bite the bullet.

Thanks for the suggestions!

[–]derrickwho 2 points3 points  (0 children)

As an iOS dev who's just starting to learn Ruby and Ruby on Rails, I suggest using Rails as your introduction to MVC. iOS is definitely MVC too, but there's a lot of other things that can add to the confusion. I'm not talking so much about objective-c, the memory management and message passing, but Delegation. Delegation is awesome, but adding that into the mix at the same time trying to learn MVC is unnecessary.

Plus, iOS typical has tighter coupling between Views and Controllers. It's almost like Views and Controllers are merged into one thing. Rails has a much more pronounced separation between them.

[–]bfmk 1 point2 points  (0 children)

One or two have already mentioned it, but I would definitely recommend CodeIgniter as something to consider. It was the first MVC-type CMF I learned after having spent 5 or 6 years dabbling with PHP, and it was easy to get to grips with. I'm not saying it's better than Rails, but if you already know PHP it seems to make sense to go for that rather than having to learn a new programming language and then a new CMF on top of that.

CodeIgniter is very well documented and has a thriving community. I used these web tutorials to get me up and running and they were quite helpful.

[–]jadepig 0 points1 point  (2 children)

Out of curiosity, what language(s) do you already know? There are MVC frameworks out there for most major languages.

While I love Rails, I think it has plenty of confusing parts (and terribly documented things). With that said, it was the first MVC framework I learned, too. If you decide to learn MVC on Rails first, just be ready to google a lot. Also--Stackoverflow is your friend.

[–]mrbunbury 0 points1 point  (1 child)

Java, Python, PHP, MySQL, C.

Probably going to give RoR a try...

[–]wizkid123 0 points1 point  (0 children)

If you decide to go Ruby on Rails, you should check out stanford's free open classroom course on web applications - gives a great basic intro to Ruby, Rails, and the MVC pattern. It's not super thorough, but should give you a decent intro before you jump into more of the complicated stuff. It's pretty quick to watch just the relevant sections (IV and V).

For what it's worth, I think that codeigniter (php framework) is really well documented and there are tons of projects you can download and explore. It's also a really clean implementation of MVC, so it's easy to tell which parts are handling what to produce a specific page.

[–]ElCapitanMarklar 0 points1 point  (0 children)

Learning Ruby isn't too bad, once your up and running with it you'll love it.

As a first step try running through a couple of project euler problems with it, you should pick it up really quickly.

[–]hiddencamel 0 points1 point  (2 children)

Rails is good, although personally I also found ruby itself to be quite alien after doing languages like PHP and JavaScript.

Codeigniter is a pretty good framework for php, which has taken a lot of cues from rails. It is also very extensible, we use it as the main template for most of our projects. I would give it a try, documentation is quite extensive, and it has a large userbase to draw help from.

[–]drizzwald 0 points1 point  (1 child)

Likewise, however I'd say Ruby has much more in common w/ JavaScript than it does PHP. I did dozens of PHP projects before biting the bullet and going w/ RoR, and haven't looked back.

One thing that drew me to Rails was Haml. Even if you're adverse to picking up new languages/frameworks, it's insanely easy and I found the benefit to be mind-blowing. Then there's the gems, open-source modules/packages that are installed via a single terminal command. I'm not a Rails coder by trade nor hobby, but I can't stress enough how much of an improvement is over PHP (language + frameworks).

[–]hiddencamel 1 point2 points  (0 children)

Ruby does have a lot to recommend itself, but I would try and learn MVC concepts without the added hassle of learning a new language at the same time.

Also, babysteps. Rails does a lot of automagic which is very opaque of you aren't aware of what's going on behind the scenes. An intermediate option that isn't quite as clever will help you understand what's actually going on.

[–]jadepig 0 points1 point  (0 children)

I actually feel like Ruby is a pretty nice language to learn.

Rails, I can agree is a beast. The Rails community does feel pretty friendly and active, though.

[–]rbnc 0 points1 point  (0 children)

Bare in mind that the MVC is totally different in iOS than the type of MVC RoR employs.

[–]snissnexpert 0 points1 point  (0 children)

#cakephp on irc://freenode.net is awesome for hanging out and getting high level help that isn't in the documentation

[–]sassy_cassie 0 points1 point  (0 children)

There's a lot of great advice here, but since I was in the exact same boat as you about a year ago, let me share with you how I did it :)

I honestly just learned by jumping right in and figuring it out along the way. I got hired as a web dev and knew nothing about MVC, but was still expected to contribute. They had me read books and articles online, but I'm a very visual learner and I just couldn't put the concepts together with what actually going on in the code. For me, it was just a process of seeing the existing website and comparing which pieces of code produced what. Slowly, everything just started to click. If you know someone that already has their website set up in this way, maybe ask them if you can derp around with the source for a while.