[Discuss] php dev's code with warnings and notices

Tom Metro tmetro+blu at gmail.com
Sun Jul 27 22:41:42 EDT 2014


Eric Chadbourne wrote:
> The code they have...has a bunch of warnings and notices in the logs.
> I personally think this is sloppy coding.  My question is, how strong
> a stand should I take on this issue?

Part of this is going to depend on how practical it is to achieve "no
warnings" in PHP code. I don't know the answer to that. But if you are
accustom to achieving no warnings in your own PHP code, then yes, I'd
agree this is indicative of sloppy code.

Compiler/interpreter warnings can be a great tool for spotting problems.
One of the first things I do in web browsers used for development is
enable strict mode in the JS engine. I do likewise with MySQL. 'use
warnings' (or the equivalent achieved through other means) is stock
boilerplate for all Perl code I develop.

I'd never deliver Perl code that triggers warnings. But Perl also gives
you tools where you have fine gained control to override warnings in
situations where the best solution to a problem is to bend the rules a bit.

With JavaScript, that's a different matter, as not all browsers agree on
what constitutes a situation warranting a warning. And there are some
warnings, like "function doesn't always return a value" that can seem
superfluous.

As the senior developer, I'd definitely recommend setting the example by
delivering code free of warnings, and cleaning up the code you happen to
be touching for other purposes to eliminate warnings, but what you are
facing is a cultural problem, rather than a technical one, and that can
take time to change. If you're the only one submitting clean code, and
your coworkers aren't on board with the value in doing likewise, you may
find it to be a futile effort.

 -Tom

-- 
Tom Metro
The Perl Shop, Newton, MA, USA
"Predictable On-demand Perl Consulting."
http://www.theperlshop.com/



More information about the Discuss mailing list