Consider the following code that calculates the maximum product of 3 integers possible from a given array (Java used for exposition; could be any language):
The code in the loop could probably be extracted into 2 subroutines but that would involve major interaction between the variables in this one and those subroutines. What if we were able to define the code between the recalc...end recalc comments as a named range that did not introduce a scope? Something like so:
The code in the loop could probably be extracted into 2 subroutines but that would involve major interaction between the variables in this one and those subroutines. What if we were able to define the code between the recalc...end recalc comments as a named range that did not introduce a scope? Something like so:
Finally: Why a language construct and not a comment? Because it explicitly aids comprehsnsion.
1 comment:
Update: I just discovered that C# has had this for ages as Regions
Post a Comment