Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing a software system (Patient Administration System) and I have noticed it already had 451 lines of code(in one namespace).

Is this bad? Or does the number of lines of code not matter as long as the methods and comments are useful and they doing what they are intended to do?

Or there is a number of lines of code to maintain like a namespace should only have 500 lines of code something like that

share|improve this question
500 lines of code is almost nothing. I'm quite sure there are many types in the System namespace that have more than that. – svick Mar 7 '12 at 9:03
I don't see how lines of code are relevant to a namespace. If we were talking about a method, maybe. But a namespace? Namespaces can contain hundreds or even thousands of classes. – MetalMikester Mar 7 '12 at 12:34
Short answer: no. Do not use lines of code to determine when you should separate code, but do use it as an indicator that you might need to reevaluate your code and make sure your components are separated properly. – Rachel Mar 8 '12 at 19:26

The reason for line-number guidelines is that huge blocks of code is hard to read. This does not apply to namespaces as they themselves do not have any code to be read.

It is not at all uncommon to have thousands if not millions of lines inside a single namespace and so 500 is not at all a problem.

Instead of going by line number, ask yourself, "is this a separate, contained component?" If so, give a namespace.

share|improve this answer

Is there is a number of lines of code to maintain like a namespace should only have 500 lines of code ?

In general, we cannot be particular about the number of lines of code a namespace can hold as it depends on the classes defined in it.

That said, usually a collection of well defined classes are grouped into a particular namespace. So the key here is that one must be wise in defining individual class which are apt for their functional role and not a collection of classes that come under one namespace which form the total lines for a given namespace.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.