Re: Multiple Statements per Line
- From: "Alex McDonald" <alex_mcd@xxxxxxxxxxxxxxx>
- Date: 7 Apr 2006 13:13:19 -0700
randyhyde@xxxxxxxxxxxxx wrote:
Every now and then, someone around here starts making the claim that[snipped]
having multiple statements per line is good programming style (largely,
this comes from the RosAsm camp where that seems to be the standard
programming style, but other people have posted such code, too).
Multiple statements per line have been possible in programming
languages since the days of Algol-60 (at least), yet you *rarely* see
this facility employed in readable programs. The lack of such usage
should give everyone a big clue that most programmers don't expect to
have to read code written in such a fashion.
Perhaps factoring (aka refactoring) is just as important; that is, as
few lines of code (or statements, or whatevers) per
function/subroutine. Long functions/subroutines are difficult to
understand, and are perhaps best replaced by removing what could be
common sub-functions to somewhere else, and calling them.
Of course, the ultimate in code factoring is not to write the code at
all, unless you really need to. You can put factored code in a shared
source library and INCLUDE it; or an object code library if your
assembler/linker supports it, or at least a run-time load library.
Good factoring makes your code cleaner, faster, and easier to read.
This is the antithesis of cut&paste coding. Resist it!
http://www.cyberconf.org/~cynbe/muq/muf3_5.html#SEC5
http://en.wikipedia.org/wiki/Refactoring
--
Regards
Alex McDonald
.
- Follow-Ups:
- Re: Multiple Statements per Line
- From: randyhyde@xxxxxxxxxxxxx
- Re: Multiple Statements per Line
- References:
- Multiple Statements per Line
- From: randyhyde@xxxxxxxxxxxxx
- Multiple Statements per Line
- Prev by Date: Re: Multiple Statements per Line
- Next by Date: Re: Multiple Statements per Line
- Previous by thread: Re: Multiple Statements per Line
- Next by thread: Re: Multiple Statements per Line
- Index(es):
Relevant Pages
|
Loading