Hi,
I was wondering that does anyone ever put abstract classes or interfaces in the same file with their "real" class equivalents? This way you could save some execution time, but makes the class file a bit larger..
Having classes on the same file?
Moderator: General Moderators
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Having classes on the same file?
That seems wrong because the point of an abstract class is to provide a base class for other classes to extend. If you have the abstract and child class in the same file it implies that they should be combined.
The only time I combine classes is for 1) helper classes used by a larger class that would never need to be autoloaded, 2) combining many classes to speed loading.
The only time I combine classes is for 1) helper classes used by a larger class that would never need to be autoloaded, 2) combining many classes to speed loading.
(#10850)
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: Having classes on the same file?
Would this be an acceptable solution for production use (leaving the developer version intact - separate files)?
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Having classes on the same file?
I keep all classes in separate files and run a compile like script to pull classes into a single file (cached actually not compliled). Each request pulls on different classes, so each request loads a different cache.
The only problem I have ran into using this approach is when the cache is out of date and the classes are not loaded completely...I basically need to run my application through a ringer to ensure the classes loaded on each request are properly cached...which also means I completely test my application.
I`m looking into maybe using Selenium to automate the process as I currently use iMacros for Firefox which is a little tedious.
The only problem I have ran into using this approach is when the cache is out of date and the classes are not loaded completely...I basically need to run my application through a ringer to ensure the classes loaded on each request are properly cached...which also means I completely test my application.
I`m looking into maybe using Selenium to automate the process as I currently use iMacros for Firefox which is a little tedious.
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: Having classes on the same file?
How do you determine, which cache to load?PCSpectra wrote:Each request pulls on different classes,
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Having classes on the same file?
Each request is associated with a URI -- so the cache are just MD5'd URIs
- kaisellgren
- DevNet Resident
- Posts: 1675
- Joined: Sat Jan 07, 2006 5:52 am
- Location: Lahti, Finland.
Re: Having classes on the same file?
PCSpectra wrote:Each request is associated with a URI -- so the cache are just MD5'd URIs
Are you sure you never miss any required classes?
Re: Having classes on the same file?
In the framework we use, small related classes are put together in one class. For example all basic actions (create / execCreate, edit / execEdit, view, delete ) as well as their abstract classes they extend, are in 1 files, but those are type of command patterns and they are really small. Same applies to all validator classes, and to all basic widget classes. When we are creating a set of specific validators that all applies to the same view (screen in the browser) we also put them in one file.
Sometimes module classes are also combined in one file.
Sometimes module classes are also combined in one file.