Conclusion: Enforcing Architecture Boundaries

This lesson recaps the importance of enforcing architecture boundaries and how it can help write maintainable software.

How does this help me build maintainable software?

Software architecture is basically all about managing dependencies between architecture elements. If the dependencies become a big ball of mud, the architecture becomes a big ball of mud.

So, to preserve the architecture over time, we need to continually make sure that dependencies point in the right direction.

When producing new code or refactoring existing code, we should keep the package structure in mind and use package-private visibility when possible to avoid dependencies to classes that should not be accessed from outside the package.

If we need to enforce architecture boundaries within a single build module, and the package-private modifier doesn’t work because the package structure won’t allow it, we can make use of post-compile tools like ArchUnit.

And anytime we feel that the architecture is stable enough, we should extract architecture elements into their own build modules because this gives us explicit control over the dependencies.

Get hands-on with 1200+ tech skills courses.