Chapter 20. Applying Class and Component Scale Aspects
Introduction
Aspects seem to be easily categorized as system or enterprise-wide concerns because those contexts gain the most visible benefits from aspect-oriented methods. However, any cross-cutting behavior is a good candidate for implementation using AspectJ whether that behavior is across the enterprise, system, or a single class or component.
The next three chapters will look at the different types of aspects that can be applied within these three different software development contexts: enterprise, system, and component. This chapter focuses on micro-scale aspects that are apparent in class or component-wide cross-cutting concerns.
You’d be forgiven for thinking that little could be described as cross-cutting within a single class or component. Take a closer look though and you’ll discover that any behavior that affects the characteristics of a class can be a strong candidate for an aspect, especially if those characteristics are not core to the business logic of the class.
Examples of these micro-scale cross-cutting concerns examined in this chapter range from validating the parameters passed to a method, to controlling the instantiation of a class. These areas benefit from modularization and separation from the core business concerns of a class and show how using AspectJ can improve your design and implementation, even at the class and component level.
20.1. Validating Parameters Passed to a Method
Problem
You want to validate ...
Get AspectJ Cookbook 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.