The ALARA principle originates in radiation protection and means “As Low As Reasonably Achievable”. It means that you have to weigh the purpose of an action dealing with radiation against its disadvantages, like radiation damage or long-term risks. The word “reasonably” means that while some disadvantages are not avoidable, a practicable amount of protection should be in place to lower them. The principle calls for a balancing act: Not without safety measures, but don’t overextend your means by trying to achieve a safety level that isn’t helpful anymore.
To put the ALARA principle in practice with an example: You shouldn’t need a X-ray every time you go to the dentist, but given enough time since the last one and reasonable doubt about a tooth, the X-ray examination will benefit your dental (and overall) health more than if you deny it. It isn’t healthy by itself, but the information gained by it will be used to improve your health.
I learnt about the ALARA principle when my father (a nuclear physicist by heart) explained it to me in context of the current corona pandemic: Use protection like face masks and distance, but don’t stress yourself too much over that one time when you grabbed a pen in the postal office. While preparation and watchfulness is helpful, fear is detrimental to your mental health. And even the most resilient mind has bounded resources that can better be spent on constructive things instead of fear.
A fun fact from radiation protection is that at least three of the four main rules of protection can be applied to corona, too:
- Distance yourself from the radiation source
- Use appropriate protection gear
- Avoid incorporation (keep the thing outside your body)
- Limit your exposure time (this doesn’t fit as nicely, because the virus is probably not cumulative)
But how can we apply the ALARA principle to software engineering? I was instantly reminded about the “Thorough” rule of unit testing. In the book “Pragmatic Unit Testing” by Andy Hunt and Dave Thomas, the two original Pragmatic Programmers, good unit tests have to follow the ATRIP-rules. The T stands for “Thorough” which is often misinterpreted as “test everything at least twice”. In reality, the rule states that:
- all mission critical functionality needs to be tested
- for every occuring bug, there needs to be an additional test that ensures that the bug cannot happen again
The first thing that meets the eye is that the rule doesn’t define a bug as a failure of your testing effort. It takes a bug that probably happened in production and caused some damage as a motivation to strengthen your test coverage in that particular area. The second part of the rule calls for directed, well-aimed testing effort. It is easy to follow because it has a clear trigger: A bug happened, now you have to write a test.
The first part of the rule is more complicated: What is mission critical functionality? And what means “is tested thoroughly” in this context? And here, the ALARA principle can help us. The bug rate in the important parts of your code should be as low as reasonably achievable. “Reasonably achievable” is defined by the resources at your disposal (like time to market), your expertise in testing and the potential damage that could happen if something in your code goes wrong.
If the potential damage is high or even life-threatening, your reasonable effort should be much higher than if the most critical thing that happens is a 15 minute downtime while you restart the server. There are use cases where even 15 minutes mean subsequent damage, but most software is written for a more relaxed context.
I’ve always found the “Thorough” rule of good unit tests pleasant and comforting: If you made reasonable effort to test your most important code and write a test for every bug you or your users encounter, you can say that your bug rate is ALARA – “As Low As Reasonably Achievable”. And that is good enough for most cases.
What was your first thought when you heard about the ALARA principle? Tell us in the comment section!
One thought on “The ALARA principle in software engineering”
> What was your first thought when you heard about the ALARA principle?
As I read the very first sentence, this german phrase came to my mind directly “so kurz wie möglich, so knapp wie nötig”.
Then I thought of RBAC (Role Based Access Control) and the so-called Principle of Least Privilege (sorry the following is german only):
Gleichzeitig werden durch die Rollendefinition nach dem Principle of Least Privilege (PoLP) Audit- und Compliance-Anforderungen einfacher eingehalten und Überberechtigungen vermieden, die z.B. durch die gängige Praxis der Copy User schnell entstehen.
Thanks for the nice reading!