Ask HN: Codebase at my work is a complete mess, what should I do?
I&#x27;ve struggled with this a lot. If you want to talk over the phone or via discord I would be more than willing to be a sounding board. :)<p>&gt; Recently I joined a relatively small company (50-100 employees) as a medium level software developer. For a while I was very excited about this opportunity.
After few days&#x2F;weeks of getting to know the whole codebase I finally moved to a specific project I was suppose to work on and I found out the code is a complete mess.<p>Yep<p>&gt; Often I find parts of code that unintentionally affects other parts of code. Some parts are just copied and left there doing nothing. Even names of classes&#x2F;variables are sometimes useless and project structure is unintuitive and seemingly without rules. It&#x27;s spaghetti and relatively big spaghetti (tens of thousands of LOC).<p>CACE principal at work.<p>&gt; I started &quot;repairing&quot; the project but there&#x27;re no tests to check whether my adjustments are correct.  <p>Start writing tests, start motivating other contributors to write tests. Focus on the code that matters.<p>&gt; I&#x27;m so frustrated and depressed by it. The job basically turned into something I hate - I&#x27;m just rewriting the code!<p>You&#x27;re going to need to work through this and either change your mindset about this or start looking for a new job. I challenge you to do the former and not the latter. This is how 90% of the projects you&#x27;re going to jump into are going to be. The real test will be whether or not you can thread the needle and make valuable improvements to the code while also delivering business needs.<p>You can&#x27;t let this job get you down. I know... it&#x27;s your vocation, but most of the time people treat their job like a sweet paycheck. Instead you&#x27;re going to need to treat this as a challenge if you want to get through it. You&#x27;ve identified the problems, now you can either continue to be negative and wallow (bitch) or, attempt to offer solutions to fix them.<p>The challenge is not so much technical as it is cultural. You&#x27;ll need to be able to communicate the value of the changes that you want to make. You&#x27;ll need to change the mindset of the stakeholders of the people on the project to let them know why integration tests are not unit tests. Why, separation of concerns is important and how you plan on doing that. Otherwise, you won&#x27;t be able to create change and this is the cultural challenge.<p>The bad news is that this isn&#x27;t necessarily the exact job you signed up for as an engineer. The good news is that you&#x27;ll be able to build new valuable skills that are often highly sought after. If you feel like you&#x27;re a &quot;better engineer&quot; than the current engineer that built it, then you need to help elevate that engineer and the other engineers around them. Otherwise if you become depressive or negative on the job, you&#x27;re going to have a major negative impact on the rest of the team.<p>&gt; The person in charge of this project was working on it alone and from the outside it all looks fine and it&#x27;s working. So this makes the higher people think that it&#x27;s all just fine.<p>Welcome to business life. This is how it&#x27;s going to be a lot. I&#x27;m sorry.<p>&gt; I really don&#x27;t know what to do. Should I just go and basically say that this person did a bad job? I don&#x27;t feel very comfortably doing that because (a) I&#x27;m a relatively new hire, (b) the person in charge is working there for about two years and (c) I&#x27;m much younger than she&#x2F;he is both professionally and biologically.<p>No, don&#x27;t go in and blame the person who wrote it. You always need to &quot;consider the context&quot;. It&#x27;s easy to point at someone&#x27;s code and call it shit, or to say that a project needs to be rewritten. It&#x27;s harder to reverse engineer the &quot;why&quot; of how it got to where it is. If you can identify the &quot;why&quot; then you&#x27;ll have more insight as to how you may be able to fix the problem or address the aspects that may have caused the problem.<p>&gt; I&#x27;ve already made some comments about rewriting it and the response was basically &quot;ok&quot;.<p>&quot;ok&quot; or in other words, &quot;how are you going to deliver business value for our team&quot;. Show them data, show them why having easy to maintain code delivers business value, then people&#x27;s ears will prick up.<p>It&#x27;s your job to manage this problem. If you have the necessary insights, it&#x27;s on you to fix that. Otherwise move on and don&#x27;t let it kill you. I know, my job is very important to me as well, you can&#x27;t make yourself miserable over something like this. It will be far too prevalent in this field.