I'm coming across some nightmare quality legacy code right now. Code currently in production and being used by a few million users over the lifetime of the product. This is something you would see from an average to less-than-average Comp Sci student. The most recent example is along the lines of this:
Code:
public class SomeClass {
SomeObj someObj;
---snip---
public SomeObj getObjProfile(SomeObj s) {
this.someObj = someObj;
---snip---
return someObj;
}
}
Now... the method is clearly intended to operate on s. But they never touch s at all. I'm not the best programmer, I can raise my hand and admit that. But the shyt I'm seeing here is something that should have gotten somebody fired and blacklisted.
It looks bad from the outside., but there could be many reasons why that ended up there.
- Maybe the person working on that code at the time was working under pressure, depressed, overworked, and had no one to review and catch that mistake they made.
- Maybe that person people were pre-occupied with other shyt that it slipped into production without being caught.
- Maybe it was intentional, the person was an unhappy employee already one foot out the door and decided to fukk up the code base knowing no one else was competent enough to catch it before they left.
Many reasons could have caused it, I think its important to have a little more empathy looking at old code because you dont have enough context of the time it was written.
Asking them to be fired or blacklisted is a bit too harsh and elitist, in my opinion.
I've seen these silly lines of code made by developers I respected who I knew for sure are smart and capable people. I've learnt not to be too judgemental when looking at legacy code.