Code Organization

A simple code project is typically organized with two sub-projects: one for code, and another for unit testing.

  • Solution 'Library'
    • Library Project
    • Unit Testing Project

When we add Traceability to the project, we place the original code in the Functional Layer, and then mirror it to create the Traceable Layer. We also follow this pattern for the unit tests.

  • Solution 'Library'
    • Functional Layer
      • Library Project
    • Traceable Layer
      • Trace Library Project
    • Unit Testing
      • Functional Layer Unit Tests
      • Traceable Layer Unit Tests

It is important to make sure that compilation generates two sets of code: one that is purely Functional Code, and the other containing the Traceable Code. This way, we can deploy the Functional Code into production systems with no worry that we are accidentally deploying the Traceable Code as well.

Multitier Code Organization

If the software is designed around Multitier Architecture then it may be laid out such that each tier has its own section, with multiple projects inside of each tier. The unit tests section will then have a similar pattern of tiers so that there is a clear mapping between the code and the corresponding unit tests:

  • Solution 'Service'
    • Presentation Tier
    • Logic Tier
    • Data Access Tier
    • Unit Tests
      • Presentation Tier Unit Tests
      • Logic Tier Unit Tests
      • Data Access Tier Unit Tests

Once again, the Traceable Layer mirrors the Functional Layer:

  • Solution 'Service'
    • Functional Layer
      • Presentation Tier
      • Logic Tier
      • Data Access Tier
    • Traceable Layer
      • Trace Presentation Tier
      • Trace Logic Tier
      • Trace Data Access Tier
    • Unit Tests
      • Functional Layer Unit Tests
        • Presentation Tier Unit Tests
        • Logic Tier Unit Tests
        • Data Access Tier Unit Tests
      • Traceable Layer Unit Tests
        • Trace Presentation Tier Unit Tests
        • Trace Logic Tier Unit Tests
        • Trace Data Access Tier Unit Tests

In the event we are creating a solution that contains both a Logging Layer and a Traceable Layer, we simply extend the mirroring pattern again:

  • Solution 'Service'
    • Functional Layer
      • Presentation Tier
      • Logic Tier
      • Data Access Tier
    • Logging Layer
      • Logged Presentation Tier
      • Logged Logic Tier
      • Logged Data Access Tier
    • Traceable Layer
      • Trace Presentation Tier
      • Trace Logic Tier
      • Trace Data Access Tier
    • Unit Tests
      • Functional Layer Unit Tests
        • Presentation Tier Unit Tests
        • Logic Tier Unit Tests
        • Data Access Tier Unit Tests
      • Logging Layer Unit Tests
        • Logged Presentation Tier Unit Tests
        • Logged Logic Tier Unit Tests
        • Logged Data Access Tier Unit Tests
      • Traceable Layer Unit Tests
        • Trace Presentation Tier Unit Tests
        • Trace Logic Tier Unit Tests
        • Trace Data Access Tier Unit Tests

By requiring that each layer generate its own code files, we are able to easily map where each layer resides in the production and development systems. This concept will be explored more in the next section.

Next: System Organization

Copyright © 2017-2018 Adin H. Baber, all rights reserved.