• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Big Source Code Problems

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • 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.
 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic