In the realm of software engineering, we often discuss concepts like determinism, preconditions, postconditions, and class invariants. While these are important, itâs time we challenge some fundamental assumptions about software development and testing. This post explores these concepts and then proposes a radical shift in our approach.
Traditional Concepts: A Brief Overview
- Determinism: In a deterministic system, the same input consistently produces the same output.
- Preconditions: Conditions that must be true before a method is executed.
- Postconditions: Conditions that must be true after a method has executed.
- Class invariants: Conditions that must hold true for every instance of a class at all times (except during method execution).
These concepts intersect to form a framework for designing, implementing, and reasoning about software systems and their quality. They promote predictable behaviour, enhance reliability, and facilitate verification and assurance of software correctness.
Challenging the Status Quo
However, itâs time we question some deeply ingrained beliefs in our industry:
Testing Does Not Ensure Quality
Contrary to popular belief, testing does not ensure quality. It merely identifies the presence of defects, not their absence. Quality must be built into the product from the start, not tested in afterwards.
Testing is Waste
All testing is, in fact, waste (âmudaâ in lean manufacturing terms). It doesnât directly add value to the end product from the customerâs perspective. In an ideal development process, testing would be unnecessary.
Defects are Not Inevitable
Weâve long operated under the assumption that defects are an inevitable part of software development. This belief has led us to accept testing as a necessary evil. But what if we challenged this assumption?
A New Paradigm: Zero Defects through Progressive Refinement
As Phil Crosby Crosby advocates, we can eliminate the need for testing through a progressive refinement of our approach to development. Hereâs how:
- Perfect Requirements: Start with a flawless understanding and documentation of requirements. This eliminates misunderstandings that lead to defects.
- Rigorous Design:Develop: comprehensive design specifications that leave no room for ambiguity or misinterpretation.
- Correct-by-Construction: Employ programming languages and techniques that make it impossible to introduce certain classes of bugs (a.k.a. Poka yoke).
- Pair or Ensemble Programming and Code Reviews: Use these practices not to find defects, but to ensure that every line of code written is correct from the start.
- Continuous Verification: Instead of testing after the fact, continuously verify that the software meets its specifications throughout the development process.
- Cultural Shift: Foster a culture where the expectation is appropriate, not some vague âgood enoughâ. Every team can choose to believe that defects are preventable and unacceptable.
The Role of Determinism in Zero-Defect Software
In this new paradigm, concepts like determinism, preconditions, postconditions, and class invariants take on a new role. Rather than being tools for testing, they become part of the specification and verification process:
- Determinism ensures predictable behaviour, making verification easier.
Preconditions and Postconditions become part of the formal specification, used to prove correctness rather than guide testing.
Class Invariants help ensure that objects maintain consistent states throughout their lifecycle.
Conclusion: Towards a Testing-Free Future
By adopting this mindset and progressively refining our development practices, we can move towards a future where testing is unnecessary because defects simply donât occur. This isnât just an idealistic vision â itâs a necessary evolution of our field.
Remember, every test we write is an admission that we expect our software to fail. By aiming for zero defects and eliminating the need for testing, weâre not just reducing waste â weâre fundamentally changing what it means to develop software.
The path to this future wonât be easy, but as Phil Crosby reminds us, itâs a journey worth undertaking (Cf. âQuality is Freeâ. After all, in a world of zero-defect software, the intersection of determinism, preconditions, postconditions, and class invariants isnât about testing â itâs about guaranteed correctness.
In this new world, we donât test quality in; we build it in from the start. We donât hunt for bugs; we prevent them from ever existing. This is the future of software development â a future without tests, because tests have become obsolete in the face of our ability to create quality, defect free software.
Original article: https://flowchainsensei.wordpress.com/2024/07/02/rethinking-determinism-and-testing-in-software-development-a-path-to-zero-defects/