[Tutorial] Beautiful, Readable Code (Indentation, Whitespace, Comments)
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
Nested if are another good point. Some people insist on having an if-else-return structure when checking for prerequisites. Just make out for yourself which one's more readable: http://pastebin.com/Ji50mQQN
The real difference in those structures is the first example requires return statements but the second example does not require return statements to which one is more readable? I would go with the second example since multiple returns tend to cause code to become convoluted with multiple exit points. Now in that example is certainly not the case but when you get 100 lines with no indentation with a dozen returns it looks ugly and has no flow.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)