Actually, I wasn’t surprised to find about a dozen different questions in the same gist, but here is the one that I really liked, especially some of the more interesting answers: How many lines should a method typically have?.
And to quote one of the answers that I really liked:
It should fit in my head.
That is to say, if I put my head against the monitor, the method should not be seen as extending past the boundaries of my head.
So what do you think should a method’s size be?
The way I see it – in the simplest terms – a function or method should be only as long to do one logical operation and no more. That being said, if your one logical operation is to large to fit on the screen, then something is very wrong with your logic 🙂 .
- The best programming questions and answers site – if you’re a programmer by trade or hobby and you’re not familiar with Stack Overflow, then go register. [↩]