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

后端 未结 12 1451
北海茫月
北海茫月 2021-02-04 01:02

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

12条回答
  •  伪装坚强ぢ
    2021-02-04 01:33

    As a young programmer I still remember my teacher telling us to break up big functions and work on a good OO design before writing code.

    So unless there is a REALLY good reason in your design to impose 40k lines (which I strongly doubt) then you already have your answer : your class is too big.

    I will quote my wife (who is chemist and doesn't program) : "40k lines of code, there is something really wrong!"

    I've had friends take up projects in their companies that were really old, tossed from one programmer to the over and what we all agreed on is that a class that size simply means:

    -patch and fix : people had to do minor changes here and there and didn't want to/ didn't have the time to do it corretly.

    at runtime there might not be any problems with that code, everything works, but usually problems occure when you want to do any form of modifications:

    • it takes ages to find anything

    • when there is a bug you can't pin point it easily

    ...

    In conclusion I would sit down rethink the oo design of your project and restructure (at least into 1k ~ 5k lines classes to start with), I know its annoying to do bu usually on the long run its better

提交回复
热议问题