Why non-deterministic code hurts

Siddique Ahmad
Bazaar Engineering
Published in
2 min readNov 2, 2023

--

Non deterministic code

What is Non deterministic code?

Non-deterministic code, in the context of software development, refers to code that can produce different outcomes or behaviors under the same set of inputs or conditions. This unpredictability can lead to various issues and is generally considered bad for long-term software stability and maintainability.

Why it hurts?

It has following challenges attached to it which can hurt us in long term development

  1. Debugging Challenges: Non-deterministic issues are often hard to reproduce and debug. In a long-term software project, this can lead to increased development and maintenance costs as developers spend more time identifying and fixing elusive bugs.
  2. Testing Complexity: Automated testing is crucial for software quality, but non-deterministic code makes testing difficult. Tests may pass in some runs and fail in others, leading to unreliable test results.
  3. Scalability Issues: In larger software projects, non-deterministic code can become a major obstacle to scalability. It can lead to performance bottlenecks and hinder efforts to parallelize or distribute tasks effectively.
  4. Maintenance Nightmare: As software evolves, developers come and go, and libraries and dependencies change, non-deterministic code becomes a maintenance nightmare. What worked before may not work anymore due to external factors that have shifted.
  5. Reproducibility: In a long-term project, it’s essential to be able to reproduce past behavior or issues. Non-deterministic code makes it challenging to recreate specific conditions, which is necessary for auditing, compliance, or understanding historical data.

Conclusion

To mitigate its negative impact, we should strive for code that produces consistent and predictable results under various conditions. Techniques such as proper synchronization, avoiding hidden assumptions, and documenting external dependencies are essential for maintaining software quality and reliability over time.

Disclaimer:

Bazaar Technologies believes in sharing knowledge and freedom of expression, and it encourages it’s colleagues and friends to share knowledge, experiences and opinions in written form on it’s medium publication, in a hope that some people across the globe might find the content helpful. However the content shared in this post and other posts on this medium publication mostly describe and highlight the opinions of the authors, which might or might not be the actual and official perspective of Bazaar Technologies.

--

--

Siddique Ahmad
Bazaar Engineering

Passionate about devops, data analytics, business solutions, #kubernets @debezium flink-statefun, kogito