-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from Never-Over/update-docs
why modguard
- Loading branch information
Showing
5 changed files
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
# Overview | ||
|
||
## What is modguard? | ||
Modguard enables you to explicitly define the public interface for a given module. Marking a package with a `Boundary` makes all of its internals private by default, exposing only the members marked with the `@public` decorator. | ||
Modguard enables you to explicitly define a public interface for your Python modules. Marking a package with a `Boundary` will make all of its internals private by default, exposing only the members marked with `public`. | ||
|
||
This enforces an architecture of decoupled and well defined modules, and ensures the communication between domains is only done through their expected public interfaces. | ||
|
||
Modguard is incredibly lightweight, and has no impact on the runtime of your code. Instead, its checks are performed through a static analysis CLI tool. | ||
|
||
## Commands | ||
|
||
* [`modguard check [dir-name]`](usage.md#modguard) - Check boundaries are respected throughout a directory. | ||
* [`modguard init [dir-name]`](usage.md#modguard-init) - Initialize package boundaries in a directory. | ||
* [`modguard check [dir-name]`](usage.md#modguard-check) - Check boundaries are respected throughout a directory. | ||
* [`modguard show [dir-name]`](usage.md#modguard-show) - View and optionally generate a YAML representation of the boundaries in a directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,24 @@ | ||
# Why modguard? | ||
|
||
We built `modguard` to solve a recurring problem that we've experienced on software teams - code sprawl. Unintended cross-module imports would tightly couple together what used to be independent domains, and eventually create "balls of mud". This made it harder to test, and harder to make changes. Mis-use of modules which were intended to be private would then degrade performance and even cause security incidents. | ||
|
||
This would happen for a variety of reasons: | ||
- Junior developers had a limited understanding of the existing architecture and/or frameworks being used | ||
- It's significantly easier to add to an existing service than to create a new one | ||
- Python doesn't stop you from importing any code living anywhere | ||
- When changes are in a 'gray area', social desire to not block others would let changes through code review | ||
- External deadlines and management pressure would result in "doing it properly" getting punted and/or never done | ||
|
||
The attempts to fix this problem almost always came up short. Inevitably, standards guides would be written and stricter and stricter attempts would be made to enforce style guides, lead developer education efforts, and restrict code review. However, each of these approaches had their own flaws. | ||
|
||
The solution was to create a set of definitions for each module and it's public interface, and enforce those domain boundaries through CI. This meant that no developer could ever violate these boundaries without explicitly changing the definition of either the interface or the boundary, a significantly smaller and well scoped set of changes that could then be maintained and managed by those who understood the correct semantics for the system. | ||
|
||
With modguard set up, you can collaborate on your codebase with confidence that developers won't violate the intentional design of your modules. | ||
|
||
Modguard is: | ||
|
||
- fully open source | ||
- able to be adopted incrementally | ||
- implemented with no runtime footprint | ||
- a standalone library with no external dependencies | ||
- interoperable with your existing system (cli, generated config) |