I spent too many years in PL/I, where nested functions and subroutines look
like this:
outer: procedure (param1);
declare param1 char(4);
declare local char(1);
put skip;
put skip list ('hello outer');
put skip;
inner: procedure (param1, param2);
declare param1 char(4);
declare param2 char(4);
declare local char(4);
put skip;
put skip list ('hello inner');
put skip;
end inner;
end outer;
Indenting preferences aside, that made *vertical* spacing a no-brainer.
Put a blank line before the procedure declarations, another after the
parameters, another after the locals, and one each before and after the end
statements, and everything looks nice, at least to me. (This will actually
look really funny to Ed, who's probably used to much more segmented-style
declarations.)
But I haven't found a style in Ruby that makes me happy yet. It always
looks so unbalanced:
module Mod
class Klass
def one_method(param1, param2)
puts
puts "hello world"
puts
end
def two_method
puts "hello again"
end
end
class NotherKlass
def three_method
puts "hi already"
end
end
end
No matter how I space it, either the "end" statements look detached from
their class, so nesting is hard to follow, or the def looks detached, or
everything runs together, depending on how many lines are in the routine,
how long the method name is, how many methods/classes are in a row, etc.
I can't find a spacing rule that I like more than 50% of the time. Not 50%
of the *cases*, mind you - all the cases, just different solutions in
different moods. I'm pretty sure I spend 50% of my time deleting and
re-adding newlines on end statements
Has anyone (as obsessive as I am) found a simple, aesthetically pleasing
pattern to follow? I like programming to be art, but not Colorforms art.
···
--
Jay Levitt |
Boston, MA | My character doesn't like it when they
Faster: jay at jay dot fm | cry or shout or hit.
http://www.jay.fm | - Kristoffer