Related
Quick Links
Computer problems.
We all have them sooner or later.
Learn all about it.
What Is anAssert?
When a developer starts writing code, they will soon introduceifstatements therein.
Anifstatement is used whenever a certain condition needs to be tested.
However, maybe someone has turned the power off to the sensor.
We can keep going like this for a while.
We can cover every possible scenario imaginable and still miss a few.
And what’s more, these sorts ofifconditional tests happen quite regularly in almost all software.
This is precisely the situation that an assert can, to some extent, provide for.
An assert is another condition (Think about it like anotherifstatement.)
For example, let’s say that our little water sensor is mounted in a rain tank.
The water should, therefore, never be boiling.
Let’s add an assert to the pseudo-code that we started above.
The code needs to assert that the water temperature is less than 70 degrees Celsius.
Asserts in actual code are quite similar to the example above.
Often, these assets are logged to the system’s log files or even directly on the screen output.
Assert messages are often bugs, although they might simply be bugs in the developer’s reasoning.
(Let’s hope not, though!)
For example, imagine this assert message being shown for the program above.
Yes, it can get a little confusing.
What Is anError?
Errors in computing happen all the time and for a wide variety of reasons.
They happen both at the developer and the user level and at every step in between.
In short, a computer error can be defined as a problem with computer hardware or software.
There are some examples of an error even in the limited pseudo-code above.
When thesensor_readout == nonsensicalcondition is met, an glitch notice is displayed.
There are certain errors that are more common than others.
For example, using a wrong path or filename is a common error.
Power-related issues (for example, battery low) are also quite common errors.
What Is aCrash?
A computer crash can take many forms.
Most of the time, however, a crash is a software app that ran into an undefined situation.
There are many such undefined scenarios possible.
Next time you run into an assertion message, take a closer look, and enjoy debugging!