Your Cross-Cutting Concerns are Someone Else's Core Domain
Join the DZone community and get the full member experience.Join For Free
consider a domain, for example an online bookshop project that we call buycheapbooks. the ubiquitous language for this domain would talk about book, category, popularity, shoppingcart etc.
from scratch, coding this domain can be quite fast, and we can play with the fully unit-tested domain layer quickly. however if we want to ship, we will have to spend several times more effort because of all the extra cross-cutting concerns we must deal with: persistence, user preferences, transactions, concurrency and logging (see non-functional requirements ). they are not part of the domain, but developers often spend a large amount of their time on them, and by the way, middleware and java ee almost exclusively focus on these concerns through jpa, jta, jmx and many others.
on first approximation, our application is made of a domain and of several cross-cutting concerns. however, when it is time to implement the cross-cutting concerns, they each become the core domain -a technical one- of another dedicated project in its own right. these technical projects are managed by someone else, somewhere not in your team, and you would usually use these specific technical projects to address your cross-cutting concerns, rather than doing it yourself from scratch with code.
for example, persistence is precisely the core domain of an orm like hibernate . the ubiquitous language for such project would talk about data mapper , caching, fetching strategy (lazy load etc.), inheritance mapping ( single table inheritance , class table inheritance , concrete table inheritance ) etc. these kinds of projects also deal with their own cross-cutting concerns such as logging and administration, among others.
logging is the core domain of log4j , and it must itself deal with cross-cutting concerns such as configuration.
in this perspective, the cross-cutting concerns of a project are the core domains of other satellite projects, which focus on technical domains.
hence we see that the very idea of core domain vs. cross-cutting concerns is essentially relative to the project considered.
note, for the sake of it, that there may even be cycles between the core domains and the required cross-cutting concerns of several projects. for example there is a cycle between a (hypothetical) project conf4j that focuses on configuration (its core domain) and that requires logging (as a cross-cutting concern), and another project log4j that focuses on logging (its core domain) and that requires configuration (as a cross-cutting concern).
there is no clear and definite answer as to whether a concept is part of the domain or whether it is just a cross-cutting concern: it depends on the purpose of the project. there is almost always a project which domain addresses the cross-cutting concern of another.
for projects that target end-users, we usually tend to reuse the code that deals with cross-cutting concerns through middleware and apis, in order to focus on the usually business-oriented domain, the one that our users care about. but when our end-users are developers, the domain may well be technical.
Opinions expressed by DZone contributors are their own.