DEV Community


Discussion on: What's the worst code you have seen by a senior dev?

brandinchiu profile image
Brandin Chiu

My comment was more to indicate that the line in question is hard to evaluate as an objective "mistake", and I personally would not evaluate it as such.

As for the variable names, there is often a very wide gap between what we as developers expect a value to be, and what it actually is, especially in a loosely typed language like Javascript.

Thread Thread
dineshmadanlal profile image
dineshmadanlal Author

If we ourselves don't know what's being stored, then it's a matter of concern. If used JS in the right way, it will help to do wonders. Else, get ready to fix bugs mate, lol. I had the same mindset during the early stage of my career. Way to go.

Thread Thread
awdng profile image

I have the same opinion as Brandin as a dev of 15 years. Also your way of communicating is quite patronising. In a language like JS, this kind of conditional makes sense, especially in bigger projects with multiple developers. It adds no weight but is a stricter check that helps to prevent bugs. If this value is changed by someone to a non-truthy value for whatever reason, a code review will most likely not catch it and even your tests might work and you have an extremely hard to track bug. Software projects are never perfect and you should never assume so.
In our company of 150+ devs, the strict checks in loosely typed languages are actually in the coding standards and will get flagged if you don't do them.