Code Handoff Discrimination
The other day I was working on a feature for a new module. I was working on the frontend and my junior was handling the backend. The feature was quite simple.
Basically there’s a button which a user clicks on to create that new entity. A dialog pops up and user can input in values for the required fields. There’s an optional file upload field where a user can drop in a file. Upon the file being dropped in, an API is called which uploads the document to our S# bucket.
Upon successful attachment, the API returns the file name which the frontend then attaches to the payload it needs to create the entity. The file name is then stored on the newly created entity itself and will then be used to as a key to retrieve the file.
Previously, this feature was implemented on another module an the backend logic was handled by my senior. I readily accepted the logic from the backend since it was from my senior and didn’t really bother examining it. It wa from my senior and I was prett ysure it will be alright.
Fast forward to the same feature being implemented and my junior did the same thing, reusing the previous logic for this new module. However, this time, I began questioning it immediately. I highlighted to my junior immediately that this could be a problem.
Suppose a user clicks the button, fills in the required info and drops the file in and suddenly decides to just close out the dialog. This will be an issue because the file is uploaded to S3 but it will not be associated to any entity because the entity was simply not created. The uploaded file will be orphaned, consuming some space on our S3 bucket. A dozen or so orphaned files will not be an issue but imagine hundreds of orphaned files which take up space and consequently, money.
My junior pointed out that this was the same exact logic that our senior used!
Moral of the story is: even seniors can make mistakes. Don’t just assume that its a senior’s code that it will be alright. Keep an active and inquisitive mind when getting handed down code.