Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Crap code
Message
De
15/04/2021 18:26:11
Walter Meester
HoogkarspelPays-Bas
 
 
À
15/04/2021 16:20:40
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
01679827
Message ID:
01679831
Vues:
91
Ok genius, you've got my attention.

First of all you're failing your own rules. No usage of mdot.

Second, it really is a silly example. At runtime there hardly is any time to gain here unless we're talking about more than a hundred thousands of rows. It what Steven Black would call premature optimization. Since you're collecting only limited number of records or else it would error on MESSAGEBOX(), readability should go over optimization over less than a ms followed by a messagebox.


Then you come with the real genius statment of
REPLACE ScanGrL.OutForEOD WITH 0 for ScanGrL.OutForEOD<>0
Which again breaks your own rules as it should be
REPLACE OutForEOD WITH 0 for OutForEOD<>0 IN ScanGrL
And depending on the nature of the table, whether cursor or table stored on network, whether rushmore optimizable or not just as
REPLACE ALL OutForEOD WITH 0
And when you really are concerned about the number of steps in the debugger (hardly an issue in this case), you'd be better of with something like this. No scan needed.
	SELECT TOP 1 CAST('' as M) as Result, 1 FROM ScanGrL ORDER BY 2 INTO CURSOR Result

	REPLACE ALL 	Result.Result WITH ALLTRIM(STR(OrdNmb))+CHR(13) ADDITIVE, ;
					OutForEOD WITH IIF(wScanForEndOfDay = 1, 0, OutForEOD) ;
 			IN ScanGrL

	MESSAGEBOX( Result.Result, 4 + 32 + 256, goApp.cCaption)


So here you have it. All in three freaking lines, 3 STEPS. Congrats !!!

Now, do you really think this is better than the original code? Its cool, it works but is hardly readable.
You better climb off your high horse. You're not a smart as you think you are.

Best regards from the one who does not claim to be a genius and others to be idiots.







>The way FoxPro thinks is often not understood. It's not low-level like C. Every command is interpreted. If there are 20 records, this code will require 84 steps.
>
			GO top
>			SCAN
>				IF wScanForEndOfDay = 1
>					replace ScanGrL.OutForEOD WITH 0
>				endif
>				wMessBody = wMessBody + CHR(13) + ALLTRIM(STR(ScanGrL.OrdNmb))
>			ENDSCAN
>			wnAnswer = MESSAGEBOX(wMessBody, 4 + 32 + 256, goApp.cCaption)
>
>This code will take a lot less time to step through in the debugger. The number of interpretations of the lines of code are way less. 26 steps.
>
			IF wScanForEndOfDay = 1
>				REPLACE ScanGrL.OutForEOD WITH 0 for ScanGrL.OutForEOD<>0
>			endif
>			SCAN
>				wMessBody = wMessBody + CHR(13) + ALLTRIM(STR(ScanGrL.OrdNmb))
>			ENDSCAN
>			wnAnswer = MESSAGEBOX(wMessBody, 4 + 32 + 256, goApp.cCaption)
>
>I'm sick and tired of getting grief from fake geniuses, much less security guards. I am doing the best I can and giving the best advice I can. Keep up, smarten up or shut up.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform