Hey everyone.
I'm working on a fairly large project (about 70% done, running about 4000 lines right now). I've done it entirely myself so far, but I recently recruited a friend to help out.
Now he's taking issue with how I have my functions organized. It's not so much that I care whether he or I is right. I care more about making the work easier in the future and making it look good. heh... But seriously, I want others to consider it easy to work with, but I also want it to be secure.
The project is a message board, similar to phpBB. It is partially that I have some unique requirements and partially that i wanted to "see if I could" do it by myself.
Now that I know that I can do it, I'm sensing that we're close to the final product.
Right now, I have the system set up as such:
index.php is the main index and merely calls several functions which display headers, generate the main SQL query and display the index line by line. This function REQUIRE()s one other file that has all of it's sub-routines for displaying the index in it.
there is also a MESSAGE file that displays the content of messages, which calls one OTHER file where all of the code for displaying a message is stored.
In addition, there is a POST file which handles posting of new messages. This file also REQUIRE()s another file which contain the primary functionality to post new messages and replies.
Each of these modules is divided up into between 2-10 functions, each having a specific purpose.
There are several files which are independent functions used both in posting, browsing and reading which have their own file and are included as needed. The authentication file is one of these, which checks user names and such.
There is also an administrative file, which calls a few of it's own functions from another file, as well as pulling a few of the funcitons off the remainder of the database.
Does this sound way out there? or is it solid? Any suggestions?
The problem I have is that my friend has decided it's best to put ALL of the routines in one file. so now every request is handled by the index.php file.
to view a message, your pass the variable "action=message" such as:
index.php?action=message&m=200
He also wants to run all of the functions that are REQUIRE()d together into one central "repository". He says it is more secure and easire to find things when the system is set up this way.
I'm asking because I don't want to put my foot down and say "no, this is HOW IT IS" and the only reason I have is "because I think it's better"
If someone can let me know what they think and perhaps cite some examples, I would appreciate it.
I am open to whatever you all have to say about this, but I really am curious what most people consider "good practice" in programming. (I think I already know, but maybe I'm wrong)
Oh, yes. Also, what do you think of having "REQUIRE" files to be named .inc instead of .php? I've been doing some thinking on that and seems to me it might be very bad because a browser will read a *.inc file as a text document and display all the code. The .php file will only show a blank page, since it has only functions in it. It could even log an attempt to read an include file as a hacking attempt. :-) Still, maybe there are benefits the other way. Let me know what you think.
Thanks,
Eric