Aspect (computer programming)


An aspect of a program is a feature linked to many other parts of the program, but which is not related to the program's primary function. An aspect crosscuts the program's core concerns, therefore violating its separation of concerns that tries to encapsulate unrelated functions. For example, logging code can crosscut many modules, yet the aspect of logging should be separate from the functional concerns of the module it cross-cuts. Isolating such aspects as logging and persistence from business logic is the aim of aspect-oriented software development, of which the aspect-oriented programming paradigm is the most widely employed.
Aspect-orientation is not limited to programming since it is useful to identify, analyse, trace and modularise concerns through requirements elicitation, specification and design. Aspects can be multi-dimensional by allowing both functional and non-functional behaviour to crosscut any other concerns, instead of just mapping non-functional concerns to functional requirements.
One view of aspect-oriented software development is that every major feature of the program, core concern, or cross-cutting concern, is an aspect, and by weaving them together, one finally produces a whole out of the separate aspects. This approach is known as pure aspect programming, but hybrid approaches are more commonly used, perhaps since there is less of a paradigm shift between object- and aspect-oriented programming. There is a similar situation with early aspect software development, with traditional methods being enhanced for aspect-orientation and new models proposed. Non-functional concerns can crosscut functional concerns. It is possible for functional concerns to crosscut non-functional or functional concerns. A uniform approach to representation and composition, similar to the pure approach in AOP, is termed multidimensional representation.
The prism analogy describes aspects with terms from the domain of light. Like splitting light into its many aspects with a prism, one splits a problem into its separate aspects. With another prism you can put the different colours back into a white ray of light, and by the process of weaving aspects one can put the solutions for the different aspects of a problem back into a solution for the whole problem.