Aspected Oriented Programming

Aspect-oriented programming (AOP) is the idea of decoupling and modularizing cross-cutting concerns. Cross-cutting concerns are concerns that span over multiple objects in object oriented programming. Common examples are tracing, logging, and auditing, but there are many different cross-cutting concerns.

Using Aspect-oriented programming is made simple by the libraries that exist. For Java, there is AspectJ. For C#, there is PostSharp.

Java

Aspectj

  1. AOP – Adding Advice before or after main() in Java with AspectJ
  2. AOP – Logging all method calls and executions in Java with AspectJ
  3. AOP – Logging method execution time in Java with AspectJ
  4. AOP – Encrypting with AspectJ
  5. AOP – Encrypting with AspectJ using an Annotation
  6. AOP – Implementing Role Based Security in Java with AspectJ

C#

PostSharp

Note: PostSharp has discount or free license available for educationaly, blogging, open source, or other purposes. See this link: http://www.sharpcrafters.com/purchase/discounts

  1. AOP – Tracing methods in C# with PostSharp
  2. AOP – Logging method execution time in C# with PostSharp
  3. AOP – Implementing try catch in C# with PostSharp
  4. AOP – Implementing a lazy loading property in C# with PostSharp
  5. AOP Contracts with PostSharp
  6. AOP Custom Contract: ListNotEmptyAttribute