3 ms·
Perhaps a more helpful principle I heard a long time ago was that all methods are either a specific method doing a specific thing (like splitting up a string) o
by lbriner 4y ago
Perhaps a more helpful principle I heard a long time ago was that all methods are either a specific method doing a specific thing (like splitting up a string) or they call a series of methods of the first type. When we mix the two, it becomes harder to reason since type 1 is generally logically complex, so keeping these small makes them testable and readable, and the logic of the high level is more easily encapsulating as a series of DoThis(), DoThat(), ThenDoThat() calls.
If I've only helped one person today, it was worth it ;-)
- layer8 4y agoThere’s a balance to be struck if most of the Do methods need a common and/or interdependent set of parameters. Inlined code can be clearer because you can directly see how/why those parameters are used. You rarely have DoThis(); DoThat(); DoTheOtherThing(); Instead you usually have something like: x = DoThis(a, b, c); y, z = DoThat(c, x, a); w = DoTheOtherThing(a, z, x, y, b); …and on top of that have to add error handling for those calls.