Notes on the book Clean Architectures in Python

Notes on the book Clean Architectures in Python


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.

TDD

  1. Test first, code later.
  2. Add reasonably minimum amount of code to pass tests.
  3. Shouldn't have >1 test failing at a time.
  4. Write code that passes the test, then refactor it.
  5. A new test must fail first. If it doesn't, ask why add it then?
  6. 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
  • Layers:
    • Entities
    • 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.