In
aspect-oriented software development, cross-cutting concerns are
aspects of a
program that affect several
modules, without the possibility of being
encapsulated in any of them.
These
concerns often cannot be cleanly
decomposed from the rest of the system in both the design and implementation, and can result in either ''scattering'' (
code duplication), ''tangling'' (significant dependencies between systems), or both.
For instance, if writing an
application
Application may refer to:
Mathematics and computing
* Application software, computer software designed to help the user to perform specific tasks
** Application layer, an abstraction layer that specifies protocols and interface methods used in a c ...
for handling
medical records, the indexing of such records is a
core concern, while
logging
Logging is the process of cutting, processing, and moving trees to a location for transport. It may include skidding, on-site processing, and loading of trees or logs onto trucks or skeleton cars.
Logging is the beginning of a supply chain ...
a history of changes to the record database or user database, or an authentication system, would be cross-cutting concerns since they interact with more parts of the program.
Background
Cross-cutting concerns are parts of a program that rely on or must affect many other parts of the system. They form the basis for the development of
aspects.
Such cross-cutting concerns do not fit cleanly into
object-oriented programming or
procedural programming.
Cross-cutting concerns can be directly responsible for ''tangling'', or system inter-dependencies, within a
program. Because procedural and
functional language constructs consist entirely of procedure calling, there is no semantic through which two goals (the capability to be implemented and the related cross-cutting concern) can be addressed simultaneously.
As a result, the code addressing the cross-cutting concern must be ''scattered'', or duplicated, across the various related locations, resulting in a loss of
modularity
Broadly speaking, modularity is the degree to which a system's components may be separated and recombined, often with the benefit of flexibility and variety in use. The concept of modularity is used primarily to reduce complexity by breaking a sy ...
.
Aspect-oriented programming aims to
encapsulate cross-cutting concerns into
aspects to retain modularity. This allows for the clean isolation and reuse of code addressing the cross-cutting concern.
By basing designs on cross-cutting concerns,
software engineering benefits can include modularity and simplified maintenance.
Examples
Examples of concerns that tend to be cross-cutting include:
*
Business rules
*
Caching
In computing, a cache ( ) is a hardware or software component that stores data so that future requests for that data can be served faster; the data stored in a cache might be the result of an earlier computation or a copy of data stored elsewher ...
*
Code mobility
*
Data validation
* Domain-specific
optimizations
*
Environment variables and other global configuration settings
*
Error detection and correction
In information theory and coding theory with applications in computer science and telecommunication, error detection and correction (EDAC) or error control are techniques that enable reliable delivery of digital data over unreliable communi ...
*
Internationalization and localization which includes
Language localisation
*
Information security
*
Logging
Logging is the process of cutting, processing, and moving trees to a location for transport. It may include skidding, on-site processing, and loading of trees or logs onto trucks or skeleton cars.
Logging is the beginning of a supply chain ...
*
Memory management
*
Monitoring
*
Persistence
*
Product features
*
Real-time constraints
*
Synchronization
Synchronization is the coordination of events to operate a system in unison. For example, the conductor of an orchestra keeps the orchestra synchronized or ''in time''. Systems that operate with all parts in synchrony are said to be synchronou ...
*
Transaction processing
*
Context-sensitive help
*
Privacy
Privacy (, ) is the ability of an individual or group to seclude themselves or information about themselves, and thereby express themselves selectively.
The domain of privacy partially overlaps with security, which can include the concepts of a ...
*
Computer security
See also
*
Separation of concerns
*
Aspect-oriented programming
*
Code refactoring (restructuring software)
*
Database normalization (minimize needlessly replicated data)
*
Multiple inheritance
*
Microservices
*
Orthogonalization (mathematical normalization)
References
Bibliography
*
*
*
*
*
Further reading
*Laddad, R. (2003): AspectJ in Action, Practical Aspect-Oriented Programming, Manning Publications Co.
External links
AOSD.net'sglossary of
aspect oriented terms (vi
Internet Archive Wayback Machine AOSD.net has becom
Modularity.
*
AspectJbr>
an Aspect-Oriented extension to the
Java (programming language), Java programming language
*Bergmans, L., M. Aksit (2001): Composing Multiple Concerns Using Composition Filters, https://web.archive.org/web/20170909131212/http://trese.cs.utwente.nl/ (24 July 2004)
*Berg, K. van den, Conejero, J. and Chitchyan, R. (2005). AOSD Ontology 1.0 ‐ Public Ontology of Aspect‐Orientation. AOSD Europe Network of Excellence, http://eprints.eemcs.utwente.nl/10220/01/BergConChi2005.pdf
*Here is an example of handling a cross-cutting concern: https://web.archive.org/web/20161220151503/https://www.captechconsulting.com/blogs/a-persistence-pattern-using-threadlocal-and-ejb-interceptors
{{aosd
Aspect-oriented software development
Aspect-oriented programming