|
Posted by Mike Russell on 03/06/07 12:50
"Toby A Inkster" <usenet200702@tobyinkster.co.uk> wrote in message
news:dquvb4-r3n.ln1@ophelia.g5n.co.uk...
> Mike Russell wrote:
>
>> Big suggestion: consider using a debug environment - life will be much
>> more
>> pleasant. It will take several days to set up, but I think you will find
>> it
>> is well worth it.
>
> I considered this, but then decided the best way to avoid those long hours
> of bug hunting was to just write code that doesn't have any bugs in it. I
> don't know why I never thought of that before -- all those years of
> writing code with bugs in it and then debugging it -- much easier just not
> to write the bugs in the first place. ;-)
Hi Toby,
I understand you are being tongue in cheek here, but it does touch on one of
the reasons that I believe people reject using debuggers and development
environment. Being able to type accurately and quickly write code with few
or no bugs is a high level of skill, and rightfully a source of pride. That
pride seems to be undercut by the suggestion that using a debugger would
help in any way.
> More seriously, no matter how good you get at PHP, these silly little
> syntax errors like misplaced brackets and missing semicolons are always
> the ones that come back to bite you.
Absolutely - a nickle for the number of times I've left the single quotes
off a field name, or had a backwards if.
> If you (not you in particular, Mike; I am referring to the general "you")
> don't already have the command line version of PHP, then get it, and run
> "php -l filename" on any file before you try using it. It will catch any
> parsing errors in the file.
I appreciate your consideration, as well as your useful suggestion re the -l
option. It's nice, too, to have a red wavy line appear under the syntax
error immediately as you type it, or xtrl-space give you a selection of
function names.
> After that, enabling PHP's normal error reporting should provide fairly
> helpful error messages, such as when you don't provide enough parameters
> for a particular function, or if you've not implemented a particular
> interface correctly, and so forth. When relevant, it tells you the exact
> file and line number where the problem is. These bugs are usually fairly
> simple to fix.
>
> Then you "only" have to deal with logic errors. :-)
There you go - I sense a universe of hard-earned knowledge in your use of
the word "only". Logic errors do not produce syntax errors, and knowing
where to place the echo statement often means knowing where the bug is.
Another example is learning about PHP itself, or dealing with a large
existing body of code. For example, I'm about to dive into a mature forum
system that includes 306 source files, and dozens of database tables. With
a debug environment, I can set a breakpoint at a piece of code I'm wondering
about, see all the variables (not just the ones I think I might be
interested in), and follow the chain of execution arbitrarily. These are
all very powerful abilities that I have learned are necessary for me to work
efficiently.
For me the decision of whether to use a debug environment is not even a
close call. If it's available I want it. If it's not, I'll slog along with
embedded echo's.
If you work well without a debugger, more power to you. IDE's and debug
environments are used by skilled professionals all the time, and I hope you
will forgive me if I suggest that, as experienced and productive as you are,
you would be even more productive with a *good* debug environment.
--
Mike Russell
www.curvemeister.com/forum/
Navigation:
[Reply to this message]
|