<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde" -->

---
title: Avoid Public Functions Calling Other Public Functions
description: Public functions shouldn't call other public functions within the same module, matklad argues. When one public function reuses another, optional parameters...
canonical: https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Avoid Public Functions Calling Other Public Functions | daily.dev
og:description: Public functions shouldn't call other public functions within the same module, matklad argues. When one public function reuses another, optional parameters...
og:url: https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde
og:image: https://api.daily.dev/og/posts/D5PCdTRde.png
og:image:alt: Avoid Public Functions Calling Other Public Functions
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Avoid Public Functions Calling Other Public Functions

**[matklad](https://daily.dev/sources/matklad)** · 3 min read · 2 upvotes · 1 comments

## Summary

Public functions shouldn't call other public functions within the same module, matklad argues. When one public function reuses another, optional parameters creep in over time to serve internal callers, degrading the external interface. The fix: extract a private helper and have both public functions call it, keeping the shared logic easy to change locally. The one exception is 'shortcut' APIs, where a public function is explicitly defined as a chain of other public calls; there, no private helpers should be used, to keep it a genuine shortcut rather than a hidden midlayer.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://matklad.github.io/2026/10/29/pub-calls-pub.html>

## Questions this post answers

### Should one public function call another public function within the same module?

No, it is better to extract a private helper function and have both public functions call that helper instead. Letting public functions call each other creates tension between making the interface convenient externally and convenient internally, which often causes functions to accumulate optional parameters meant only for internal callers, degrading the public API over time.

_Weigh API design trade-offs like this one by following architecture discussions on daily.dev._

### Is it ever okay for a public function to call another public function directly?

Yes, when the public function is explicitly a 'shortcut' API, meaning it is defined as a commonly used chain of calls to other public functions. In that specific case, the rule reverses: no private helper calls are allowed, so the function stays a genuine shortcut rather than becoming a hidden, undocumented layer of logic.

_Developers refining public API boundaries can follow more API design reasoning on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@ahmetozel** · 0 upvotes

> The private helper example also creates a useful boundary for validation and instrumentation. Public entry points often own input checks, tracing spans, or request metrics; calling bar from foo can accidentally run those twice even before optional parameters start growing.
>
> A shared implementation can accept already validated internal values, while each public function retains its own external contract. The shortcut exception is the important qualification: if the API promises the observable behavior of a sequence of public calls, skipping those checks or hooks through a private helper could...

## Similar posts on daily.dev

- [What to Do When Your Constants Are Someone Else's Law](https://daily.dev/posts/what-to-do-when-your-constants-are-someone-else-s-law-qdd8xtbqx) · freeCodeCamp · 4 upvotes · 2 comments
- [You can refactor everything except your API](https://daily.dev/posts/you-can-refactor-everything-except-your-api-pcwpvakuq) · The Polymathic Engineer · 15 upvotes · 1 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#architecture](https://daily.dev/tags/architecture)

[View this post on daily.dev](https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Avoid Public Functions Calling Other Public Functions","url":"https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde"},"datePublished":"2026-10-29T19:03:39.584Z","dateModified":"2026-10-29T19:04:22.160Z","description":"Public functions shouldn't call other public functions within the same module, matklad argues. When one public function reuses another, optional parameters...","image":"https://media.daily.dev/image/upload/s--foaA6JGU--/f_auto/v1722860399/public/Placeholder%2004","thumbnailUrl":"https://media.daily.dev/image/upload/s--foaA6JGU--/f_auto/v1722860399/public/Placeholder%2004","isAccessibleForFree":true,"articleSection":"matklad","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"matklad","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/c34dbbf360354a179786e8a127718b12","url":"https://daily.dev/sources/matklad"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"testing,architecture","timeRequired":"PT3M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"matklad","item":"https://daily.dev/sources/matklad"},{"@type":"ListItem","position":3,"name":"Avoid Public Functions Calling Other Public Functions"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde","comment":[{"@type":"Comment","text":"The private helper example also creates a useful boundary for validation and instrumentation. Public entry points often own input checks, tracing spans, or request metrics; calling bar from foo can accidentally run those twice even before optional parameters start growing.\nA shared implementation can accept already validated internal values, while each public function retains its own external contract. The shortcut exception is the important qualification: if the API promises the observable behavior of a sequence of public calls, skipping those checks or hooks through a private helper could change that promise.","datePublished":"2026-10-30T05:41:07.707Z","url":"https://daily.dev/posts/D5PCdTRde#c-xcKsbmnAU","author":{"@type":"Person","name":"Ahmet Özel","url":"https://daily.dev/ahmetozel","image":"https://avatars.githubusercontent.com/u/70992231?v=4"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/avoid-public-functions-calling-other-public-functions-d5pcdtrde#faq","mainEntity":[{"@type":"Question","name":"Should one public function call another public function within the same module?","acceptedAnswer":{"@type":"Answer","text":"No, it is better to extract a private helper function and have both public functions call that helper instead. Letting public functions call each other creates tension between making the interface convenient externally and convenient internally, which often causes functions to accumulate optional parameters meant only for internal callers, degrading the public API over time. Weigh API design trade-offs like this one by following architecture discussions on daily.dev."}},{"@type":"Question","name":"Is it ever okay for a public function to call another public function directly?","acceptedAnswer":{"@type":"Answer","text":"Yes, when the public function is explicitly a 'shortcut' API, meaning it is defined as a commonly used chain of calls to other public functions. In that specific case, the rule reverses: no private helper calls are allowed, so the function stays a genuine shortcut rather than becoming a hidden, undocumented layer of logic. Developers refining public API boundaries can follow more API design reasoning on daily.dev."}}]}
```

