Software Module size and file size

How long should a software module be?  How many lines of code should a file have?  These are some of the questions that my colleague and I were discussing regarding software engineering practices; and I thought it was worth posting.

In our dialog, I mentioned that a module size, in general, should not exceed 200-400 lines of codes.  

If you count comments and white spaces, you can probably double this number.

In this posting I will share with you why I think a module size should not exceed 400-800 lines (including comments and whitespace), and why a file should not exceed 4000 lines of code.

Continue reading