Working on the auction example application I found that creating an
app for Axon (as with other frameworks too involves creating much
boilerplate code...
Therefore I'm currently thinking about creating a small DSL to
generate some code and speed up development. Here is an example what I
have so far: http://www.fuin.org/files/cqrs-dsl.gif
not a bad idea, last time we did a workshop here at jteam and someone created a sample with scala. Somehow this reminds me of that.
A disadvantage could be that you put everything in one place, labels, errors. Not sure if I really like that. And it seems that your domain âclassesâ can become pretty big this way.
the idea of less and easier-to-read code is always very appealing. Itâs definitely worth-while to explore the possibilities.
A few questions\remarks on your sample dsl-code, though. It seems that you are combining front-end and back-end logic into a single file. Or am I misinterpreting? What is the idea of the messages (UserRegisteredMessage)? Is that the return value of the command handling? Will this DSL allow for a single command to map to multiple events? Where does the validation logic go? is that part of this DSL, or will that need to be developed as âregularâ aggregates?
Itâs not really clear to me which problems youâre trying to address with this DSL. Could you elaborate on that?
If I am not mistaken, this looks like an external DSL. Personally I donât like external DSLs because of the additional complexity in building an application. Internal DSLs do not have this disadvantage. In addition, proper internal DSLs are transparently mixed with regular code.
With Scala one could write an internal DSL. Actually some of the required syntax is already available. For example all events and commands could be written on a single line with case classes. Libraries for validation also exist.
Btw, you can probably use the proposed syntax (with small changes) in a Scala based internal DSL.
A disadvantage could be that you put everything in one place, labels, errors. Not sure if I really like that. And it seems that your domain 'classes' can become pretty big this way.
I think I will use one file per aggregate. This way the file is kept
small and everything is still in place.
Iâm wondering why you switched back from Xtext to XML. Did you encounter any hiccups w.r.t. Xtext? As you know, Xtext has changed quite a lot since '10 so any technical impedance mismatch might have become smaller since then.
Btw: my current interest in resurrecting this thread and potentially an Axon DSL is that Iâm on a project team with Allard
Four years ago I struggled with using Xtext because I faced several little problems.
But actually things improved and Xtext together with Xtend is pretty cool.
There is not much documentation yet, but I already use it in one of my projects. Generation of code is done with my SrcGen4J framework (https://github.com/fuinorg/srcgen4j-core) - It supports different input (like Xtext, EMFText or even XML) and supports also different template languages (like Xtend or Velocity) for generating source code.
At the moment above itâs just DDD - CQRS DSL will follow in a few weeks.
Iâm very busy at the moment, but I think I can assist you in setting the stuff up. Defining the âAddressbook-Sampleâ with the DSL would be a nice example.