Simple abstractions we use to follow the CQS Principle in applications.
The CQS Principle states that "every method should either be a command that performs an action, or a query that returns data to the caller, but not both." in order to reduce side-effects.
In our projects we use abstractions like Query & QueryHandler as well as Command & CommandHandler to follow this principle. However, there is a bit of fine print here that makes it worthwhile to reuse this in form of a library:
- a command / a query needs to be valid (as in java.validation valid), otherwise a Command/Query-ValidationExcption will be thrown
- a command / a query needs to be valid (determined by an optional message on the handler), otherwise a Command/Query-ValidationExcption will be thrown
- a command / a query needs to be verified by a mandatory method in the handler the is expected to throw a Command/Query-VerificationException
- when a command / a query is handled, any exception it may throw is to be wrapped in a Command/Query-Handling Exception
TODO
cqs is a parent-only artifact (packaging: pom). For Spring Boot applications, use one of the
starter modules:
<dependency>
<groupId>eu.prismacapacity</groupId>
<artifactId>cqs-spring-boot-starter</artifactId>
<version><!-- put the desired version in here--></version>
</dependency>
or, for the AOP based integration:
<dependency>
<groupId>eu.prismacapacity</groupId>
<artifactId>cqs-aop-spring-boot-starter</artifactId>
<version><!-- put the desired version in here--></version>
</dependency>
For non-Spring usage, use cqs-core as dependency:
<dependency>
<groupId>eu.prismacapacity</groupId>
<artifactId>cqs-core</artifactId>
<version><!-- put the desired version in here--></version>
</dependency>
TODO
TODO
TODO
TODO