• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Big Source Code Problems

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are still in development process and the code of one of classes has exceeded more than 110,000 lines. This has implications on debugging in eclipse. Code above 65k lines cannot be accessed in debugger. Also, Eclipse becomes very slow on opening this code.
We don't want to move any methods to a new class, as it will impact the whole application and there will be lots of code changes.
Is there any way to break this BIG code in atleast two three parts ?
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh! What is this class all about? Does that class has only one reason to CHANGE?
 
Shiraz Khan
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I mentioned, moving methods in a new Class will amount to lots of rework, which I want to avoid.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your class is too big, does too many things, probabely violates every known principle of object oriented design and programming and will send you straight to maintenance hell as soon as you need to change anything in it.

Do yourself a favour and refactor it, the sooner the better, because every day passing and every line of code added, will make things worse.

I know this is not the answer you were asking for and not the answer you wanted to hear, but its the only reasonable advice.

Btw, as your are using eclipse, there is quite goode rafctoring support into eclipse and i am sure, your unit tests will reduce the pain during refactoring.

Regards,
Uli
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shiraz Khan wrote:...still in development...code of one of classes has exceeded more than 110,000 lines. ...
We don't want to move any methods to a new class, as it will impact the whole application and there will be lots of code changes.



Eclipse is the least of your problems. Have you considered what a nightmare it is going to be to maintain that code in the future?

I do not mean to offend you, but if our class has these many lines, do yourself a favor, stop coding and return to the drawing board. You need to start with a proper modular design, split into multiple classes, based on logical functionality.
Usually, the rule of the thumb is a class does not ideally exceed ~2000-2500 lines. Of course the actual number can be debatable, but it definitely should not be as high as yours.

Ok. Enough of my cribbing Coming back to your problem.
Easiest and quickest way to fix your problem would be to provide pass through methods in your lumpy class.
Say your lumpy class contains 100 methods with an average of say 20 lines in each method.
Break these 100 methods into multiple classes and transfer the methods in those classes.
In your lumpy class, provide pass through methods which will in turn invoke these distributed methods. That way, the code which invokes the methods in the lumpy class need not be changed. This should ensure minimum code changes.
 
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic