Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
2.40/5 (3 votes)
See more:
In a class, how many methods can be written??? is there a limit..
Posted

As a rule of thumb, once your list of methods no longer fits on the screen, it's too much! The whole concepts of OO, code reusability and separation of concerns break down if you can no longer easily memorize the functionality of a class. Or to put it differently: if your class has that many methods, it's design is probably bad, and it should be refactored.
 
Share this answer
 
Though there might be no technical limit, there is some kind of limit set by Good Coding/Design Practises (but no exact number can be given).
What is a class about? Hint: E.g. "Separation of concerns".
When a class has many methods, it cares for too many different things. And thus it is wrongly designed.
 
Share this answer
 
Comments
Legor 21-May-14 3:25am    
Good advice. Classes with lots of method usually hint at a design flaw.
Bangi Blore 21-May-14 6:27am    
:) thanks . here i came to know
No there Is no limit,
You can write n numbers of methods
 
Share this answer
 
A class can contain n no. of methods . There is no limit for defining methods inside a class . And its the rule of Encapsulation and data abstraction .
 
Share this answer
 
Comments
Bangi Blore 21-May-14 6:39am    
thank you sir
1.As I know there is no limit.

2.Even is supposing there is a limit to Max Int32 ==> a huge number of methods.
 
Share this answer
 
Comments
Avenger1 21-May-14 1:34am    
Hithere is no limit
for example for artificial intelligence with C# they write more than 100 class
With Respect "Spaceman"
Legor 21-May-14 3:24am    
"More than 100" isnt really a big number and cannot prove that there is "no limit".
Bangi Blore 22-May-14 12:29pm    
thanks spaceman
Avenger1 22-May-14 16:39pm    
your welcome
and "Bangi Blore" i said MORE than 100 class not just 100
;)
With Respect "Spaceman"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900