Asking for code review - contract programming
whateveragain222 at gmail.com
Fri Jan 7 14:03:23 UTC 2022
I am working on a personal - and FOSS - project, available here:
(Tiny url => becoz of results ranking on search engines)
The goal is too see if D contract programming features can help
cover strong design requirements from the aeronautic industry.
Those requirements are generated from the industry standard
guideline called DO-178c
So I found a github project by three Master students dealing with
the DO-178, because I actually don't know much about this
Their project involved to find an idea, write a design document
following the DO guideline, code the idea, and verify through
contracts code that the requirements are met.
Their project is using ADA.
I wrote the same idea (a snake game) in Dlang, using as much
contract techniques as I could think of, as a dlang hobbyist, and
using Adam's lib for terminal. Please not that I did NOT test the
game on Linux. Windows only. But technically it should work on
This post! I am actually asking the community for code review, to
have a look at the code and:
- correct any mistake you could find. Propose PR.
- add contract programming features (in/out/do, invariant,
unittest...) where you think it is necessary. Propose PR.
Important note: I discovered there are 2 levels of contract
1. Checking that the code is sound, like verifying func param, etc
2. Ensuring that the game will work as a standard snake game!
Think win/loose conditions, etc.
I kind of forgot point 2 so far. Feel free to propose PR for
anything you think could be relevant to a snake game, on top of
#step 4 (the interesting part!)
I have already translated the document of the students from
French to English. This step will involve to compare the
requirements they chose in their design with the code coverage of
our reviewed code, which has no external guideline.
Note that I did not check those requirements before starting
coding my own version of the game. I just followed a rough
guideline "let's make a game which works and put some contracts
It will be interesting to see how much code coverage we can reach
If necessary, fix the missing requirements coverage, and note how
easy / hard it is to do so.
Write a post-mortem document to be added to the repo.
Voilà! I am from the aero industry, and I think it is kind of
awkward to have those jobs offers in ADA, because they become a
dead-end for a career.
C/C++ is also used in the industry, but with the same problems
which lead to the creation of Dlang, somehow. Buffer overflow on
board a plane is not sexy!
I had been wondering for a while if D could be a part of the
solution, hence this project. Thanks if you have time to
More information about the Digitalmars-d