Sean McGrath writes about a correlation between screen size and method length
Funny, I never thought about the number of lines on the screen, only about number of characters on one line.
I'm normally limiting myself to some 70-80 characters max, which limits your amount of indentation. After three
for statements, the space starts getting narrow. This pushes you to splitting things up a bit into different methods.
Thinking about his lines/screen ratio... Dunno. When one single method starts getting past a page or two, I normally split it to make it a bit more browseable. A few more lines on your screen extra probably delays this for a bit, but that only effects methods with, say, 30-50 lines, not the 30- or 50+ ones.
Characters/line has much more effect. I'm refactoring/reformatting some existing code that happily puts 150 characters on one line. Ouch. To counter it, I have to introduce more variables and some additional methods. The amount of code goes up, but it's much clearer in my opinion. Instead of calling a method and doing all sorts of calculations in-place for parameters... :
# before method1('test', len(self.something.objectIds()), self.somewhere.pipe) # after amountOfContent = len(self.something.objectIds()) outputPipe = self.somewhere.pipe method1('test', amountOfContent, outputPipe)
Might be personal preference, though :-)
My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):