Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQLSERVER Rollback
Message
From
04/01/2019 10:03:13
 
 
To
04/01/2019 03:12:41
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01665065
Message ID:
01665113
Views:
54
I do *try* to do the positive one first but I really like the one that most commonly runs to also be first - especially if there is a lot of code for this condition. I know that the general "rule" is to try to avoid negatives.
IF NOT UserDeactivated
  && do first as 99% of the time user is not deactivated
  && lots of code here; I want to read it first usually (and execute the fastest, though probably this is so negligible in most cases it does not matter)
ELSE
  && user deactivated; very little code just alert and return
ENDIF
And yes, I do just about always comment the ELSE and also the ENDIF - especially if they are nested as it helps me see what ends where.

Thanks.

Albert


>1. if both alternatives are processed, you may want to write the positive comparison first:
>
>if myFlag
>else
>endif
>
>
>2. explicit naming makes it more readable:
>
>if success
>else && error
>endif
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform