Re: Multiple Statements per Line




randyhyde@xxxxxxxxxxxxx wrote:
Every now and then, someone around here starts making the claim that
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.

[snipped]

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

.



Relevant Pages

  • Re: Multiple Statements per Line
    ... making the claim that having multiple statements ... to be the standard programming style, ... If no one other than yourself ever reads your code, the readability is ...
    (alt.lang.asm)
  • Multiple Statements per Line
    ... programming style, but other people have posted such code, too). ... Multiple statements per line have been possible in programming ... and you have to switch to assembler ...
    (alt.lang.asm)
  • Re: A sample RosAsm macro (actually a whole set)
    ... > stick with RosAsm). ... rather than the underlying language. ... all this before) concerning good programming style, ... By placing multiple statements per line, ...
    (alt.lang.asm)
  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... > The real question is "do you want the programming language to enforce ... > RosAsm allow multiple statements per line, the HLA programming ... OTOH, the RosAsm programming style ...
    (alt.lang.asm)
  • Re: Multiple Statements per Line
    ... having multiple statements per line is good programming style (largely, ... "Good Asm Programing is re-inventing the wheel, or, at least, always ...
    (alt.lang.asm)

Loading