Naming convention
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Naming convention
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?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Naming convention
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.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?
(#10850)
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
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?
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?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
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).MrPotatoes wrote:why don't you name them functionally anyways? like forum.model.php, forum.controller.php?
Ya it's such a silly thing but it annoys the crap out of me.
I havn't really grasped what namespacing is yet. Care to elaborate?Ambush Commander wrote:I think... you ought to try namespacing.
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.
Java for example.. java.lang.String
String is the class, of the namespace lang, of the namespace java.
Think of them as virtual directories.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
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.
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.
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.