I am in the beginning of my career (3 years in, Mid Backend Engineer).
I just inherited a large project (52297 lines of python code) that was built by a few developers who just left the company. I'm in the process of fixing bugs (and learning about the code altogether).
Every time I'm working on a bug, I just want to re-write the whole thing since the approach prev. devs took feels so bad. Obviously I can't do that, so I end up duct taping the existing thing. This is killing me.
So, here is the question: 1. In your engineering careers how often do you have to deal with shit code other people wrote? 2. If so, how do you deal with it? Psychologically and physically. 3. Are there any resources online that can help me structure my thoughts around this problem.
Thanks a ton in advance.
When working on a new code base of that size, figure out how old it is, and how the requirements changed over time. It might be more likely your don't see the big picture of why things are done and structured the way they are. obviously, it would be great to have someone around to ask why every time your see something that doesn't make sense or seems overly complicated or backwards. You don't have that luxury. But try to get to know the code more.
Sure, you might be right and the code is just complete garbage, but I'm just reminded of how third semester CS students also know everything better as soon as they learn some pattern X and consider it the best and only way to do things. :-)
2. I don't get invested psychologically in code, and certainly not physically. Get some perspective.
3. Martin Fowler's book Refactoring has some good advice and techniques.
The message in this is as true now as it was 23 years ago. Granted, the code in your case might not be the company's flagship product for all I know, and maybe you should start from scratch, but definitely not until you've tried everything else.
You should absolutely not continue doing something that is literally or figuratively killing you.
> If so, how do you deal with it? Psychologically and physically.
Handling shitty code doesn't affect me mentally and honestly I don't see how it could affect anyone physically. It's not like it causes you nausea or stomach pains, is it? However, feeling that my talents are wasted negatively affects my mood. I would not stand "duct taping" someone's trash unless I were given the authority to refactor and fix the underlying problems with it.
Bottom line is that you should leave jobs that make you feel bad.
I will share a contrarian experience I had. I once had to maintain the tcp/ip stack for an esoteric device running Linux. The stack was insanely complicated, with C code calling ksh scripts, etc. I was able the code's authors why it was designed this way: Because Linux doesn't let you assign more than one ip address to an interface. Except it does... The architect didn't want to believe me when I told him that Linux has had this feature for over two decades. Eventually he realized I was right and apologized. So, all code is written the way it is for a reason, but that reason may not be a good reason.
Also, you have 3 years experience, so you probably have very little understanding of what "good" and "bad" actually means, with respect to large software systems. Deadlines exist, priority calls need to be made, things have to be done for the sake of delivery. Not everything can be "good", but lots of "bad" code is actually just fine.
> (and learning about the code altogether)
If you're saying this, stop saying things are bad. You don't know what you don't know.
Read this, internalize it: https://fs.blog/chestertons-fence/ By far the best resource I've ever found about thinking about legacy code.
> 1. In your engineering careers how often do you have to deal with shit code other people wrote
It's all shit, and most of the stuff we all write every day starts or becomes shit
> 2. If so, how do you deal with it? Psychologically and physically.
Escape the trap of binary thinking and accept that code serves a purpose and if that purpose is being met, it's fine.
> 3. Are there any resources online that can help me structure my thoughts around this problem.
Linked above.
Very often, a quick git/blame shows my own name back to me.
Have patience, have mercy.
Almost as often as I have to deal with shit code I wrote :)
> I'm in the process of fixing bugs (and learning about the code altogether).
This is exactly the way to deal with this situation. Until you understand the project's architecture you can't make an objective decision on how to improve things.
As you go along make sure that you're adding in relevant tests so that when you are in a position to make an objective change you can make sure you don't break the actual business logic of the project.
Leave the code as is because if it ain't broken, don't fix it.
However, once you have to go into code and fix it, this is where you can re-write it, leave comments, maybe even put the old code at the bottom in a comment.
It'd be too much time and possible errors to fix everything, but if you can go in there and re-write some, maybe even make it more efficient, than you might be able to do it.