Code blocks must be short


Link to this posting

Postby Ursego » 21 Feb 2013, 15:45

Keep the operators, which open and close the block, on one screen. If it's impossible then refactor (extract) the block into a brand new function.

A code block is a fragment, placed between opening and closing operators. These operators are (in different languages):

1. Special code block delimiters: braces ({ and }) in C-like languages and BEGIN/END in PL/SQL and Transact-SQL.
2. Code branching operators (like IF ... ELSE ... END IF).
3. Looping operators (FOR ... NEXT, LOOP ... END LOOP, DO ... WHILE etc.)

That solution will also decrease the indenting. For example, the fragment

Code: Select all
if ([condition]) {
   [very long code fragment with its own indents]
}

will be looking in the new function as

Code: Select all
if (![condition]) return;
[very long code fragment with its own indents]

But that is already the subject of the topic "Code after validations".
User avatar
Ursego
Site Admin
 
Posts: 140
Joined: 19 Feb 2013, 20:33



IF you want to ((lose weight) OR (have unbelievable (brain function AND mental clarity))) THEN click:




cron
Traffic Counter

free counters

eXTReMe Tracker