• Post Reply Bookmark Topic Watch Topic
  • New Topic

Elegant way of handling classes  RSS feed

 
Manoj Pooleery
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is an elegant way of handling big classes? I have a situation where one of the base classes is well over 2000 lines of code. I want to break it into smaller segments. But the only way I could think of is having multiple classes with each one extending the previous one in the hierarchy, which to me, doesn't look to be a good way of doing it. Has anybody come up with any such scenarios earlier or can provide some suggestions?
Thanks
Manoj.
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need one class with 2000 lines of code? What does it do? Why do you think it all needs to be in one class.
--Mark
 
Ashok Mash
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CORBA implementations, especially those classes which is supposed to be database interfaces, with all set, get functions and required SQL generators and transaction management (partial) in it, used to run in to 1000+ lines easily.
 
Manoj Pooleery
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
Basically, this class is being used as the base class of all the view classes(I am following the MVC pattern). It contains the logic used by almost all other view classes. (It is one the most abused classes also). Let's say 80% of it is being used by all of its sub classes and 20% specific to some sub classes. I can take away the 20%, but still the class is, simply huge. I am asking as to ways of splitting up the 80% functionality so that it becomes manageable. I can easily cut it into 4 separate classes -
class1
class2 -> class1
class3 -> class2
class4 -> class3
But I am still not comfortable with this way, because the only thing I am achieving here is maintainability.
As to the question of why all these logic is put in there, well, can you suggest an alternate way of doing it?
Thanks
Manoj.
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a problem for some reason? Breaking the class up will not cause the net memory used to be any lower, and infact will be larger.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!