Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I shortcut this code?
Message
De
12/01/2000 08:58:57
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
11/01/2000 16:46:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00316384
Message ID:
00316880
Vues:
18
>>I have some fields in a table. I want to check this bunch of fields to see if they are all EMPTY(). What's the best way to do it? Maybe I need to use EMPTY() instead? But I was comparing one after another and it was not very efficient. Thanks in advance.
>
>You've gotten a ton of replies giving shorter, more cryptic ways of doing things. I'm now going to recite sermon # 1,937, "Clever one-liners are bad!"
>
>We had this discussion about a week ago; JVP posted a semi-cryptic one-liner, and a UDF with a CASE statement that accomplished the same thing, and asked "Which is better?" The respondents whose opinions I value, mine, Jim Booth's, and Christof Lange's were an interesting perspective.
>
>All three of us said that where the number of repetitions was unimportant, the UDF was the better alternative, because its intent was clearewr and it was more maintainable and extensible. I went on to say that the one-liner offered advantages in a WHERE clause of a SQL Select or a FOR statement, for no reason other than the UDF overhead.
>
>I was right; the UDF took nearly twice as long to execute as the one liner. This amounted to a 3 second difference in execution speed in 1,000,000 iterations. Oops. The performance cost was more than recovered the first time someone else had to look at the code and figure out "whut duzzit dew?"
>
>Sacrificing clarity for speed is a bad tradeoff, especially where the speed increase is minimal. Get things working in an understandable, well-documented, boringly obvious fashion first; if speed is a problem, and there are clear indications that the problem lies in an area where a less obvious, more obscure approach, try it, but leave the obvious, easy approach there commented out, and document what you do heavily.
>
>Coding, contrary to popular belief, is (or should be) relatively boring and consistent. If there are five ways of doing something, I tend to use one way all the time, so that the next guy in has a clue about how I'll implement something - once he understand my approach to implementing something, he won't be confronted by another equivalent but syntactically different block of code just because I felt like doing it that way. I'm even more appreciative of my lack of original thought when I'm the guy picking up the code a year or two down the road...
>
>I've never gotten a job because I could code in 5 lines what someone else needed 10 line of code to accomplish. Plenty of my clients hire me because once I've got it working someone else can figure it out.


Ohh but I love tricks :) Kidding you're right my friend. Still here goes my 0.2 cents of "clever few liner" < bg >
function isAllEmpty
scatter name oEmpty memo blank
scatter name oCurrent memo
return compobj(oEmpty, oCurrent)
I know it doesn't think of general fields.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform