(If not: please move the topic)
I am gathering opinions on the following matter from seasoned developers. Or at least people with more programming experience than I have (which is about half this planet ...)
How would you structure this code (and why?)
Is there a third option?
Are there guidelines somewhere?
Thanks in advance!
Option 1
Code: Select all
Action 1
if result 1 {
action 2
if result 2 {
action 3
If result 3 {
report success
} else {
report exception 3
}
} else {
report exception 2
}
} else {
report exception 1
}
Code: Select all
Action 1
if not result 1 {
report exception 1
return
}
Action 2
if not result 2 {
report exception 2
return
}
Action 3
if not result 3 {
report exception 3
return
}
report success