Code (software) is based on a software design which is based on a set of software requirements. Some measure of assurance is needed to show that the created code fulfills the design upon which it is based without leaving out any design elements or adding any new functionality not present in the design.
Tracing elements of the code such as functions, subsystems, modules, CSCI (Computer Software Configuration Item)s, etc. to design elements helps provide the basis of this assurance.
Traceability matrices help ensure that each design element, typically documented in a Software Design Document (SDD), is implemented in the resulting software, giving a reason for the code implementation through the design back to the software requirements.
Traceability links between individual requirements and other system elements, including, but not limited to, source code, are helpful tools when evaluating the impact of changing or deleting a requirement. When a requirement is changed, traceability can help identify the affected products, including design, documentation, source code, tests, etc. (NASA-GB-8719.13, NASA Software Safety Guidebook).
Tracing source code to design elements also provides the ability to demonstrate traceability of safety-critical software functions and safety-critical software controls to detailed design specifications.
Bidirectional traceability is defined as a traceability chain that can be traced in both the forward and backward directions as illustrated below (Bidirectional Requirements Traceability, Westfall, 2006). It is important because it can point out software design elements that are not fulfilled in the code (i.e., missing or incomplete functionality) as well as source code that does not have a parent design element (i.e., extra functionality). Ideally, the trace does not identify any source code elements that have no source design element, but if such "orphan" source code elements are discovered in the trace, they need to be discussed by the project team and assurance personnel to determine if the "orphan" elements are necessary. If they are determined to be necessary, any missing design elements and source requirements are added to the project.