Null references (oh no, not again!)

Walter Bright newshound1 at digitalmars.com
Wed Mar 4 23:04:16 PST 2009


Nick Sabalausky wrote:
> "Walter Bright" <newshound1 at digitalmars.com> wrote in message 
> news:gonnf4$2mnj$1 at digitalmars.com...
>>> The code is bug-ridden. It's exactly the kind of maintenance nightmare 
>>> where you change one line and 1000 lines below something crashes.
>> It does occur in various forms. I know this from experimenting with flow 
>> analysis. The problem with saying it's "buggy" is then the programmer 
>> throws in a dead assignment to "fix" it rather than refactor it.
>>
>>
> 
> If someone has code like that than the main issue is that it needs to be 
> refactored. Neither the current status of D, nor "perfect" flow-analysis 
> would do anything to force, or even nudge, the programmer into doing that 
> refactoring. So if C#-style analysis doesn't force the proper refactoring 
> either, so what? At least attention will get called to it and the programmer 
> will at least have the *opportunity* to choose to fix it. And if they choose 
> to do the dead-assignment hack, well, the code's already crap anyway, it's 
> not like they're really all that worse off.

This is the same argument for mandatory exception specifications that 
Java had. Bruce Eckel wrote a fascinating article about it, showing that 
even the experts who denigrated and dismissed the "bad style" of the 
quick and dirty fix, used it themselves. The excuse was always "I'll fix 
it later" and of course it never got fixed.

We could debate what good style is and is not, but I think we can agree 
that the ideal language should make it easy to do good style, and more 
effort to do bad style, because programmers will naturally follow the 
path of least resistance - even the ones that know better.

That's why php is so popular, yet reviled <g>.



More information about the Digitalmars-d mailing list