In case you apply the modularization constructs of your programming language when designing or specifying architecture building blocks, you’ll get the optimal mapping of source code to the architecture.
For development of Java systems, for example, architecture building blocks (i.e. level-1 blackboxes) shall correspond to Java packages.
When to deviate from this rule
- In historically grown systems it might be useful to deviate from this rule if the code is (seemingly) disorganized…
- If you use various programming languages for implementing otherwise cohesive building blocks (i.e. you implement parts of the building block in Java, other parts in JavaScript, even other parts in Python)
- If some of your frameworks/libraries or even used-products enforce other structuring of code… then you should comply to the suggestions of your tools (“don’t fight the platform”), but nevertheless create meaningful architectural building blocks.
- If the stuff located in the package/namespace/module is not cohesive (see tip 5-17 (cohesion is king))