Aspect oriented programming

Modularity of software is a great feature, the majority of this book has been about modularity and its advantages. However, there are some features of software that span the entire system. Security is a great example of this.

We would like to have similar security code in all the modules of the application to check that people are, in fact, authorized to perform some action. So if we have a function of the sort:

var GoldTransfer = (function () { function GoldTransfer() { } GoldTransfer.prototype.SendPaymentOfGold = function (amountOfGold, destination) { var user = Security.GetCurrentUser(); if (Security.IsAuthorized(user, "SendPaymentOfGold")) { //send actual payment } else { return { success: 0, message: "Unauthorized" ...

Get JavaScript: Functional Programming for JavaScript Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.