r/badcode • • May 12 '23

java Code written by project lead. A comment was added by my team member that the entire method can be replaced with a single line: getErrorsList().contains(message). Project lead responded that we should focus on readability and performance and not on such code review comments.

Post image
796 Upvotes

152 comments sorted by

View all comments

Show parent comment

3

u/Agilitis May 12 '23

No exact origin, but the saying is very common among developers. I think it is pretty straightforward. Code you don't write can't have: bugs, readability issues, bad tests, etc. So yeah I still think it is true.

1

u/Eggimix May 13 '23 edited May 13 '23

literally my job is to find bugs in code I didn't write, idolizing shit other people wrote that you dont understand is weak af edit: its true that code that isn't written cant have bugs, but moving features to code someone else wrote can have exactly the same problems as code you wrote, and since you were talking about things getting broken it's another vector for that too. There's a difference between not writing unnecessary code and using someone elses code.

1

u/Agilitis May 13 '23

I am not sure I understand your reasoning. We are talking about new code someone just wrote. All I’m saying (and basically every developer) is that the absolute 100% bugless code is the code you don’t write, simply beacuse if it does not exist it cannot have bugs. If you can do something simpler or shorter you should. If you can’t than yeah, don’t force shorter code just because it’s shorter.

1

u/Eggimix May 13 '23

The problem with your reasoning is that the logic of the code cant be shorter, the alternative in this thread is just offloading the same behavior to a built-in function. Its totally valid to decide whether or not to implement it yourself. OPs boss is choosing between relying on assumptions or enumerating very simple code.