241 reputation
18
bio website stackoverflow.com/users/23118/…
location Norway
age 41
visits member for 3 years, 7 months
seen 2 days ago
Linux user since 1994. Main programming language: C.

Dec
2
comment Elegant ways to handle if(if else) else
It is very common to use goto like this. The linux kernel contains a 5-digit number of goto statements.
Dec
1
awarded  Nice Answer
Nov
30
revised Elegant ways to handle if(if else) else
spelling correction
Nov
30
awarded  Editor
Nov
30
revised Deciding factors in pair programming
spelling correction
Nov
30
answered Elegant ways to handle if(if else) else
Nov
30
comment Elegant ways to handle if(if else) else
And another aspect is that the code written this way is orthogonal. For instance the two lines "if(!FileExists(file))\n\tgoto notexists;" are now ONLY related to handling this single error aspect (KISS) and most importantly it does not affect any of the other lines. This answer stackoverflow.com/a/3272062/23118 lists several good reasons to keep code orthogonal.
Nov
30
awarded  Critic
Nov
30
comment Elegant ways to handle if(if else) else
Yes, Yes! This is the absolutely "right" way to write code. The structure of the code now is "If error, handle error. Normal action. If error, handle error. Normal action" which is exactly like it should be. All the "normal" code is written with just a single level indentation while all the error related code has two levels of indentation. So the normal AND MOST IMPORTANT code gets the most prominent visual place and it is possible to very quicly and easily read the flow sequencially downwards. By all means accept this answer.
Nov
21
awarded  Teacher
Nov
21
answered What are some common examples of a Parallelizable problem?
Feb
4
comment What are useful metrics for source code?
Ah, excellent. Very nice to have some specific numbers to refer to. Thank you.
Dec
20
comment What are useful metrics for source code?
As far as I remember typical industry numbers are around 2-3 errors per 1000 lines of code for average projects, approaching something like 0.5 errors per 1000 lines of code for nuclear plant control software or NASA projects where they put down an enourmous amount of effort, control, testing, review, etc because failures can have very severe consequenses. Anyone that have some reference to numbers supporting this?
Dec
20
answered Deciding factors in pair programming
Dec
20
comment What parts of your coding standard contribute to quality code?
Indeed. In my oppinion there are three ways to write code: 1) write unreadable code. 2) write unreadable code and comment it readable. 3) write readable code.
Dec
20
awarded  Supporter
Dec
20
comment Is using ELSE bad programming?
I do not try to avoid else as such, but I think I agree with what you write. The point is that the thing you are testing should be the exception and not the normal case (stackoverflow.com/questions/114342/…). Here authentication failure is the exception and (only) that should be tested.
Dec
20
awarded  Autobiographer
Aug
11
answered How to Leverage Clearcase's features