RE: Multiple Inheritance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Please note that I am specifically *not* weighing in on the OO vs.
procedural religious war, but only wanted to make a couple of small
comments. :)

Richard Lynch wrote:
> I spend a *LOT* more time, digging through endless class files, of
> what are essentially name-spaces of singleton "objects" trying to
> find the line of code some idiot typed that is doing the wrong thing,
> but starting from 'index.php' I have *NO* *IDEA* how it got in there.

debug_backtrace() is your friend.  I have a tiny little backtrace function
that I use that accepts a label and dumps the label and the output of
debug_backtrace() to the terminal that I am SSH'ed into (via a redirect to
/dev/pts/[0-9]+).  If I have a complicated class hierarchy, or a series of
library files that include other files, etc. then I add a line into the
function that is giving me trouble:

backtrace('one');

If I have two functions I want to check I just add it again, but make sure
my label is different:

backtrace('two');

Then I request the page and check my terminal screen to see how the PHP
parser made it to the offending section(s) of code.  I even array_reverse()
the array returned from debug_backtrace() so it starts with index.php and
works it's way down (I find this easier to follow).

> I end up having to "grep" source code just to find the damn thing.

A good editor would help here.  For example my editor of choice, jEdit
(www.jedit.org), allows you to search for a string (or a regex) across every
open file, and using its "HyperSearch" functionality shows an index of
filename and line number containing your search string that you can easily
click on to jump around.  Of course it only searches files that are already
open, and if you're dealing with a large number of files sometimes grep is
still necessary to narrow down which ones need to be opened, but it's still
an immense help to me.  I'm sure many other editors offer similar
functionality.

Just a couple of tangential thoughts...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux