satish
satish

Reputation: 2441

How many lines should a class contain?

I have seen the Ndepend rule of having a method more than 30 lines is bad. Does the same apply to a class?

Upvotes: -1

Views: 618

Answers (3)

Chris
Chris

Reputation: 1207

No more lines than is necessary.

Upvotes: 1

Pepto
Pepto

Reputation: 1444

There isn't a good or bad measure of "lines of code" or "number of members" in a class. Just to better emphasize Jeff's point, good class design should follow a SOLID programming standard instead.

More information on that concept can be found here

http://en.wikipedia.org/wiki/Solid_%28object-oriented_design%29

Methods are asked to be shorter in design due to a sincere likelihood that most lengthy methods can be refactored into smaller ones.

Upvotes: 3

Jeff Yates
Jeff Yates

Reputation: 62387

There is no such reasonable guideline for a class or type. The type will be as long as it needs to be to meet the goals of its responsibilities.

Upvotes: 3

Related Questions