Mvc

This is a discussion on "Mvc" within the PHP Forum section. This forum, and the thread "Mvc are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 11th, 2007, 10:46
SuperMember

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Mvc

Q. for you web guru's.

When building a site, do you use the MVC method that is sometimes talked about out there.

A friend of mine uses it and I found it difficult to understand. This may be becasue I do not understand classes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 11th, 2007, 10:59
Highly Reputable Member
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Mvc

I have never heard of it until you mentioned it and I would say stick to what you know.

If you want to learn php you have to start from the ground up and learn the basics first as there is a lot to learn
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 11th, 2007, 11:09
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Mvc

The MVC method is highly beneficial.

Breaking your code into three manageble areas is a good idea that allows for higher flexibility.

Having database processing, HTML output and algorhythms all mixed up in one file makes it very hard to change one independently.

To break it down into an easy to understand idea:

M - The model. The backbone of your program, the way you arrange your data, the way you perform actions on it.

V - The view. The output and what is seen, the displaying.

C - The control. The conrol takes the model and sets it up for the output.

Set your scripts up so these all work by themselves and you will have a very manageable code.

Hope that helps.

Cheers,
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 11th, 2007, 12:19
SuperMember

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Mvc

Thanks for this

What key areas would you say I need to embrace/learn in order to really get to grips of working this way.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 11th, 2007, 12:28
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Mvc

LOL, I think I already outlined my liking of OOP but objects and classes are definitely the best way to get this sort of abstraction happening.

Say you have a script that shows user information from the database.

In the output script, you mix HTML and the output from controller objects. These objects are separate from the output and you just echo the results.

The controler objects themselves perform operations on the data from your model objects. The model objects again are separate from the controlling objects.

This allows you to change the output/operations to get output/data to be used in operations without having to alter the other layers in any way.

Say you want to change the background colour of the page on a user preference basis. Don't fill your output page with conditionals, instead call an object method

backgroundcolor = "', $userPreference->backgroundColour(), '"

The class that built userPreference (controller) can then do the conditional processing to determine what colour to output and it does this by working with the data from a user class that has data (the model)...

Hope that helps, but abstraction is very graceful and I am passionate about it... lol , like you couldn't tell.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 11th, 2007, 12:28
Reputable Member
Join Date: Feb 2006
Location: London
Age: 26
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Re: Mvc

I use cakePHP which is a MVC framework. It makes things a lot more organised, especially when working on large projects.

I'd suggest you do some basic work with classes, it will save you a whole bunch of time and headaches in the future!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:58.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42