3 ms·
Then you need to make those functions public, when the goal is to keep them private and unusable outside of the parent function. Sometimes it's easy to write m
by oxidant 2y ago
Then you need to make those functions public, when the goal is to keep them private and unusable outside of the parent function.
Sometimes it's easy to write multiple named functions, but I've found debugging functions can be more difficult when the interactions of the sub functions contribute to a bug.
Why jump back and forth between sections of a module when I could've read the 10 lines in context together?
- Freak_NL 2y ago> Then you need to make those functions public, […] That depends on the language, but often there will be a way to expose them to unit tests while keeping them limited in exposure. Java has package private for this, with Rust the unit test sits in the same file and can access private function just fine. Other languages have comparable idioms.
- oxidant 2y agoJavascript doesn't, AFAIK. I work in Elixir, which doesn't. I'm for it if it's possible but it can still make it harder to follow.