Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-17-2004, 09:27 AM   #1 (permalink)
DavH27
PHP Pilgrim
 
DavH27's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 170
DavH27 is on a distinguished road
[mfp] Model-View-Controller

Quote:
Originally posted by Belisarius
Well, if it's design insight you're looking for, you might want to read up on MVC
Somebody hit me with this in Joe Bloggish cuz it does not really make sense ot me tbh.

Okay So there are 3 parts to the model, this does this to this part and this does this to this part and it does this to show the result of this etc etc etc but so what? Is it just an explanation of how good projects could be using this model?

Is it not used by default when developing PHP websites connecting with MySQL manipulated by forms.

Maybe not done very well most the time but surely I was going to be using this model idea by default anyway...?

Sorry if I haven't made myself too clear, my head's hurting with the amount of PHP stuff I'm cramming into it.
__________________
Davy - Programming since 1998 [CV]
Currently working on: n/a
Status: n/a
DavH27 is offline   Reply With Quote
Old 08-17-2004, 10:13 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
As you move into scripting languages such as PHP or ASP, there is a tendency to mix and match elements of the design patterns.

The goal is total seperation, so you don't worry about database logic in the same page as you're attempting to display a table. You think it's obvious, but way too often you'll see people (especially newbies) including an SQL query in a webpage.

I'm going to go OOP a bit, as that's how I think. Let me know if you don't follow.

I have a website (theoretically). I handle form validation through Javascript, content through HTML, and layout through CSS. I store session data (user, permissions, stats, form information) in an Object for later retrival. I use JSP/ASP/PHP to display different content based on this Object. I use a seperate object to perform background database logic (or e-mail logic or what have you). I keep SQL queries in another object.

By doing this, everything in comparmentalized. You can bring in someone to change the look of your site without the need of them to know Java/VBScript/PHP. You can have a DBA admin your queries with a minimum of programming knowledge. You can get someone who knows programming but not SQL.

It will also make things easier in the long run, as boundaries are clearly defined and hacking is far less frequent. A current project of mine didn't start with that model, but I adopted as I went on later, and the quality of the code has really improved.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 08-17-2004, 10:35 AM   #3 (permalink)
DavH27
PHP Pilgrim
 
DavH27's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 170
DavH27 is on a distinguished road
Wow that's really weird as at the moment as I'm progressing up the razor-handled ladder of coding, I'm looking for way I can modulize my apps. I ahve modulated my basic website DH-CV using SSI includes for the nav, body and footer.

This makes everything 1000% easier for maintenance and updating so I was looking at the way of doing it with other stuff. When I was learning JavaScript the other month (I've given it up now - no point in learning what everybody has already coded for me) I was lookin for a way to modulate all the coding and I think I read somewhere about .JS files.

But anyway yeah - thank you for clearing that up

Have you noticed the [mfp] thing at the start of the topic title? Do you understand that? I just wanna make sure people do before I confuse everybody.
__________________
Davy - Programming since 1998 [CV]
Currently working on: n/a
Status: n/a
DavH27 is offline   Reply With Quote
Old 08-17-2004, 11:04 AM   #4 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
I didn't understand it until I read your .sig, and remembering what you wrote in the lounge it makes sense.

.js files are just javascript files that are kept seperate and included in HTML files, so you don't repeat the same Javascript function in several different pages. So instead of including a hundred-line function in several different pages, you write one hundred line .js file, and refer it it with one line in your HTML files.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 08-17-2004, 11:44 AM   #5 (permalink)
DavH27
PHP Pilgrim
 
DavH27's Avatar
 
Join Date: Aug 2004
Location: London
Posts: 170
DavH27 is on a distinguished road
Yeah I know all about .js files! They can be includes in a modulated structure such as external CSS files, html ssi etc etc ... it just makes coding loads easier! I know I know ...

I won't ask questions to do with modulating a website with individual files that all draw together with PHP because I have to learn basics first.
__________________
Davy - Programming since 1998 [CV]
Currently working on: n/a
Status: n/a
DavH27 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 05:11 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting