In computer science, cross-cutting concerns are aspects of a program that affect other concerns. 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 for handling medical records, the indexing of such records is a core concern, while logging a history of changes to the record database or user database, or an authentication system, would be cross-cutting concerns since they touch more parts of the program.
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.
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 are effected, including modularity and simplified maintenance.
Examples of concerns that tend to be cross-cutting include:
- Real-time constraints
- Error detection and correction
- Product features
- Memory management
- Data validation
- Transaction processing
- Internationalization and localization which includes Language localisation
- Information security
- Business rules
- Code mobility
- Domain-specific optimizations
- Separation of concerns
- Aspect-oriented programming
- Aspect-oriented software development
- Code refactoring (restructuring software)
- Database normalization (minimize needlessly replicated data)
- Multiple inheritance
- Orthogonalization (mathematical normalization)
- U.S. Patent 6467086, p.4
- Kiczales, p.1
- Kiczales, p.6
- Kiczales, p.2
- Li, p.1
- Kiczales, Gregor; Lamping, John; Mendhekar, Anurag; Maeda (1997). "Aspect-Oriented Programming". Proceedings of the 11th European Conference on Object-Oriented Programming (ECOOP 1997) (Jyväskylä, Finland): 220–242.
- US patent 6467086, Kiczales et. al, "Aspect-oriented programming", issued 2002-10-15
- Li, Harry; Krishnamurthi, Shriram; Fisler, Kathi (2002). "Verifying Cross-Cutting Features as Open Systems". ACM SIGSOFT Software Engineering Notes 27 (6): 89–98. doi:10.1145/605466.605481.
- Parnas, David L. (December 1972). "On the Criteria To Be Used in Decomposing Systems into Modules". Communications of the ACM 15 (12): 1053–1058. doi:10.1145/361598.361623. CiteSeerX: 10.1.1.90.8963.
- Tarr, Peri; Ossher, Harold; Harrison, William; Sutton, Stanley M., Jr. (1999). "N Degrees of Separation: Multi- Dimensional Separation of Concerns". Proceedings of the 21st International Conference on Software Engineering (Los Angeles, California, USA: IEEE Computer Society Press): 107–119. doi:10.1109/ICSE.1999.841000. CiteSeerX: 10.1.1.89.1641.
- Laddad, R. (2003): AspectJ in Action, Practical Aspect-Oriented Programming, Manning Publications Co.
- AOSD.net's glossary of aspect oriented terms.
- AspectJ , an Aspect-Oriented extension to the Java programming language
- Bergmans, L., M. Aksit (2001): Composing Multiple Concerns Using Composition Filters, 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, retrieved May 2005, from http://www.aosd-europe.net/deliverables/d9.pdf
- Here is an example of handling a cross-cutting concern: http://blogs.captechconsulting.com/blog/balaji-muthuvarathan/persistence-pattern-using-threadlocal-and-ejb-interceptors