Re: test if a string is a valid 'number'?

Tech-Archive recommends: Fix windows errors by optimizing your registry



My code does work, does sell, and doesn't require grotesque solutions. I can write an FSM
to parse an integer in less time than it takes to discover how to find a function in VB,
invent a way to call it, and create distribution package that includes the DLL. In fact,
I can write an FSM to parse an integer as fast as I can type it in.

The "need it NOW" approach has led to more bad decisions, some of which took MONTHS to
undo, and some of which cost us customers because the problems that resulted created code
that was unreliable.

The best possible solution would be an optimized FSM, but an optimized FSM takes too long
to write and doesn't matter when the unoptimized version can parse a number in under a
microsecond. But a kludgy solution remains a kludgy solution. The long-term implications
of code that is this bad are far more serious.

This violates the KISS principle: Keep It Simple. It adds unnecessary complexity to the
system, creating failure points that do not need to exist. The simplest one that should
be at the forefront of all decisions is "Will it run under Win64?", which this clearly
will not (The Win64 compilers do not support embedded assembler, and you can't call 32-bit
DLLs from 64-bit apps).

One company I worked for failed because management kept pushing for quick solutions, and
would not accept the time required to do correct solutions. I learned a lot about project
management from that company, mostly from antipatterns of bad management. I got a lot of
flak because I would not accept short-term kludges, yet my code didn't break. Everyone
who did quick & dirty solutions ended up having to rewrite their code again and again to
get it right. The result was a failure to ship (my code, for example, was running solidly
for a YEAR while the code around it got rewritten and rewritten and rewritten until that
particular project failed. During that year, I ended up rewriting several modules for
other people, and once rewritten, my code remained solid and required no support
whatsoever. Meanwhile, the quick & dirty code got rewritten yet again...)

I have no respect whatsoever for the kind of solutions that this code demonstrates,
because I've seen the ultimate consequences of these solutions, code that breaks far too
easily.
joe
*****
On Wed, 30 May 2007 22:25:27 -0700, "Ashot Geodakov" <a_geodakov@xxxxxxxxxxxxxxxxxx>
wrote:

Oh c'mon, you may write the most beautiful code in the world that won't work
and won't sell. While you spend time searching for the best possible
solution (which doesn't exist, by the way), customers take their business
elsewhere.

"It must work, and it must work NOW" is what I've heard thousand times...

"Joseph M. Newcomer" <newcomer@xxxxxxxxxxxx> wrote in message
news:0vds53l3v1g69sbitss72g5l11lmmeraeo@xxxxxxxxxx
"It works" is one of the weakest justifications for bad code I have had to
put up with in
my career. Not only is the solution baroque, horribly inefficient, and
non-portable, to
start with its major flaws, but is completely unnecessary because you can
write the FSM
parser in a fairly minimal amount of effort, vastly less effort than was
required to
conjure this off-the-wall solution!

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: test if a string is a valid number?
    ... I can write an FSM to parse an integer as fast as I can type it in. ... If you care so much about Win64 (which is really not so widely spread in the ... Rewriting it for the sake of beauty wastes more time than fixing a bug, ...
    (microsoft.public.vc.mfc)
  • [ANN] ParseTree 2.0.0 Released
    ... Uses RubyInline, ... Includes UnifiedRuby, allowing you to automatically rewrite ruby quirks. ... ParseTree#parse_tree_for_string lets you parse arbitrary strings of ruby. ...
    (comp.lang.ruby)
  • Rewrite last line in text file
    ... I do not want to have to rewrite the ... entire file each time or to have to parse the file from the beginning, ... Regards ... Magnus Oskarsson ...
    (borland.public.delphi.language.objectpascal)
  • Re: Many warnings from our userspace headers
    ... Correct - but we can rewrite it like this: ... This is at least for me also easier to parse. ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: Adding Headers in ASP.NET on vista
    ... I think I will go with your last suggestion. ... I have an odd situation ... where I have to parse the url and sometimes rewrite it and sometimes ... The only downside I can see is that I have to parse the ...
    (microsoft.public.dotnet.framework.aspnet)