Click here to Skip to main content
14,303,166 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: true-false or false-true Pin
Member 798912217-Jul-19 3:23
memberMember 798912217-Jul-19 3:23 
GeneralRe: true-false or false-true Pin
Rage17-Jul-19 0:57
professionalRage17-Jul-19 0:57 
GeneralRe: true-false or false-true Pin
Rick York17-Jul-19 4:47
mveRick York17-Jul-19 4:47 
GeneralRe: true-false or false-true Pin
Rage17-Jul-19 4:48
professionalRage17-Jul-19 4:48 
GeneralRe: true-false or false-true Pin
mdblack9817-Jul-19 1:38
membermdblack9817-Jul-19 1:38 
GeneralRe: true-false or false-true Pin
Gary Wheeler17-Jul-19 1:41
memberGary Wheeler17-Jul-19 1:41 
GeneralRe: true-false or false-true Pin
obermd17-Jul-19 3:25
memberobermd17-Jul-19 3:25 
GeneralRe: true-false or false-true Pin
Member 798912217-Jul-19 3:50
memberMember 798912217-Jul-19 3:50 
For me, it depends.

From my "programming childhood" I was brought up to write every funcition as a (1) verify all arguments and preconditions, (2) do the work, (3) prepare the results.
If in step 1 any precondition is not satisfied, then you prepare an error return and get out of there, making no changes. Don't even look at the work and result stages.

If anything in step 2 prevents you from creating a complete result, then you prepare an error return and get out of there, without any side effects or other kinds of results.

In step 3, with all preconditons met and all work successfully completed, you do whatever possible to preserve the results (e.g. wait for locks to be released). If all functions are written in this orderly manner, you very rarely run into problems in this step.

These "Get out of there" tests are usually semantically negative, even though they may be syntactically positive ("if (parameter outside legal range) ..."). The essential part is: Don't bother the clean work with debris (I count "n" levels of extra indentation due to validity checks as "debris"!). If there is nothing more you can do, then leave!

Any test that ends up in an abort/termination is placed as early as possible - and then there is no "else" and no extra indentation.

Within step 2, and sometimes even in step 1, the "if" selects one of two equally valid actions, or they are elseif-alternatives. In such cases, I write the test so that the most likely case comes first (even when that requieres negation of the logical expression). An elseif-sequence is ordered in decreasing likelyhood. The final else is the least likely one - like a default at the end of a switch case statement.
GeneralRe: true-false or false-true Pin
James Lonero21-Jul-19 11:52
memberJames Lonero21-Jul-19 11:52 
GeneralThought of the Day Pin
OriginalGriff16-Jul-19 4:48
protectorOriginalGriff16-Jul-19 4:48 
GeneralRe: Thought of the Day Pin
littleGreenDude16-Jul-19 5:21
memberlittleGreenDude16-Jul-19 5:21 
GeneralRe: Thought of the Day Pin
  Forogar  16-Jul-19 5:23
professional  Forogar  16-Jul-19 5:23 
GeneralRe: Thought of the Day Pin
W Balboos16-Jul-19 5:29
mveW Balboos16-Jul-19 5:29 
GeneralRe: Thought of the Day Pin
Rick York16-Jul-19 7:04
mveRick York16-Jul-19 7:04 
GeneralRe: Thought of the Day Pin
Daniel Pfeffer16-Jul-19 10:02
professionalDaniel Pfeffer16-Jul-19 10:02 
GeneralRe: Thought of the Day Pin
jsc4216-Jul-19 23:25
professionaljsc4216-Jul-19 23:25 
GeneralI'm baaack Pin
Marc Clifton16-Jul-19 2:49
protectorMarc Clifton16-Jul-19 2:49 
GeneralRe: I'm baaack Pin
theoldfool16-Jul-19 3:04
professionaltheoldfool16-Jul-19 3:04 
GeneralRe: I'm baaack Pin
Mike Hankey16-Jul-19 3:28
professionalMike Hankey16-Jul-19 3:28 
GeneralRe: I'm baaack Pin
glennPattonWork16-Jul-19 3:46
professionalglennPattonWork16-Jul-19 3:46 
GeneralRe: I'm baaack Pin
Rage16-Jul-19 4:59
professionalRage16-Jul-19 4:59 
GeneralRe: I'm baaack Pin
  Forogar  16-Jul-19 5:24
professional  Forogar  16-Jul-19 5:24 
GeneralRe: I'm baaack Pin
Kornfeld Eliyahu Peter16-Jul-19 6:32
mveKornfeld Eliyahu Peter16-Jul-19 6:32 
PraiseRe: I'm baaack Pin
GKP199216-Jul-19 7:40
professionalGKP199216-Jul-19 7:40 
GeneralRe: I'm baaack Pin
Nelek16-Jul-19 9:49
protectorNelek16-Jul-19 9:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.