• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Elegant way of handling classes

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic