|
-
Can you explain MVC in the most simple terms possible?
Hello.
I've been hearing that for bigger Flash sites, interactive agencies use the PureMVC and Cairngorm AS3 frameworks.
I want to know why they do this and how this workflow typically goes for the development. My curiosity really stems from not knowing what MVC is and how it helps. Every "simple" explanation I read goes off into computer science terminology and loses me. Can anyone out there explain with maybe a real-world example why this is a standard practice? Also, I know other design patterns are out there...why is MVC so popular?
THANK YOU!
-
MVC stands for Model, View, Controller. The idea is to separate the code into parts that are independent to make it easier to change and develop without having to change unrelated code.
A "Model" is the stuff you are working with. In a Library app, it will be things like Book, Shelf, Stack, and CardCatalog.
A "View" is the stuff that the user sees. It displays the information from the Model and provides a UI to interact with.
A "Controller" is the brains. It handles how everything interacts. In the hypothetical library app, it would have methods to look up books, check them out, determine whether users have late fees, etc.
So each of the M, V, and C interacts with the others, but in a loose way. A Book does not need to know how it appears on screen, it only provides information to the View to display it. Similarly, the View does not need to know how to talk to the database, or how a search works, or anything like that. It just gets information and shows it, and provides a UI. The Controller doesn't care how anything looks, it just gets commands from the View and Models and does stuff.
That's the gist of it.
The reason MVC is so popular in webapps is because it is a natural fit for the way websites work. There's the client View (browser), the Model (data), and the Controller (Server).
-
Senior Member
Another very important reason is the re-usability of the classes, the controller and the model class, since you can easily add more views without creating a whole new set of classes. Just imagine a game with different stages and levels.
- The right of the People to create Flash movies shall not be infringed. -
-
 Originally Posted by cancerinform
Another very important reason is the re-usability of the classes, the controller and the model class, since you can easily add more views without creating a whole new set of classes. Just imagine a game with different stages and levels.
Thank y'all for your responses. So could instances of the view be different pages in a web site?
-
In a general sense, yes. You could have one page which displays some data as a table, and another which displays the same data as a graph.
But if you're talking about flash, I wouldn't put those on separate html pages necessarily.
-
Cool. So how would you break up a hypothetical Flash web site like this in the MVC framework? Would you create a class for each page, each data element, and assemble them in a façade?
Home page - navbar, logo, background image, text
About Us - navbar, logo, background image, text, photo
Portfolio - navbar, logo, background image, table that pulls data from XML, images
Contact - navbar, logo, background image, ZendAMF/PHP contact form
-
None of that sounds like it needs to be flash at all, except maybe the gallery. I'm generally not in favor of using flash for an entire website, but that's an aesthetic decision. If you do want to do that, your breakdown makes sense. You'd determine whether to have those as separate swfs loaded into a facade, or separate pages, or just all one big thing, depending on how much content there is.
Here are some classes that might apply and general MVC classification:
Models: Menu, PageContent (text and background. could just be xml rather than class),
Views: Home, About, Portfolio, Gallery, Contact
Controllers: not much here, nothing actually seems to happen. You'd need some logic to load info and turn it into models and give it to views, that's about it.
-
 Originally Posted by 5TonsOfFlax
None of that sounds like it needs to be flash at all, except maybe the gallery. I'm generally not in favor of using flash for an entire website, but that's an aesthetic decision. If you do want to do that, your breakdown makes sense. You'd determine whether to have those as separate swfs loaded into a facade, or separate pages, or just all one big thing, depending on how much content there is.
Here are some classes that might apply and general MVC classification:
Models: Menu, PageContent (text and background. could just be xml rather than class),
Views: Home, About, Portfolio, Gallery, Contact
Controllers: not much here, nothing actually seems to happen. You'd need some logic to load info and turn it into models and give it to views, that's about it.
THANK YOU!!! (I'm in Austin too! Crazy morning, eh?)
-
I didn't hear about the stuff at UT until it was all over. I'm glad it didn't get crazier.
-
Me too. Very sad though.
Thank you so much for your help! Enjoy the nice weather
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|