This question already has an answer here:

I've built an ASP.Net component, for example, which consists of a base class with 670 lines of code, a sub class with 180 lines, plus some code to illustrate it's usage.

I think this is a perfect place to get a wide variety of code review feedback, but is 850 lines just too much?

marked as duplicate by Simon Forsberg, rolfl Jun 2 '15 at 23:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 6 down vote accepted

The only hard limit is the 65,536 character limit that Stack Exchange imposes on all questions.

That certainly is a lot of code, and while you could post it all (I've posted a huge question or two myself), you're likely to get better reviews if you post only the code that you think could be better.

Of course, you could take the size of your base class as a self-critique. A single class that's 670 lines is likely doing too many things. Maybe you could give it another go at refactoring prior to posting your question.

  • Good answer. Regarding appropriate lines of code for a class though if you look at some of the base classes in the .net framework (asp.net specifically) such as DatabaoundControl which is 450+ lines, ListControl which is 700+lines, or BaseValidator which is 1300+ lines, 670 lines is pretty normal, especially considering ASP.Net controls typically have to accommodate a wide set of use cases. And it's hard to code review parts of it without the context of the entire control, I think. – Jeremy Jun 3 '15 at 17:42
  • 1
    Just because Microsoft write it doesn't make it good code. =;)- – RubberDuck Jun 3 '15 at 21:06
  • That's true, but it doesn't make it bad either. 1300+ lines of code could be entirely appropriate – Jeremy Jun 3 '15 at 22:03
  • True. Very true, but it should definitely be a red flag to take a closer look. If you really feel the size of your code can't be reduced and smaller chunks of it would hinder a review, you are absolutely encouraged to post it. I just wouldn't expect an insanely thorough review of 670 LoC. Maybe someone could see a way to reduce its size though. – RubberDuck Jun 3 '15 at 22:59

Not the answer you're looking for? Browse other questions tagged .