You've heard of the terms fault, error, and failure.
And as software developers, we use them every day. But what do they mean?
One popular definition is this (see “Fundamental Concepts of Dependability”, Avižienis et al.):
To better understand this definition, let's look at a concrete example.
Imagine a JS function that calls an external API to get search results.
const result = JSON.parse(response.payload)
Let's assume the response object is always present.
But when there is no payload property, a SyntaxError
when running that code:
SyntaxError
, because we try to call JSON.parse(undefined)
This example is a bit trickier than we see at first glance:
try
and catch
and handled appropriatelyNow the big question, where does a bug fit into this?
The bug can be the fault or the failure, depending on context.
if
to handle this case.”So a bug can actually be two things! Who would've thought 🤓