I did my "Skimmable Code" talk yesterday and from the response it seems to have gone over very well. One thing that caught me entirely off guard was the response to the suggestion that end-of-block comments are a red flag for skimability and, once the block has been refactored to be shorter, should be removed.
while( $something > 42 ) { ...some code... ...and stuff... } # while $something > 42
for my $value ( @_ ) { # Handle type/value pairs an arrayref if ( ref $value eq 'ARRAY' ) { my ( $type, $value ) = @$value; while ( my $input = shift @inputs ) { next if $input->type eq 'hidden'; if ( $input->type eq $type ) { $input->value( $value ); $num_set++; last; } } # while } # by default, it's a value else { while ( my $input = shift @inputs ) { next if $input->type eq 'hidden'; $input->value( $value ); $num_set++; last; } # while } } # for
(show-paren-mode)
Re:Appropriate Magic(tm)
schwern on 2008-06-18T18:39:33
That doesn't appear to do anything if the other paren if off the screen. Maybe I don't have some other magic set. Does it work for you?Re:Appropriate Magic(tm)
jplindstrom on 2008-06-19T01:12:59
Um, from reading your text, "If I can't have my jetpack I can at least have an editor that can show me where a block starts. Emacs does this when you type the closing brace. I'm not sure how to get it to do it on-hover", I understood that as "highlight the matching curly" whenever the cursor is on a { or }
(similar to "mouse hover", but Emacs isn't very mouse oriented in general...)
Did you mean something else?Re:Appropriate Magic(tm)
schwern on 2008-07-06T10:38:37
Um, from reading your text, "If I can't have my jetpack I can at least have an editor that can show me where a block starts. Emacs does this when you type the closing brace. I'm not sure how to get it to do it on-hover", I understood that as "highlight the matching curly" whenever the cursor is on a { or }
It's not very useful if the matching curly has scrolled off the top of the screen, ie. I can't see it. Setting show-paren-style to "parenthesis" it will highlight the other paren, which is off screen. If I use "expression" it will highlight the whole block, but the condition still lies off screen and out of sight.
What I really want is it to say "Matches if( foo ) {", like it does when you type a closing brace. Show me the first line of the block so I can see the condition, the important bit.
(similar to "mouse hover", but Emacs isn't very mouse oriented in general...)
This is why I use Aquamacs.
:) But really I just mean when the cursor is over a paren or brace rather then when it's typed.
Re:An idea for the IDEs..
jplindstrom on 2008-06-18T12:36:25
Or you could display it permanently at the end of the block, making it look like a tooltip or something, but not as a comment in the source code. (in Emacs, an overlay)
I'm note sure I'd appreciate it though, it may be too noisy.
Maybe it would be useful if it was only displayed whenever the block is longer than n lines, or whenever the other side of the block isn't visible.
This may be one of those things that sound good/bad, but you won't really know how it pans out until you try it:)
Re: folding
Eric Wilhelm on 2008-09-07T05:19:51
... of course one can use folding in Vim as well. If you're doing it right, the block is usually short enough that folding it isn't worthwhile.
End of scope comments are a pet hate of mine, for all the reasons you've given. And it's one of those things that people seem to cling to, as if it's a best practice like TDD.
I hate clutter of any sort in code... which is a shame since I have to use Java for my next project...