Mar
04
2010
0

CQRS && Validation && Business Rules

Validation and business rules within a CQRS architecture [1][2] continue to raise issues for those who first hear of it. Three specific questions are often asked: how does the validation of commands work, how can one enforce business rules on large collections (state) and how does the enforcement of business rules on multiple aggregates work? Hopefully I can help some readers with my three replies. First the questions.

  1. If asynchronous commands to be handled, how can I do the validation on the server and notify the user that validation failed?
  2. How do we enforce business rules that depend on state that is very large. Familiar example: a user must have a unique username.
  3. If aggregates are completely separate, how do we enforce business rules over multiple aggregates?

I wanted to share my ideas, because I think that these questions have proper answers. In a (renewed) attempt to write a short post, here are my three answers:

  1. Make declaratively valid commands. Validate on the client. Ignore non-valid commands on the server. See also [3]
  2. Save this state initially in-memory in a part of the aggregate that represents the scope (see also [4] for an explanation of why there is always some scope). Optimize the state to use out of memory storage when necessary. Using the read database is an extra optimization.
  3. You cannot do this. At least, not in the form of invariants, because those only apply within aggregates. Possible solutions: fuse the aggregates as they appear inextricably linked, check if you do not miss an aggregate specifically enforcing this invariant or send out events from one aggregate to another according to the usual scenario and solve exceptions with compensating actions.

To be brief, this post is stripped of all additional explanation. I can imagine that there are questions that remain, which I would like to hear.


[1] See this post by Mark Nijhof for a clear description of what I mean by “CQRS architecture” 
[2] Greg Young himself says CQRS is not an architecture, I agree. It often is accompanied by one, but it does not have a name for itself yet. Proposal: “Circular Architecture”? 
[3] This is explained nicely in this post by Udi Dahan. Search for “Commands and validation”. 
[4] An explanation can be found in a fine post by Jérémie Chassaing.

Written by Rick | Tags: , |

No Comments - Leave a comment »

May
09
2009
3

TDD & DbC @ DotRT

Last wednesday there was another Devnology event: the developers of the round table met at.. a rectangular one. Despite the out-of-place table, it was a very good meeting in any way that matters. I couldn’t shake of the feeling that the program didn’t fully work out as planned, but everybody was completely cool with it and the result was even better than planned. Discussions! And lots of it, of pretty high quality. See for yourself, as a picture says more than a thousand words..

After the event, Pieter-Joost van der Sande and I had a nice little off-time discussion about the interchangeability of Test-Driven Development and Design by Contract. PJ, correct me if I am wrong, but I remember you defending the viewpoint that DbC is an improvement over unit tests and consequently over TDD too. DbC is all a developer needs. :-) Might be a bit of an exaggeration, but it comes close to what you said, right? read more…

Written by Rick | Tags: , , , , |

3 Comments - Leave a comment »

Apr
25
2009
0

Python and the Google AppEngine at the CodeFest

On the first of april the first Devnology CodeFest took place. An interesting group of 16 enthousiastic developers gathered at the Sogyo farm to make an implementation of the Game of Life, the famous cellulair automaton, devised by Conway.

My goal for that night was to make an implementation of the Game of Life in Python and to host this in the Google AppEngine. A nice challenge, since my knowledge of Python did not go much further than that it is a whitespace-significant scripting language that prominently feautures the keyword def and that the language is developed by Guido van Rossom. Oh and of course that the language has now been quite popular for a few years at Google, probably not completely coincidentally about the same period of time that Guido has been working there. read more…

Written by Rick | Tags: , , , , , |

No Comments - Leave a comment »

Mar
12
2009
0

Seminar Fixed price + Agile + DDD

During the evening of March the 17th, Sogyo will organize another technical seminar. In this one, Sogyo employees Rick van der Arend (that’s me!) and André Boonzaaijer will explain how we can handle the wishes of many of our customers to get an agile software project, in a domain driven way, but with a planned and fixed budget.

Experiences they have had in several recent projects will play a central role. Workshop techniques and several other activities you should undertake during the domain exploration phase will be presented. Next to that, Rick and André will answer the question: how do you fill and estimate the SCRUM product backlog up front? In short, this will be an interesting evening.

The seminar starts at 18:00 with a bite to eat and at about 19:00, Rick and André will start their intro. The program will last until about 22:00. Sogyo employees can subcribe to the seminar by sending an e-mail to marketing@sogyo.nl. If you are not a Sogyo employee, but you are interested in this seminar, please e-mail Anneke van Beek at avbeek@sogyo.nl

Written by Rick | Tags: , , , , |

No Comments - Leave a comment »

Mar
08
2009
0

David vs. Goliath

In this post I will give my answer to the question where innovation takes place: in big or in smaller (ict-) companies? An all-or-nothing answer doesn’t seem feasible to me, because we all know examples of big as well as smaller companies that are innovative. But I still think it might be interesting enough to write a blog post about (of course), because I think some differentiation can be made. read more…

Written by Rick | Tags: , , , , , |

No Comments - Leave a comment »

Feb
20
2009
0

Domain exploration – really

The last few week have been quite exhilirating! Two weeks of really exploring a domain, getting to know a new client’s business and language. I have always liked going through such a phase and one does not always get the chance to do something like that for two whole weeks at the client’s site. read more…

Written by Rick | Tags: , , |

No Comments - Leave a comment »

Dec
30
2008
0

Xrump

 After a few years of experience with agile software projects, I have read the Agile manifesto again and afterwards read more specifically about the details of XP and Scrum, the most well-known agile methodologies. It occurred to me that from both ’sides’ a way of mixing the two is actively being sought. It seems like a logical choice to me, as XP has always been targeting more the technical practices to get to a good end result and scrum takes aim at the processes that should enable a team to get to a good end result. But that is just a sidestep. read more…

Written by Rick | Tags: , |

No Comments - Leave a comment »

Dec
28
2008
0

The learning curve

The shame! Two months of inactivity on this blog… the reason? A steep learning curve.

I have been diving deep into the .NET framework, at the sub-CLR level. What all the versions mean, how they interact. How assemblies and modules look like at the byte level. What actually happens when methods are called and types are loaded, how memory management is performed, why the reflection api is built the way it is. Next to that, how the C# compiler targets this platform, in detail. And of course, Visual Studio. What does it do when I make a settings, config or resource file or add a windows forms, etc. How do the project and solution files interact with it. But I also got to know it under the hood, because of my lastest project: developing an exploratory modelling extension package for Visual Studio. By the way, this was all quite new to me, although I have quite recently finished courses up until the MCTS level and already have some development experience in .NET. And it occured to me that a lot of developers never make such a deep dive, even when having several years of experience in developing for .NET. So it is apparently not necessary to be able to do my work. Why did I do it then, you might ask?

Getting to know my working environment a few levels deeper has helped me to better understand it , remember the way to manipulate it and predict how it will behave. I am convinced this will help me get the most out it and to be able to keep working sensibly when things become more complex. I have seen too many developers resort to some sort of trial-and-error when things get though, although most of them have had a scientific education. I have seen people doing bug hunting in very strange ways: not even trying to understand what is happening, but just pushing some buttons, moving some code and see if it works. When the thing you work on is very simple and you have a bit of luck, this usually works and will sometimes even be faster than trying to understand it. But when things get complex, the chances of accidentily solving your bug get very small, very quickly..

Any way, reading a lot of books, doing little experiments and making small applications to see how certain technologies work have taken up a lot of time. Oh and of course, December is always full of parties, weekends away, christmas, etc. Sadly, not much was left for writing blog posts. But the good part is that the quality of future blog posts will probably improve because of all the new knowledge – I hope.

Written by Rick | Tags: , , |

No Comments - Leave a comment »

Oct
30
2008
0

PDC: Azure and Oslo

Lots of new stuff at the PDC that is going on right now.. but Windows Azure (‘Windows in the clouds’) & Oslo generate the most buzz in the developers community. Windows Azure is of course Microsoft’s response to the c2 and s3 engines of Amazon, Google’s AppEngine and a few others. Interesting, but it will take a few years before enterprise software will be hosted outside of a company’s premises, I suppose. Oslo looks like an interesting meta-modelling platform and with the new M language, Microsoft makes their offering of modelling tools a lot more compelling, I think. Not every DSL lends itself to graphical editing with blocks and lines.

For some more coverage of the event, have a look at born2code.net

Written by Rick | Tags: , , , |

No Comments - Leave a comment »

Oct
16
2008
1

Software Developers Conference 2008

Last week, on the second day of the SDC 2008, I visited these sessions:

  1. Deep Dive into Entity Framework Object Services – Julie Lerman
  2. Developing Scalable Apps with Google AppEngine – Nik Kalyani
  3. WPF Data Binding – Brian Noyes
  4. Building a Service Oriented Enterprise System – Dennis Doomen

I will tell you in short what impression each session made on me. read more…

Written by Rick | Tags: , , |

1 Comment - Leave a comment »

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes