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 separate the logging from the rest of the code, we place the logic in the Functional Layer, and the logging into the Logging Layer. We also follow this pattern for the unit tests.
- Solution 'Library'
-
- Functional Layer
- Library Project
- Functional Layer
-
- Logging Layer
- Logged Library Project
- Logging Layer
-
- Unit Testing
- Functional Layer Unit Tests
- Logging Layer Unit Tests
- Unit Testing
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 Logging Layer mirrors the Functional Layer:
- Solution 'Service'
-
- Functional Layer
- Presentation Tier
- Logic Tier
- Data Access Tier
- Functional Layer
-
- Logging Layer
- Logged Presentation Tier
- Logged Logic Tier
- Logged Data Access Tier
- Logging Layer
-
- 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
- Functional Layer Unit Tests
- Unit Tests
Next: Basic Logging