Hacker News new | ask | show | jobs
by SebastianKra 1087 days ago
> A function and API is always an abstraction

To a degree, yes. But they're not always introduced for that reason. There are cases, where the caller is expected to fully understand the implementation of a function, yet it may still provide value, for example, by:

- ...reducing the mental demand for understanding the calling code by making it easier to visually scan.

- ...reducing the mental demand for understanding the called code by narrowing the scope of the logic through parameters / encapsulation / etc...

- ...preventing repetition by being callable from multiple places