Jump to content

avinoamr

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

avinoamr's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Using alecks' test results, I did some math. The avg. time with __autoload() was 0.137174374771 The avg. time with require_once() was 0.111725187302 This means under the test conditions (loading the exact same files), __autoload() is 22.778% slower.
  2. Thank you Alecks, your method seemed to do the work. Only thing to note though, is that in your test you've included all of the classes, but in-fact __autoload will only include the needed ones. The require_once approach will included all of the files needed throughout the class, __autoload will only create the ones needed by the specific workflow (functions, conditions, etc.). For example, let's consider the following class: class ClassName() { function Func1() { // uses class1.php } function Func2() { // uses class2.php } function Func3() { // uses class3.php } } If we only execute ->Func3(), autoload will only include class3.php, require_once will include all three files. keebB, regarding the debugging issue, I just suggest extremely secure code. The function should throw detailed exceptions about every little issue (class in array, file exists, include failed, class exists, anything else?), making it impossible to miss anything. Overall I agree with aschk, that when it comes to maintainability and rapid development, __autoload is a great tool, even at the expense of a minor performance reduction. Only problem I see with coding practices with __autoload, is that a careless programmer might use too many different classes for simple operations that doesn't really require all of these classes. With require_once you can't miss the fact that you need to use a different class file and with __autoload it's easy to get forgetful. Makes sense?
  3. We had a huge discussion about it at the office, and wanted your advice. Consider a very large-scale MVC web application (over 3000 files, atleast 2000 files in different files), which of the two methods will be more high-performance? (for argument purposes, forget dev-time or complexity, only interested about speed.) 1. Creating a huge array with 'ClassName' => 'ClassPath.php', and then use __autoload to require_once the class definition file according to that array. 2. For each file, write a list of require_once that is required for that script/file/object to fully work? Also keep in mind that the list will include ALL of the files that are needed for that class, regardless of which functions were actually used. What do you think?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.