Reducing the cognitive load is exactly the opposite of what the micro-functions pattern achieves.
ActiveRecord is MUCH better at "telling what's going on without telling the how" this than micro-functions.
-
> When you inline those tiny functions, as the author argues for, now the reader has to recognize what each implementation line means.
As a software maintainer, I can understand a simple ActiveRecord query better than find_user_role.
> Of course we might say it's obvious, but it's less consistent and clear than a series of calls to functions which are well-named and take arguments which are well-named.
If the action is obvious, then simply don't turn it into a micro-function. If it's not, then put it into a function of appropriate size.
Consistency is a piss-poor argument for treating everything like a hammer. If you don't start this practice in the first place, you can't even resort to "consistency" to defend it.
-
> And as software engineers of any experience, we know that eventually one of those "simple" actions will become more complex due to some new requirements. Then that one line becomes more lines, and then of course it will end up as its own function. Over time, many of those simple steps will become more complex out of necessity, and eventually we'll end up with all those individual private methods (with bigger bodies).
Nope. That is not true for the general case. In 99% of cases, micro-functions won't get more complicated.
ActiveRecord is MUCH better at "telling what's going on without telling the how" this than micro-functions.
-
> When you inline those tiny functions, as the author argues for, now the reader has to recognize what each implementation line means.
As a software maintainer, I can understand a simple ActiveRecord query better than find_user_role.
> Of course we might say it's obvious, but it's less consistent and clear than a series of calls to functions which are well-named and take arguments which are well-named.
If the action is obvious, then simply don't turn it into a micro-function. If it's not, then put it into a function of appropriate size.
Consistency is a piss-poor argument for treating everything like a hammer. If you don't start this practice in the first place, you can't even resort to "consistency" to defend it.
-
> And as software engineers of any experience, we know that eventually one of those "simple" actions will become more complex due to some new requirements. Then that one line becomes more lines, and then of course it will end up as its own function. Over time, many of those simple steps will become more complex out of necessity, and eventually we'll end up with all those individual private methods (with bigger bodies).
Nope. That is not true for the general case. In 99% of cases, micro-functions won't get more complicated.