clean-code-boundaries

Installation
SKILL.md

Boundaries

There's a natural tension at the edge of any system. Providers of libraries aim for broad applicability, while users want an interface focused on their own needs. Interesting things, including change, happen at boundaries, so they deserve deliberate design.

1. Don't let general-purpose interfaces leak

A broad library type, such as a generic map, a raw HTTP response, an ORM session or a vendor client, offers far more capability than your code needs. That capability includes operations you don't want anyone calling, such as clear() on a shared map. If it's passed around the system, every user becomes coupled to it, and every change to the library ripples everywhere.

Wrap it in a small class or module that exposes only what your application needs, in your domain's terms:

class Sensors:
    def __init__(self):
        self._by_id: dict[str, Sensor] = {}
    def get(self, sensor_id: str) -> Sensor:
        return self._by_id[sensor_id]
Installs
1
First Seen
2 days ago