Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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
2  
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
1  
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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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.