I came across the following in some sample code:if (urlStr){    NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:urlStr];    node.nodeIcon = iconImage;}else{    // it's a separator, don't bother with the icon}Is this style of using an else statement only for a comment good practice for production or it is only useful for code used as an example?
Should an Else statement be used just for a comment?
comments;if statement
For the programmer reading it, I think it makes it quite clear. I am used to reading if condition do stuff else do other stuff, so I can parse that pretty easily. The else block seems like a really logical spot for a comment explaining why we don't want to do anything in that condition. But, will it make a significant impact if we have the empty block there? Is improved clarity for humans worth the cost? I think that's a language-specific (or rather, compiler/interpreter specific) question. The only time I can think that this could have some negative impact is if it's in a bottleneck that needs to be ultra-optimized. Even in those cases, it might make no difference. Here's an example of how I would check, for C. sometimes it makes no difference to the compiled codeshort.cint main() {  if(1) {    printf(Hello World);  }}long.cint main() {  if(1) {    printf(Hello World);  } else {    // not possible  }}Then I compiled both with the -S option to compile without assembling. I compared the assembly files and they were identical. sometimes it does make a difference to the compiled codeI then updated the files and replaced if(1) with int foo = 1; if(foo) and repeated the process. (I know, the block is still not reachable - so if the compiler still treats it as unreachable I have proved nothing, but if the compiler treats it as reachable then I know I have successfully tricked the compiler and I have proven my point.) In this case, the compiled files were not identical - the compiler did not ignore the empty else block when it thought it was reachable. short.s  ## call to printf, etc. (i.e. the if block)...LBB0_2:  ## rest of code...long.s  ## call to printf, etc. (i.e. the if block)...  jmp LBB0_3 ## ! there is always a jump statementLBB0_2:  jmp LBB0_3LBB0_3:  ## rest of code...So in this almost reachable version, when the empty else block is included, there is an extra jump statement at the end of the if block. So if performance is a key concern here, then adding the empty else block is not a good idea.conclusionBased on the language, the else block could change the compiled code and affect performance. You would have to check for whichever language you're using, and then if it does have a performance hit in your language, decide if performance is more important than readability in this section of code. 