2 ms·
I'm also conflicted about this. Did those 4 lines of code correspond to something that was a natural concept in the problem domain? In that case, outlining it m
by atq2119 7y ago
I'm also conflicted about this. Did those 4 lines of code correspond to something that was a natural concept in the problem domain? In that case, outlining it makes sense.
Otherwise, you're probably better served by keeping it where it is and adding an explanatory comment. There are times when code really is inherently complex, and hiding that may do more harm than good by making the code harder to read for everybody who comes later: they'll have to jump back and forth between the main code and the outlined function in order to follow what the code does.
Point is, what you did may have been the right choice in that particular case, but I find that it often isn't.