Class structure
Moderator: General Moderators
Class structure
How do you guys setup your class structure? As in, how do you typically break it up? Do you have one class per file or one big file with all classes...
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Directory structure wise? I segregate my classes based on categories. We've had a few discussions on that, so instead of rehashing my response, I'll simply link to one of them:
viewtopic.php?t=46498
viewtopic.php?t=46498
I separate each class into it's own file. I also stick to a standard naming convention for those classes and files which allows me to autoload the classes I need in the most efficient manner possible. I also wrote my own autoloader which is optimized for looking in the most commonly used folders first.
As for segregation. I really liked the directory structure used by Rails so I more or less duplicated it.
As for segregation. I really liked the directory structure used by Rails so I more or less duplicated it.
-
thinsoldier
- Forum Contributor
- Posts: 367
- Joined: Fri Jul 20, 2007 11:29 am
- Contact:
Re: Class structure
GeXus wrote:How do you guys setup your class structure? As in, how do you typically break it up? Do you have one class per file or one big file with all classes...
I have 1 file for any class that's a lot of code or extends some built in php class.
For something like my form field building class where theres FormField and then an extended class for each type of field, since they're all so related I have them in a single file.
For use with autoload() I have to make special cases in my autoload function for files that contain multiple classes. Not a big deal.