Re: Factoring - a newbie question



"Robert Miller" <rsmiller@xxxxxxxxxxxx> wrote:

Is there any rule of thumb about when to factor lengthy words?
[....]

The target processor is a TI MSP430 and in this instance neither speed
nor space are important issues. Once the word is tested, readability
matters only if I (or someone else) have to revisit this particular
word - which I think is unlikely, but one never knows.

Ah, a trick question. You don't need speed or space or readability, and
the word already works.

So any change you make provides a chance that you'll introduce a bug
that you'll then have to fix.

There's even a chance that you'll introduce a bug that you won't find
right away, and then when it isn't fresh in your mind you'll have to
zero in on it and fix it, even more time.

And there's some small chance that the bug won't show up at all until
somebody else uses your code and they present you with a bug report. Big
problem for them and for you.

Balancing that, when you make the code simpler and more readable there's
a better chance that you'll fix an undiscovered bug than that you'll
introduce a new one. The only virtue of the more-complex code is that
it's been tested and used some, and you haven't noticed any errors yet.

So my natural thought is that if you have the leisure time to rewrite
this, and it's something you like to do, then go ahead. But if you have
something better to do, leave it alone. On the other hand, if you're
already spending time debugging then you might as well simplify.
Particularly when it looks obvious. Since you're rewriting your test
suite anyway, it might be less work to simplify than not to. Go ahead
and simplify whatever you can, and test it together, and maybe get a
much better product for a comparatively small effort. Time spent
simplifying is better than time spent debugging something complicated.
But only if you don't already have it stable.
.



Relevant Pages

  • Re: Generics vs Individual classes
    ... class, mainly for readability. ... And that off chance I'll add a collection ... strongly-typed collection for that user. ... Generics over the method mentioned above. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Critical Bug Report in the JIT Engine of .NET Framework (v1.0/1.1/
    ... This bug is not a common case and you might not have a chance to engage into ... One of my friend said that, not only when you use the reference of variable ... int i = int.Minimum; ...
    (microsoft.public.dotnet.framework)
  • Re: Software Reuse In Embedded code
    ... "goto error" in a function that ends like this: ... Sometimes simplying the logic can help to increase readability, ... and in that case I obviously simplify the logic. ... A algorithm that natually has 8 logical steps to it ...
    (comp.arch.embedded)
  • Re: Non-random PIDs
    ... The random-PID patch might decrease ... the chance of exploiting a certain bug by a small factor, ... but that's no substitute for actually fixing the bug ... ... It's a bit like using slighty randomised file names in ...
    (RedHat)
  • Re: Bug in Mathematica 6 - Integrate - 33 - (Sinh, Cosh, Sqrt, unnecessarily arcane unsi
    ... This is a bug because for a freshman level integral Mathematica, ... it's easy for a freshman to find a substitution. ... answer, and worse still, attempts to simplify the weird stuff fail. ...
    (sci.math.symbolic)