Oriel — AI & technology worth noticing, every day.

Avoid Public Functions Calling Other Public Functions

Web page · https://matklad.github.io/2026/10/29/pub-calls-pub.html

First seen by Oriel on .

AI summary

This article recommends implementing public functions through private shared helpers, preserving call-site-friendly APIs while allowing internal implementations to evolve independently.

  • Calling one public function from another can cause optional parameters intended for internal reuse to accumulate and degrade the external interface.
  • The proposed pattern refactors both public functions to call a private helper whose signature can change locally as implementation needs evolve.
  • Shortcut APIs are an exception: they should deliberately chain public functions so they remain genuine, commonly used sequences rather than midlayer abstractions.
  • The article rejects mocking methods as the main rationale, recommending mocking IO and testing software functionality instead, except for stable public libraries.
  • The broader advice is to follow design rules because of their underlying reasons, not merely because an industry or organization has standardized them.

#software design #public apis #testing

Generated by gpt-5.6-sol. Check the original for details.

Metric trends

Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained

Points

Score reported by the source.

  • Hacker News: 3, latest observation ; 0 over observed period since
  • Lobsters: 107, latest observation ; +105 over observed period since

Comments

Comment count reported by the source.

  • Hacker News: 0, latest observation ; 0 over observed period since
  • Lobsters: 22, latest observation ; +22 over observed period since

Aliases

SourceExternal IDURL
Hacker News50294161https://matklad.github.io/2026/10/29/pub-calls-pub.html Read discussion
Lobstersk508wehttps://matklad.github.io/2026/10/29/pub-calls-pub.html Read discussion