>   1. RE: [NF]The best code is "No Code At All" (Stephen the Cook)
> Message: 1
> Date: Sat, 2 Jun 2007 09:00:25 -0500
> From: "Stephen the Cook" <[EMAIL PROTECTED]>
> Subject: RE: [NF]The best code is "No Code At All"
> To: [EMAIL PROTECTED]
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain; charset="us-ascii"
>
> Derek Kalweit <> wrote:
>
> > A function of half a dozen lines is sometimes far
> > easier to read than one of 5 lines. I try to code to make things
> > clearly readable and explicit and only shorten/compress the code if
> > needed for optimization. If I feel the optimized code is too hard to
> > read, I leave the non-optimized code in comments as well.
>
> Was that 6 lines was easy to read and 5 was difficult?
>

I'd like to point out this article again:
http://msvfp.advisorguide.com/doc/17440

Using it, you can take a "formula" or snippet and replace placeholders
with field names. This allows you to reuse simple or complex formulae
and document them as completely as you want, while making them
maintainable in a single place and keeping the speed almost as high as
if it was coded manually. It's not "no code at all" which cannot be of
any use to anyone, it's "only one piece of code" - which is what we
really should have. The code is a blueprint. There should only be
single copies of the blueprints. You have 6 spark plugs in the engine
(at runtime), but they are all derived from 1 blueprint (at design
time).

PADR(ALLTRIM(<<lastnameplaceholder>>) +
IIF(EMPTY(<<lastnameplaceholder>>) AND
EMPTY(<<firstnameplaceholder>>),"",", ") +
ALLTRIM(<<firstnameplaceholder>>),<<lengthplaceholder>>)

becomes

PADR(ALLTRIM(cSurname) + IIF(EMPTY(cSurname) AND
EMPTY(cFirstName),"",", ") + ALLTRIM(cFirstName),50)

I have used it in crosstabs so instead of typing 12 copies of a
potentially complex formula I create the crosstab query more like
this:

TEXT TO lcSQL
SELECT
  <<MonthlySumSnippet(1)>> as Amount1,
  <<MonthlySumSnippet(2)>> as Amount2,
  <<MonthlySumSnippet(3)>> as Amount3,
  <<MonthlySumSnippet(4)>> as Amount4,
  <<MonthlySumSnippet(5)>> as Amount5,
  <<MonthlySumSnippet(6)>> as Amount6,
ENDTEXT

Mike


_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to