Tracking up to the code: Is that possible?

To answer the question in the title straight away: Traceability from requirement to code is of course possible. But the effort involved is considerable. When this makes sense and how it can be implemented is the subject of this article.
Why?
Tracing from requirements to code is almost always driven by functional safety regulations. Even if Traceability Although the implementation of a new system has many advantages, the more we get closer to implementation, the greater the effort and the lower the added value.
Almost all safety regulations expect three aspects here:
- Traceability between code and requirement. This ensures that every requirement is implemented.
- Traceability between software test and requirement. The software test has an implicit traceability to the code, for example via Code Coverage can be made explicit. In particular, tests derived from code should be treated with caution and do not necessarily fulfill the compliance requirements. This includes unit tests that are written by the developer during development. In addition to these, there must be software tests derived from the requirements.
- Traceability between change and code. There will be changes both during and after development. These must also be tracked, right through to the code.
Tool limits
In order to be able to trace from the requirements to the code, tool boundaries almost always have to be overcome, i.e. from the storage of the requirements to the source code repository. When it comes to projects that require compliance, we can assume cleanly managed requirements with unique IDs. An easy way to achieve traceability is to simply embed the IDs in the source code, for example in comments. As programmers like to automate and source code is easy to parse, this approach actually works surprisingly well in practice. The granularity of traceability can also be controlled well here. Those responsible can decide whether to link at file (or class) level or at the level of individual functions/methods.
Instead of automating this yourself, you can also fall back on commercial solutions such as LDRA.
When dealing with changes, we can familiarize ourselves with how Repositories for versioning such as git or Subversion. There, it is possible to manage changes from different source code files as commits. Traceability to commits is therefore a good idea here, rather than to files or functions.
Integration makes life easier
Automation makes life a lot easier here. This is why there are many solutions that take work off the team's hands. The integration between Application Lifecycle Management (ALM) and source code is well developed. ALM tools such as Jira now have very good integration via extensions both with repositories such as git and with development environments such as IntelliJ. There are also infrastructure solutions that go beyond pairwise integration, such as Tasktop. This can be used, for example, to create an integration between Jama (requirements), Jira (ALM) and git (code), as can be seen in the following video.
Platforms such as gitHub or gitLab have also established themselves in this area, providing a functioning, integrated ecosystem. However, these platforms only go as far as the ALM level. Requirements are missing, and they are also only of limited use for systems engineering (in contrast to software engineering, where they work excellently).
Everything in one environment
Many teams want to do everything in one working environment. This is promised by MBSE platforms. Even if code is not actually in scope, code generation could be used, which is also practiced in aviation and train technology in particular. When working with a certified tool chain, many verification activities at code level are eliminated.
But the road to a single working environment is a rocky one. Code generation requires a rethink and a certain investment that only pays off in the long term. A working environment is also problematic "upwards". The handling of requirements in most modeling tools is poor in terms of usability compared to modern requirements management tools. And poor usability leads to poor collaboration with stakeholders.
Conclusion
Yes, traceability from requirements to code is possible and also important: tragic events such as the one caused by the Therac-25 The fatalities caused by the coronavirus have led to today's regulations.
But code traceability is complex and must not be an end in itself. The three use cases listed above are a good guide to help you not lose sight of the purpose of code traceability.
For those who want to delve deeper, I recommend the article Software Standards Compliance 101: Tracing code to requirements
Photo by israel palacio on Unsplash






