O'Reilly logo

JavaScript: Functional Programming for JavaScript Developers by Dan Mantyla, Simon Timms, Ved Antani

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required