Click here to Skip to main content
15,890,393 members

The Insider News

   

The Insider News is for breaking IT and Software development news. Post your news, your alerts and your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be removed. If you wish to ask a programming question please post it here.

Get The Daily Insider direct to your mailbox every day. Subscribe now!

 
GeneralRe: Avoid else, return early Pin
Kent Sharkey26-Mar-18 10:32
staffKent Sharkey26-Mar-18 10:32 
GeneralRe: Avoid else, return early Pin
BillWoodruff26-Mar-18 22:38
professionalBillWoodruff26-Mar-18 22:38 
GeneralRe: Avoid else, return early Pin
Tim Carmichael27-Mar-18 2:35
Tim Carmichael27-Mar-18 2:35 
GeneralRe: Avoid else, return early Pin
TheGreatAndPowerfulOz27-Mar-18 5:44
TheGreatAndPowerfulOz27-Mar-18 5:44 
GeneralRe: Avoid else, return early Pin
Tim Carmichael27-Mar-18 6:19
Tim Carmichael27-Mar-18 6:19 
GeneralRe: Avoid else, return early Pin
TheGreatAndPowerfulOz27-Mar-18 7:15
TheGreatAndPowerfulOz27-Mar-18 7:15 
GeneralRe: Avoid else, return early Pin
#realJSOP28-Mar-18 2:28
mve#realJSOP28-Mar-18 2:28 
GeneralRe: Avoid else, return early Pin
#realJSOP28-Mar-18 1:35
mve#realJSOP28-Mar-18 1:35 
Tim Carmichael wrote:
counter intuitive to the way we think; we process good/expected results first, THEN proceed to look at the outliers.


It's a mixed bag for me. I prefer to exit a method as early as possible, when it makes sense (performing sanity checks on method parameters to ensure they're not null at the top of the method, and throw argument exceptions if they don't meet expected values). After that, I let code go where it needs to go, letting the "true" conditions happen first, and let else handle the "false" conditions.. In the end, I also strive to have a single point of exit instead of having multiple returns sprinkled throughout a method.
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

GeneralRe: Avoid else, return early Pin
TheGreatAndPowerfulOz28-Mar-18 7:22
TheGreatAndPowerfulOz28-Mar-18 7:22 
GeneralRe: Avoid else, return early Pin
#realJSOP28-Mar-18 7:33
mve#realJSOP28-Mar-18 7:33 
GeneralRe: Avoid else, return early Pin
TheGreatAndPowerfulOz28-Mar-18 15:47
TheGreatAndPowerfulOz28-Mar-18 15:47 
GeneralRe: Avoid else, return early Pin
Dr.Walt Fair, PE6-Apr-18 13:18
professionalDr.Walt Fair, PE6-Apr-18 13:18 
GeneralRe: Avoid else, return early Pin
#realJSOP8-Apr-18 6:22
mve#realJSOP8-Apr-18 6:22 
GeneralRe: Avoid else, return early Pin
Dr.Walt Fair, PE30-Mar-18 5:36
professionalDr.Walt Fair, PE30-Mar-18 5:36 
GeneralRe: Avoid else, return early Pin
TheGreatAndPowerfulOz27-Mar-18 5:37
TheGreatAndPowerfulOz27-Mar-18 5:37 
GeneralRe: Avoid else, return early Pin
Joe Woodbury27-Mar-18 7:32
professionalJoe Woodbury27-Mar-18 7:32 
GeneralRe: Avoid else, return early Pin
Dominic Burford28-Mar-18 2:49
professionalDominic Burford28-Mar-18 2:49 
GeneralRe: Avoid else, return early Pin
S Douglas30-Mar-18 6:56
professionalS Douglas30-Mar-18 6:56 
NewsThe FTC confirms it’s investigating Facebook over its privacy practices Pin
Kent Sharkey26-Mar-18 7:45
staffKent Sharkey26-Mar-18 7:45 
GeneralRe: The FTC confirms it’s investigating Facebook over its privacy practices Pin
Nelek26-Mar-18 11:08
protectorNelek26-Mar-18 11:08 
GeneralRe: The FTC confirms it’s investigating Facebook over its privacy practices Pin
Kent Sharkey26-Mar-18 11:14
staffKent Sharkey26-Mar-18 11:14 
GeneralRe: The FTC confirms it’s investigating Facebook over its privacy practices Pin
Nelek26-Mar-18 11:18
protectorNelek26-Mar-18 11:18 
GeneralRe: The FTC confirms it’s investigating Facebook over its privacy practices Pin
Dr.Walt Fair, PE6-Apr-18 13:19
professionalDr.Walt Fair, PE6-Apr-18 13:19 
GeneralRe: The FTC confirms it’s investigating Facebook over its privacy practices Pin
Kent Sharkey6-Apr-18 14:22
staffKent Sharkey6-Apr-18 14:22 
NewsA critical analysis of the latest cellphone safety scare Pin
Kent Sharkey25-Mar-18 10:15
staffKent Sharkey25-Mar-18 10:15 

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.