4 ms·
Ask HN: how to Learn MVC?
I'm learning Python and Django but I need to grasp this MVC pattern stuff. Any good books or screencasts explaining how MVC works? I'm a beginner so a basic explanation would be appreciated.
- jsnk 13y agoCheck out this Rails MVC pattern (http://addyosmani.github.io/backbone-fundamentals/#mvc-applied-to-the-web http://addyosmani.github.io/backbone-fundamentals/#mvc-appli...) explained by Addy Osmani for developing Backbone Apps. Rails MVC is said to be very similar to Django MVC, so this should be pretty useful.
- akulbe 13y agoWould be great to talk to you more, based on your previous questions/posts, but no contact info listed. I have some of the same questions that you've had.
- shire 13y agofeel free to contact me muhammedcode@gmail.com
- moneyrich4 13y agoa primer on mvc ill just give a easy to understand (?) example MVC Model View Controller Model: this is a data model [access pattern] models/users.code: class User { function getUsers() { $db->fetchAll("SELECT * FROM USERS LEFT JOIN CRAZYTABLE ON CRAZYSTUFf = 1") } } Controller: Handles application logic controllers/userlist.code requires('models/user.code') function showUsers() { $users = User::getUsers() $usernames = [] foreach($users as $row) $usernames[] = $row['name'] renderView('views/userpage.html', $usernames) return } View: Display logic, ideally as simple as possible Could be a html template or a windows form Purists say you should do all data validation and preperation in the controller views/userpage.html <div id=myuserlist> <h1>Our users</h1> <ul> {{ foreach $users as $user }} <li>{{ $user }}</li> {{ endforeach }} </ul> </div> Now you understand MVC! =)