David Seddon
david@seddonym.me
Blog: http://seddonym.me
Please note: this talk was given for an
earlier version of Layer Linter.
Check the latest docs before attempting to implement.
layer-linter.readthedocs.io
1. The shape of a code base
2. A tool to stay in shape
a. Less than 10
b. 10s
c. 100s
d. 1,000s +
a. Not at all
b. A little
c. Somewhat
d. A lot
Graph
Directed Graph
# pets/dogs.py
from . import cats
Your modules form a Directed Graph
"The goal of an architect is to minimize the human resources required to build and maintain the required system.
"What is it that saps this kind of
people-power? Coupling."
'Uncle Bob' Martin, Clean Architecture, 2018 (p. 160)
Layers
An ordered
list of Python modules.
No layer import from a layer above it.
Layers between components
Layers within components
Layers between and
within components
layer-lint pets
layers.yml
Contract
Contract
Text
$ layer-lint pets
============
Layer Linter
============
---------
Contracts
---------
Analyzed 23 files, 44 dependencies.
-----------------------------------
My layer contract KEPT
Contracts: 1 kept, 0 broken.
Text
$ layer-lint pets
============
Layer Linter
============
---------
Contracts
---------
Analyzed 23 files, 44 dependencies.
-----------------------------------
My layer contract BROKEN
Contracts: 0 kept, 1 broken.
----------------
Broken contracts
----------------
My layer contract
-----------------
1. pets.cats.fur imports pets.dogs.walkies:
pets.cats.fur <-
pets.utils <-
pets.dogs.walkies
Top level layers:
packages:
- pets
layers:
- dogs
- cats
- rabbits
layers.yml
Layers within components:
packages:
- pets.dogs
- pets.cats
- pets.rabbits
layers:
- personality
- traits
- physical
Layers within components:
packages:
- pets.dogs
- pets.cats
- pets.rabbits
layers:
- personality
- traits
- physical
Top level layers:
packages:
- pets
layers:
- dogs
- cats
- rabbits
Text
Top level layers:
packages:
- pets
layers:
- dogs
- cats
- rabbits
whitelisted_paths:
- pets.cats.whiskers <- pets.utils
Whitelisted paths
Closed layers
Independent layers
Design
Whitelist
Reduce whitelist
Layer Linter
layer-linter.readthedocs.io
This talk's slides:
slides.com/davidseddon/lint-your-architecture
My blog:
seddonym.me
Work at Octopus Energy:
octopus.energy/careers/
David Seddon
david@seddonym.me @seddonym seddonym.me
http://www.grokcode.com/864/snakefooding-python-code-for-complexity-visualization/
Requests
http://www.grokcode.com/864/snakefooding-python-code-for-complexity-visualization/
Flask
http://www.grokcode.com/864/snakefooding-python-code-for-complexity-visualization/
Celery
http://www.grokcode.com/864/snakefooding-python-code-for-complexity-visualization/
Django