Asking for code review - contract programming

chopchop whateveragain222 at gmail.com
Fri Jan 7 14:03:23 UTC 2022


Hi guys,

I am working on a personal - and FOSS - project, available here:
https://tinyurl.com/kv62kr7t
(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

#step 1
So I found a github project by three Master students dealing with 
the DO-178, because I actually don't know much about this 
guideline :)
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.

#step 2
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 
Linux :)

#step 3
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 
testing.
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 
the nitpick.

#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 
in it."
It will be interesting to see how much code coverage we can reach 
already.

#step 5
If necessary, fix the missing requirements coverage, and note how 
easy / hard it is to do so.

#step 6
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 
contribute.



More information about the Digitalmars-d mailing list