Recently I came across a book on clean architecture focusing on Python. I was looking for something like this and got it on Leanpub for free. You can get the book from here. What follows is a bullet point list of notes I made while reading the book.
- Test first, code later.
- Add reasonably minimum amount of code to pass tests.
- Shouldn’t have >1 test failing at a time.
- Write code that passes the test, then refactor it.
- A new test must fail first. If it doesn’t, ask why add it then?
- Never refactor without tests.
How many assertions?
- If the test is a logical AND between condition, use multiple assertions (eg, positive even number) and if it’s a logical OR then write multiple tests.
Testing bugs and feature requests
- Write tests first to reproduce the bug. If there is no failed test there is no bug.
- First make sure the bug is not related to environments. Clean Architecture
- Clean is Layered
- Spherical in shape
- Inner layers are more abstract
- Use Cases
- External Systems
- Interaction between layers:
- Outer -> Inner = Simple Data Structures
- Inner -> Outer = Through Interfaces/APIs
- General workflow to plug the architecture in any external system:
- Initialise the repo.
- Initialise the use case.
- Collect the results.