DEV Community

loading...

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

Collapse
dineshmadanlal profile image
dineshmadanlaljain Author

Agreed! Right to the point Brandin. My point was more to inform all that even the senior dev sometimes do the basic mistake. That's where code review comes handy. Reviews make sure that the quality of code is good.

Coming to isRequired. I always expect high code standards and when it comes to the variable names like isRequired, hasKey, isPresent, etc.. I expect that to be a boolean. It's not good if boolean has non-truthy values which means we don't have the control of the values being stored. As devs, we have to decide which type will be stored in a variable :)

Collapse
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
dineshmadanlaljain 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
AWDNG

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.