DEV Community

Discussion on: Yoda Conditions (From the office)

Collapse
 
tinussmit profile image
Tinus Smit

I actually don't think those are mutually exclusive.

In my opinion...

Readability is about descriptive names (methods, classes, variables etc.), following conventions in naming; anything that helps a human understand the code. Can I hand this to another developer that doesn't have all my context and will they be able to understand the code soon? That's the question readability answers.

Reliability is about stuff like defensive coding, error handling, null checking; stuff that ensures that the code works as intended with the fewest possible crashes. Has the code been tested with a variety of scenarios and are the results what we intended each time / handled if not? That's what reliability answers.

There's room for both to exist at the same time.

You'll notice that I mention testing a lot, and that's a very key part of making sure that code is reliable. Untested code works in theory, but testing measures the reliability 😃