Wutthichai Luemuang | Dreamstime.com

Enforced Coding Using Ada Contracts

May 12, 2021
This multipart article series examines how Ada contracts provide SPARK with the ability to prove software correctness.

This article series is in the Embedded Software topic within our Series Library

This article series is also in the TechXchange: Developing High Quality Software

Safe and secure software requires code to meet specifications. These are often written documents that have to be translated into applications by programmers. Unfortunately, the contract between the specifications and implementation can be tenuous and even ignored, which can lead to problems. It would be great if the specifications could be enforced by the compiler. 

Contracts are a technology added to Ada 2012 and based on SPARK, a provable subset of Ada. A programmer can annotate aspects of the software, such as the pre- and post-conditions. This allows the compiler to prove that the code does what is specified by the developer. This includes code that may call a function, allowing many validity checks to be removed since the compiler makes sure arguments meet the specified requirements. 

These articles provide examples and insights into contract-based programming:

An Intro to Spark is another good resource. It is an interactive website where you can try out contracts. 

Sponsored Recommendations

The Importance of PCB Design in Consumer Products

April 25, 2024
Explore the importance of PCB design and how Fusion 360 can help your team react to evolving consumer demands.

PCB Design Mastery for Assembly & Fabrication

April 25, 2024
This guide explores PCB circuit board design, focusing on both Design For Assembly (DFA) and Design For Fabrication (DFab) perspectives.

What is Design Rule Checking in PCBs?

April 25, 2024
Explore the importance of Design Rule Checking (DRC) in manufacturing and how Autodesk Fusion 360 enhances the process.

Unlocking the Power of IoT Integration for Elevated PCB Designs

April 25, 2024
What does it take to add IoT into your product? What advantages does IoT have in PCB related projects? Read to find answers to your IoT design questions.