DEV Community


Discussion on: Hands of the privates

aleksikauppila profile image
Aleksi Kauppila

Maybe the top bun is a missing abstraction that you can test using its public interface.

class TopBun {
   hasSeedsOnTop(): bool;
   flip(): void;

Private interface is a way for you to protect the implementation details from being exposed. When all dependencies to those private methods come from inside the object you'll have the freedom to make changes which don't affect the clients of that object. We want to avoid coupling to small details.