Feb 16 2010

The denormalizer in CQRS

Category: Administrator @ 18:06

The “denormalizer” is a component responsible for mapping data from the domain model to a denormalized table structure at the query side (an over can be found here). Usually the denormalizer component runs as a windows service at the server hosting the query side. Its only responsibility is to move data from the command side to the query side, and function as a router for messages from the write side. You might not want the same data on all the read servers.

Database tables matching view models

On the query side, all the tables match a view model in the GUI. Yes, this means you will end up with some duplicated data in the database tables, but that’s ok. Hard disk space is cheap.

Let’s look on how the denormalizer fits into the architecture.

image

When the domain model have done its stuff, an event is raised and a message is sent through a “pipeline” to the denormalizer on the query side. The “pipeline” can be a queue or something else that is fit to move the message in a safe way. I have used NServicebus with a lot of success, but there are other ESBs or other ways to do this.

Easy programming model

When the denormalizer receives the message, it spreads the data into the tables that needs to be updated . The tables have a one-to-one relationship with the view models. A GUI view can have multiple view models. What this gives you is a very easy programming model on the query side. All you have to think about concerning the denormalizer, is to insert/update the data to the correct tables. From the client, you look at the data as reporting data; meaning you can’t update or insert data on the query side.

NOSQL

All though I’m referring to a relational database at the query side in this post, it doesn’t have to be a relational database. You can use a non relational database if you want to. I would recommend MongoDB over a object database like DB4o, but that’s just my taste at the moment. You can even build your own key-value store because in most GUI views you will just fetch data based on an id.

Summary

To sum it up; the denormalizer routs the messages from the command side in to the correct tables on the query side.

Tags: ,

Currently rated 4.3 by 3 people

  • Currently 4.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Aug 30 2009

Services

Category: DDDAdministrator @ 17:24

When starting to learn Domain Driven Design, entities and values objects are things people normally understand pretty quickly. But, when it comes to services, I feel things are a bit more unclear for many. If you ask a Domain Driven Design expert about services, you probably will get the answer; a service is something you can’t find a good place for in your domain model.

A concrete example

image

In almost every modern GUIs you use combo boxes as a way to display different choices for the user. You need a way to fill these boxes (look at the figure), but the action where you fill them doesn’t fit into your domain model in a natural way. I look at this as a service, something you need in your domain, but nothing you will force into your domain objects. In the applications I have created lately, I have often used value objects to transfer the data from the repository to the GUI through a service (follow the red arrows in the figure). You can of course create dedicated objects for this (follow the orange arrows in the figure), but I haven’t found the need for this yet.

 

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Jul 2 2009

A great book to get you started with NHibernate

Category: Administrator @ 15:13

Lately I have tried to learn NHibernate. NHibernate is a object-relational-mapper. It maps data from relational databases to POCO-objects. So, what is useful about that, you may ask? Well, for a starter, it’s very handy when creating a rich domain model. If you read this blog regularly, you may know that I’m also in the process of learning Domain Driven Design.

Domain Driven Design and NHibernate

The idea behind DDD is that you focus on the domain model instead of focusing on the database or GUI when trying to capture the business value from a domain expert. If you follow the guidelines described in the books written by gurus on the topic, you will end up with a domain model that is loosely coupled from the other parts of the system you are creating. That means you don’t have a coupling against the GUI, the database or any other parts of the system. But, you still need to persist the data from the domain model to the database in some way, and this is where NHibernate comes in to play. By setting up a mapping, described in a file, from the domain model to the database you can make NHibernate do the mapping for you. How cool is that? I guess you knew that already, but the purpose of this post is not to tell you how cool NHibernate is, but to guide you in the right direction of how to start learning NHibernate.

How I learned it

image

My first approach to learning NHibernate was to look at the excellent screen casts made by Stephen A. Bohlen called Summer of NHibernate. I learned a lot from watching these screen casts, but I still felt like something were missing. It’s like when you go to a conference, at the end of the day you can’t sit down in front of the PC and start to crank out code based on what you learn that day. But, it gives you a starting point. You often get information of how to investigate the topic further. This is what Summer of NHibernate did for me and it pointed me in the direction of a book called NHibernate in action.

Beside giving you a good start on setting up and using NHibernate, it also explains how to write real-world domain models. It tells you how to set up pretty complex associations between entities and why it’s important to understand why a domain model should be persistence ignorant and so on and so fourth. If you want to have a look at the index of the book, it can be found at this link.

If you want to learn NHibernate you definitely should look at this book.

Links

Links to NHibernate resources I have used and use:

- Summer of NHibernate (screen casts)
- Dimecasts.org have some screen casts on the topic (max 10 minutes long)
- NHibernate in action (excellent book on the topic)
- NHibernate.org (You can download the binaries from this site and you find documentation)

Happy learning!

Tags:

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Dec 2 2008

My tool belt

image

Earlier this fall I was tagged by Gøran Hansen. He wondered what tools I use besides Visual Studio. Here is my response to his post:

Addins:

- ReShaper (How can you program without this one?)
- Testdriven.NET (Great addin, but I don't use it much because of ReSharpers possibilities to run unit tests.)
- GhostDoc

Developer tool belt:
- NUnit (I know there are many frameworks out there, but this is a safe one that "everything" supports)
- Moq (mocking framework --> If you haven't looked at this framework, you should!)
- Tortoise SVN (code repository)
- Git (local code repository. I normally use this as a "shelf" for SVN.)
- CruiseControl.NET
- Team City (I really like this one. I don't like XML hacking :-) )
- MSBuild
- Nant
- RhinoMocks (Great framework, but maybe not so intuitive?)

Well, there's my list.
Do you have suggestions to tools I should look into?

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Dec 2 2008

Welcome to the Blogosphere, Kjetil!

Category: New bloggerAdministrator @ 12:25

A good college and friend have started blogging. You can find Kjetil Klaussens blog at http://www.kjetilk.com

His blog is called "A World Full of Sharp Objects". I'm looking forward to some great posts from this guy.

image

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Dec 2 2008

Talked at NNUG last Thursday

Category: NNUG | Presentation | SpeakerAdministrator @ 12:24

I held a short presentation about some of the new features in .NET 4.0 at Norwegian .NET User Group last Thursday. I talked a bit about the dynamic keyword and had a very short look at Code Contracts. Joar held a short talk about new features in Visual Studio 2010. Before Joar and I talked, Tore Vestues held a very good talk about the programming language Boo. I was inspired by his talk, so I will for sure have a look at this language soon.
This is cut from the Boo web page:

"Boo is a new object oriented statically typed programming language for the Common Language Infrastructure with a python inspired syntax and a special focus on language and compiler extensibility."

You can find the slides from my talk below.

image

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Nov 16 2008

You shouldn't use a electronic storyboard

Category: Scrum | ThoughtsAdministrator @ 14:46

Have you ever experienced how pacified you can feel when a co-worker takes control over your keyboard and mouse? It feels like he or she is intruding into your personal sphere. You might have asked for help, but not to be invaded. It's strange to think of how much "power" the person controlling the mouse and keyboard has. If the person holding the keyboard and mouse isn't aware of the "power" he or she got, and don't bother to include the other person, it's likely the person falls into a apathetic state just watching the screen, and not focusing on how to solve the problem.

When doing a sprint planning you should avoid using a electronic storyboard. My experience is that you end up with one person, probably the scrum master, running the whole show. The other team members will probably sit pacified looking at the screen. Doing nothing, or in best case trying to participate but not being able.

You should rather use a story board hanging on the wall in your office. Perhaps a whiteboard or maybe a board made of gray paper. And Post it’s, of course. This way everyone can participate in the process of adding tasks (and user stories). This promotes cooperation and builds team spirit. Everyone can have hands on experience with the process. It builds understanding for the problem being solved. It lets the team work more in parallel. While one team member is finishing writing one task (or user story), another member can start with the next task (or user story). I'm not saying that an electronic story board can't be used, but you should have very good arguments for using it. It's to pacifying!
If you disagree, remember one of the statements in the agile manifesto; "Individuals and interactions over processes and tools".
What is your experience with electronic story boards?

image

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Nov 3 2008

Held a presentation at DND

Category: DND | Presentation | SpeakerAdministrator @ 16:49

On Saturday my plane landed at Trondheim airport. I had then been traveling for approximately 25 hours in a row. And slept for about 1,5 hours. Oh, by the way, I have been to PDC in Los Angeles the past week. Will post more on that later. To get back on Norwegian time, I decided to stay awake until 10 O'clock in the evening. It was a really hard day, but I managed to hold my eyes open almost the whole day.  My eyes where open, but it wasn't much brain activity. When I woke up on Sunday I wasn't really trilled about the thought of holding a presentation on Monday evening. My thoughts where more like: sofa and TV. 

On Monday evening I managed to stay awake and held a decent presentation. I spoke for about 40 people. Most of theme not developers. That was a challenge for me, but I think most of them where pleased with the presentation.

For those who is looking for the presentation; it can be found in the link below.

Off to bed :-)

Enhetstestingfraskyttergraven.pdf (1.46 mb)

Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Oct 26 2008

Pre-party at PDC

Category: PDC2008Administrator @ 22:33

I'm at PDC  in Los Angeles at the moment. Last night Joar Øyen, Kjetil Klaussen, Paul, Kim Bjerkevoll and I was invited to join Jonas Follesø at a RD party held by Microsoft at Tim Huckaby's house. People like Carl Franklin, Richard Campbell and Scott Hanselman where present at the party. Some guys from Microsoft had brought a Surface table to the party, and Hanselman demonstrated his Baby smash application on it. It was awesome to see how well the surface table worked. I'm definitely getting one when the pricing is right. The Baby smash application was tested by a real baby (one of the guys had brought his family), and it went well concerning the circumstances. The baby cried a bit, but looked like it was amazed by the faces moving around on the table. We meet a lot of interesting people at the party and had a really good time.  A lot of thanks to Jonas for inviting us.

image

Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5