Re:Simple Ways of Reducing the Cognitive Load in Code
by diggan on Tuesday June 28, 2016 @07:41AM
(#11992880)
A easy way of making code into "paragraphs" with comments is to just move it into a function. So in the end, this large function you're talking about, is just calling the other ones, creating a paragraph while the functions are just "words". Makes it easy to test and no need for comments :)
[ Parent
| on HN ]
Re:Simple Ways of Reducing the Cognitive Load in Code
by rbanffy on Tuesday June 28, 2016 @08:47AM
(#11993297)
This creates the risk of making what you are doing explicit at the cost of obscuring why you are doing something.
I frequently catch tests in code reviews that don't make it clear why something is being tested and what the overall expected result is beyond the effects being tested.
Re:Simple Ways of Reducing the Cognitive Load in Code
by robmcm on Tuesday June 28, 2016 @10:29AM
(#11994045)
If the methods you are creating are private and for the purpose of segmenting a block of code, you really shouldn't be testing it directly, as it almost certainly won't be part of your public API.