2

This question already has an answer here:

I am currently in a continuous software product development project on base of legacy Java code. The source code is very complicated, which is good and bad.

But I am surprised to see that in the core component most of the classes contain thousands of lines, not one thousand of lines but usually over 5000 lines, in only one .java file. As a result, developers, or at least me, often times spend pretty much time on using the debugger with IDE. IMO, such way of coding lost the purpose of object-oriented programming and definitely need refactoring

I don't know the cause of spending much time on debugging is because I am a jerk without enough experience or the thousands of lines of code in one .java file, and I sometimes really got fed up with such kinda code. I once decoupled some parts of code in separate java file but some team members criticized on this with lacking of teamwork spirit as an excuse.

Question:

  • If my goal is to become a very professional top-level programmer, is it worth and valuable to work in such kind of software development project?
  • Is the lack of time an excuse for adding hundreds of methods to one Java class and hundreds of lines to only one method?

I faithfully would like to get comments and opinions on this from some more experienced developers.

marked as duplicate by Greg Burghardt, gnat, Robert Harvey, Doc Brown, amon Nov 22 '18 at 23:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    You spend X amount of time ONCE to clean up the code. Your spend Y amount of time EVERY TIME you have to work with the messy code. So you just have to do the math. After how many times of continuing to work with the bad code, have you actually lost more time than what you would have saved if you had spent the effort to clean it up? – Caleb Nov 22 '18 at 19:28
  • 1
    A class with 5000 lines isn't necessarily bad, what's bad is if the 5000 lines are for a bunch of disparate things. Sometimes splitting things up makes it harder to reason about, nit easier. Are most of your objects 5k lines, or just a few, with many dozens of small ones? – whatsisname Nov 22 '18 at 20:04
  • 1
    What are these classes doing? If the are doing multi threading or make web service calls, or interacting with hardware the error handling can become lengthy and messy. In such code 5k lines would not be unusual. – Greg Burghardt Nov 22 '18 at 20:13
7

If my goal is to become a very professional top-level programmer, is it worth and valuable to work in such kind of software development project?

Certainly. Sites like this often talk about the benefits of refactoring, good design, and all of these guidelines to make software great. And in a vacuum, it’s occasionally unclear why we make suggestions, or why all of these rules are in place.

Working at a place with obviously bad code can help you better understand what bad code looks like; what bad code feels like. You can learn what sort of people problems lead to these technical problems. And ideally, you can get some practice fixing them. You can get a feel for what changes make the most good. Or at the very least, you can truly appreciate a great development environment.

Is the lack of time an excuse for adding hundreds of methods to one Java class and hundreds of lines to only one method?

It is a very common excuse. It’s not a good or viable excuse. As the old adage goes: “If you don’t have time to do it right, when will you ever have time to do it over?”

You’ll find that your company doesn’t. You’ll find that management almost invariably creates a culture where people are rewarded for hitting some deadline or doing things as quickly/cheaply as possible. “We don’t have time” is a choice. All your developers need to do is say no. Management isn’t going to write the code.

  • 1
    All your developers need to do is say no. Management isn’t going to write the code. Or you just can do your best, until you find a better job. Don't underrate the negative impact of saying "no" to some people. I say no quite often and I earned the infamous reputation to be someone hard to work with. Just because I'm not a brainless code-monkey, AS @Telastyn has explained so well, even in the worse of the situations, there's still room for you to learn something useful. – Laiv Nov 23 '18 at 8:32
  • 1
    Oh, yes, you absolutely will be seen as someone hard to work with. But that is far better in my experience for you and the company than being seen as a mindless order taker. – Telastyn Nov 23 '18 at 15:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.