4 ms·
If by readable you mean proportional, then I believe a lot of the resistance comes from vertical alignment issues. For instance: def func_with_lots_of_parms
by artlogic 14y ago
If by readable you mean proportional, then I believe a lot of the resistance comes from vertical alignment issues. For instance:
def func_with_lots_of_parms(parm1, parm2,
parm3, parm4):
In my experience that's pretty difficult to do consistently with a proportional font, and then when someone changes to a different font, the alignment will be off.
To me, formatting code is more about creating a good experience for other people (and future me) and less about pleasing present me.
- Stratoscope 14y agoThere's a way to eliminate vertical alignment issues and make your code equally readable in a proportional or monospaced font: don't use vertical alignment. About ten years ago, I got tired of having to adjust the spacing whenever I edited the function name in code using vertical alignment. I'd been running across too many cases where people would take code like this: def func_with_lots_of_parms(parm1, parm2, parm3, parm4): and change it to: def betterFunctionName(parm1, parm2, parm3, parm4): Oops. So I asked myself, who do we have a different rule for indenting with parentheses than we do for braces? We don't indent functions like this (JavaScript example): function foobar(param1) {doSomething(); doSomethingElse(param1); andWrapItUp(); oneMoreThing();} Geez, you'd have to re-indent the whole thing if you came up with a better name for foobar()! So I tried indenting function parameter declarations and function calls just like function bodies, and I found I liked it quite well: def func_with_lots_of_parms( parm1, parm2, parm3, parm4 ): doStuff() or JavaScript: function doSeveralThings( param1, // one interesting param param2, // another interesting param paramWithLongerName, // comment too, but don't "align" comments lastParam // that's enough ) { doOneThing(); finishUp(); } Some time later I discovered that whatever version of Visual Studio I was using back then supported proportional fonts, so I tried it out and found my code looked pretty much the same either way, just nicer looking and more of it fitting on the screen with the proportional font. If I'd still been using a lot of column alignment, though, I probably wouldn't have liked the proportional fonts at all.