Login
You're viewing the code4lib.social public feed.
  • Nov 3, 2026, 3:40 AM

    @thirstybear @daycoder For *classes* that always made sense to me, but for *methods* I went through a stint of confusion: How are you supposed to test the internals if they’re private?

    Until it clicked that, you don’t. Because the point is you test the *externally visible* behavior.

    The test should tell you the public methods do the right thing when called. The fact that they may *internally* delegate some work to private helper methods may be true, but not part of the external contract.

    💬 1🔄 0⭐ 0

Replies

  • Nov 3, 2026, 3:42 AM

    @thirstybear @daycoder And that, in fact by trying so hard to test these internal helpers, you make a system more brittle.

    Now you can’t refactor the internals of the class without having to make a bunch of bothersome test changes as well, which makes you less likely to do so.

    Whereas that friction, for the *externally called* methods is actually a good sign that you must be careful to change that contract, as it impacts callers.

    💬 0🔄 0⭐ 0