[Melbourne-pm] Using strict...
Craig Sanders
cas at taz.net.au
Tue Feb 20 14:54:06 PST 2007
On Tue, Feb 20, 2007 at 07:21:48PM +0200, Shlomi Fish wrote:
> On Tuesday 20 February 2007, Craig Sanders wrote:
> > On Tue, Feb 20, 2007 at 02:44:58PM +1100, Tim Hunt wrote:
> > > My options seem to be to declare all the variables in the main script
> > > and carry on regardless, or implement a better config method.
> > >
> > > Discussion appreciated.
> >
> > two thoughts spring to mind:
> >
> > 1. unless they're huge, it's often better to just rewrite crufty old
> > cgi scripts from scratch. at least that way you'll know that they've been
> > written with best practice (incl. best security practice) in mind.
> >
> > actually, even if they're huge it's still a good idea. it just takes
> > longer :)
>
> Well, some people (including me) disagree with you on these claims:
>
> 1. http://www.joelonsoftware.com/articles/fog0000000069.html
> 2. http://www.joelonsoftware.com/articles/fog0000000348.html
there's an enormous difference between a little cgi script and a huge
application like netscape. what applies to one does not necessarily apply to
the other.
rewriting something like netscape would be a bad idea. rewriting a <=
5 page cgi script is, or can be, a good idea. and 5 pages (i.e 132x65
text window screenfuls) is getting on the large side for cgi scripts.
many are only a screenful or two of actual code (not incl. bulk embedded
html, which mostly should be in template files or similar anyway).
> Crufty scripts that don't have strict can be made to have it. If they suffer
> from other problems - these problems can be fixed incrementally while
> maintaining the integrity of the original code. Rewriting the code is much
> more time consuming, introduces more bugs, and requires much more mental
> effort.
and sometimes it's better to just learn from your mistakes, throw away
version 1 and start on version 2.
for small scripts to medium-sized scripts, it's often less work to just
rewrite it from scratch (and/or cutting-and-pasting useful bits of code
- even if just to have the algorithm in the buffer in editable form -
from the original as required), than it is to debug and fix it.
this is particularly true if version 1 was written by someone else who,
of course, had outrageously bad coding habits (as opposed to your own
perfectly sensible and intuitively obvious coding habits :).
the hard part of sw dev is not the coding, it's the design. once you
have the design in your head, the code (mostly :) naturally flows
from that. IMO version 1 is part of the design process - because the
design will inevitably change when theory is hit smack in the face with
reality.
joelonsoftware that you linked to is a pretty good site on software
development philosophy...see the interesting discussion there on the
"plan to throw one version away" chestnut.
http://discuss.joelonsoftware.com/default.asp?joel.3.121537.20
craig
--
craig sanders <cas at taz.net.au>
Reality is an obstacle to hallucination.
More information about the Melbourne-pm
mailing list