{"push_id":842746985,"size":1,"distinct_size":1,"ref":"refs/heads/Chp_19EnsuringCorrectUseOfMethod-Borrowing","head":"4b168ac150da0cccb9df6b3be23a4be5127e84f3","before":"3539333147dcae8daad2c592a6eb72e6d818381c","commits":[{"sha":"4b168ac150da0cccb9df6b3be23a4be5127e84f3","author":{"email":"688085edcac35a6f5d4cd9ba4db0e893cb0d2736@gmail.com","name":"petrero"},"message":"In our opinion, aspect-oriented programming is useful enough that one’s programming technique should allow for it if at all possible.\n  It is also good technique to avoid what’s called temporal coupling—the requirement to execute things in a certain order, especially if that order will not be obvious. As you saw in Chapter 17 (in the section 'Putting It All Together'), applying all optional aspects in an application-configuration phase has the significant advantage that it’s easy not to apply them. They’re applied in one place, which can be skipped when you want streamlined code for production. The aspects as coded previously are optional but have a temporal coupling with the objects they modify. That prevents them from being part of the general configuration phase.\n  You’ve no doubt heard the aphorism, “Every software-design problem can be solved by adding a level of indirection.” That is nowhere more true than in JavaScript. You can avoid the aspect-sequencing problem by borrowing not the function itself, but a wrapper function that in turn uses apply to execute the real function. This defers the method-binding until the method is actually executed—well after all aspects have been applied.\n  The direct way of borrowing:\n\n  objWithLateAspect.forEach =\n  Conference.polyfills.forEachWithLateAspect;\n  has been replaced with functional indirection and an apply .\n\n  As you read in Chapter 18, the apply will execute Conference.polyfills.forEachWithLateAspect ) but with the this supplied in the first argument, which, in this case, will be objWithLateAspect . The arguments to the function will be those supplied to the outer, anonymous function (the one assigned to objWithLateAspect.forEach .\n  With both borrowings done this way, both tests pass","distinct":true,"url":"https://api.github.com/repos/pyterDiaconescu/ReliableJavascript/commits/4b168ac150da0cccb9df6b3be23a4be5127e84f3"}]}