javalegacy-code

I'm maintaining a Java class that's 40K lines long.. problem?


This may be a subjective question leading to deletion but I would really like some feedback.

Recently, I moved to another very large enterprise project where I work as a developer. I was aghast to find most classes in the project are anywhere from 8K to 50K lines long with methods that are 1K to 8K lines long. It's mostly business logic dealing with DB tables and data management, full of conditional statements to handle the use cases.

Are classes this large common in large enterprise systems? I realize without looking at the code it's hard to make a determination, but have you ever worked on a system with classes this large?


Solution

  • Here are the ten largest class in the JDK 6 by line count of 7209 .java files. These classes include significant amount of comments which could be longer than the code.

    4495 ./javax/sql/rowset/BaseRowSet.java
    4649 ./java/awt/Container.java
    5025 ./javax/swing/text/JTextComponent.java
    5246 ./java/util/regex/Pattern.java
    5316 ./javax/swing/JTree.java
    5469 ./java/lang/Character.java
    5473 ./javax/swing/JComponent.java
    9063 ./com/sun/corba/se/impl/logging/ORBUtilSystemException.java
    9595 ./javax/swing/JTable.java
    9982 ./java/awt/Component.java
    

    I would agree one printed page is long enough for a method. There really should not be a need for classes over 10K lines long IMHO.