Aspect-oriented programming (AOP) is a programming paradigm that aims to modularize cross-cutting concerns in code. AOP was developed by Gregor Kiczales and colleagues at Xerox PARC. AspectJ is a popular implementation of AOP for Java that uses pointcuts, advice, and inter-type declarations to inject additional behavior into existing code by means of weaving. Pointcuts define where advice should be applied, advice is the additional code to execute, and weaving is the process of applying aspects to code.
12. Aspect-oriented programming is a way of modularizing crosscutting concerns much like object-oriented programming is a way of modularizing common concerns.
13. Motivation void transfer ( Account fromAcc, Account toAcc, int amount, User user, Logger logger ) throws Exception { logger.info ( "transferring money..." ); if (! checkUserPermission ( user )){ logger.info ( "User has no permission." ); throw new UnauthorizedUserException (); } if ( fromAcc.getBalance () < amount ) { logger.info ( "Insufficient Funds, sorry" ); throw new InsufficientFundsException (); } fromAcc.withdraw ( amount ); toAcc.deposit ( amount ); //get database connection //save transactions logger.info ( "Successful transaction." ); }