Page 1 of 1

Naming convention

Posted: Wed Jul 12, 2006 5:05 am
by shiznatix
Ok I know there is the Model, View, and controller classes and whatnot but I don't like that kinda naming. It's too long and they don't show up in order on a alphabatized list. I want the View to be on top, then controller, then model as this makes sence. Is there another naming convention that would do that? What other ways to call them do you use?

Posted: Wed Jul 12, 2006 5:31 am
by Jenk
Functional naming is what I stick to :)

Only 'difference' I have is prefixing with the 'project' name/acronym.

Posted: Wed Jul 12, 2006 5:53 am
by Roja
Input, Processing, Output.

Re: Naming convention

Posted: Wed Jul 12, 2006 10:30 am
by Christopher
shiznatix wrote:It's too long and they don't show up in order on a alphabatized list. I want the View to be on top, then controller, then model as this makes sence. Is there another naming convention that would do that?
This is the kind of kooky, personal requirement that just makes things harder for you down the road. I would suggest looking a something like the Zend Frameworks and follow that. Otherwise you end up with 1View, 2Controller, 3Model or some such nonsense. I don't particularly like PEAR style naming -- but I use it without complaint because it is a standard and works pretty well.

Posted: Wed Jul 12, 2006 1:42 pm
by MrPotatoes
lol, i use a mix of my naming convention and C++ naming conventions MINUS hungarian. that smurf blows smurf. also i split up all my files in the correct areas but the M/C stays in one area and the V's go in a completely different area.

why don't you name them functionally anyways? like forum.model.php, forum.controller.php?

i'm gussing that you've got all your files in one folder then right?

Posted: Wed Jul 12, 2006 8:25 pm
by Ambush Commander
I think... you ought to try namespacing.

Posted: Thu Jul 13, 2006 1:50 am
by shiznatix
MrPotatoes wrote:why don't you name them functionally anyways? like forum.model.php, forum.controller.php?
I do. Like if i make a page to lets say, add or edit email addresses for a client. I make a folder and name it like 'EmailAddresses' then I make my 3 files and name them like 'EmailAddresses.View.class.php', 'EmailAddresses.Controller.class.php', and so on. Really the biggest problem is that when I go to open them, I cant just highlight them all and click open. I have to open them one at a time so they will be in order in my tabs thing (i use editplus).

Ya it's such a silly thing but it annoys the crap out of me.
Ambush Commander wrote:I think... you ought to try namespacing.
I havn't really grasped what namespacing is yet. Care to elaborate?

Posted: Thu Jul 13, 2006 3:13 am
by Jenk
Namespaces are not yet available in PHP (I heard they are to be available in PHP6? When I say hear, I mean literally.. didn't read an article, a friend mentioned it.. so don't shoot me if I am wrong :p,) but in other languages are most useful.

Java for example.. java.lang.String

String is the class, of the namespace lang, of the namespace java.

Think of them as virtual directories.

Posted: Thu Jul 13, 2006 4:53 am
by shiznatix
ohhh. ok ya i did that stuff in java but never knew they where called namespaces. thanks

Posted: Thu Jul 13, 2006 6:53 am
by Ambush Commander
With PHP, you emulate namespacing by doing the Namespace_ClassName() convention. I agree: real namespaces would be dead useful. However, now that I see some examples, that's largely irrelevant.

Regarding your troubles, you're very much in "Transaction Script" mode. If you find yourself needing to edit all the model classes at once, you may want to consider refactoring to a more Model based layout.

Or you could create a batch script that scans the directory and opens them all. ;-)

Posted: Thu Jul 13, 2006 7:49 am
by Jenk
I've seen others use directories as kind of pseudo namespaces, granted it doesn't help too much when your 'in app' but they say it's dead handy for this type of scenario.. all model classes are in the /model dir, view class in the /view dir.. controller classes in the (you guessed it) /controller dir etc.