3 ms·
The following is a public API for a Car: - Steering wheel - Transmission - Brakes and Gas pedal - Doors and Windows, etc. The following is a private API fo
by swat535 4y ago
The following is a public API for a Car:
- Steering wheel
- Transmission
- Brakes and Gas pedal
- Doors and Windows, etc.
The following is a private API for a Car:
- The inner workings of the engine
- The inner workings of the battery
- Smart break system, internal wiring, etc.
All users of the Car only care about how to drive it with as little knowledge as possible.
Now Mazda can do a full recall and upgrade the smart breaking systems internally but millions of drivers around the world don't have to "learn" anything new, they can happily continue using the public API.
It makes refactoring much easier, reduces dependency and enables duct typing (in supported languages) via message passing for objects with a common public API. You also don't have to perform shotgun surgery[0] when changing classes..
[0] https://refactoring.guru/smells/shotgun-surgery https://refactoring.guru/smells/shotgun-surgery