Skip to main content


Showing posts from 2012

Speaking experience

Been a long time since I last blogged. There were many things happening, which were pulling me away from writing. One of those things was an opportunity to share my thoughts with a wider group in public. Recently I gave two talks - one in my company, and a second during JavaCamp #11 . The second one was filmed and you can watch it below (in polish). The topic was "Changing the mindset - more object-oriented view at the business domain modeling" and it was based on my series of previous blog posts (links below). I briefly introduced audience into Domain-Driven Design, Command Query Responsibility Segregation and Event Sourcing concepts. The main thing in my presentation however, was to show how developer's mindset is changing when meets those contemporary techniques. I wanted to emphasize what questions she starts to ask and what things are becoming more important while she goes step by step over this "rope bridge". Both speeches were well recieved, I th

Should tests influence the production code?

For a very long time I was told that tests should not influence the production code. By this I mean, that we should not change our design only in order to be able to test it. That was quite OK for me, since - you know - test are only tests - the production code is what matters and what drives the design. Tests should just shut up and follow. Right? Lastly I am flipping the bit and diving into TDD and I must say - this is quite an adventure. At the beginning I was like a babe in the woods. It was not easy to start. Everything was harder - writing code, designing, thinking... I had to firstly write a test, and then the code - everything was upside down - I didn't even have the code to test. Damn! I started to think about basics again, and that... was really refreshing! The Example One day I was given a task to figure out changes in history lines of some objects and update the meta-data for each line accordingly - with ids of objects that were changed. For the simp

5 reasons why we (still) do not like patterns in the heart of software

We like Design Patterns. They make complicated things simpler. Our brains are designed to tackle complexity with them. It is easier to describe something with words "it's like that one thing that you know, but with some differences" than describing it completely from scratch. All frameworks that we use are full of Patterns and we understand them very well. Decorator here... Chain of responsibility there... Oh, and some old, nasty, huge and extremely overloaded Singleton over there - yup, we use it too... Piece of cake. This is our (developers) well known Domain. We are Domain Experts on that territory and we feel confident there. The reality But guess what - this is not the Domain that we are dealing with on daily basis (unless we are working on frameworks of course :P ). Our Domain, which we are struggling with, is about the business that runs our company. We don't need those mentioned Decorators and stuff. At a glance, it looks like we can ju

7 lessons learned from launching my DDD/CQRS/ES startup

It's been a month and a half since I wrote the last blog post. This time it was not because I am lazy (although in general I am), but quite the opposite. I was very busy with launching my startup application written after hours at home with my brothers. For the couple of last weeks, there was the Euro 2012 Cup in Poland and Ukraine, and everybody around me was crazy about the football those days. On the other side, couple of months ago I started to practice Domain Driven Design with Command Query Responsibility Segregation with Event Sourcing . I combined those two and launched my startup as a Facebook application written in this style: " Typer " (at this moment only in Polish). What were my goals? From the personal perspective , I wanted to give people some opportunity to have fun - to type scores in their own groups, compete with each other and find out who is the best football specialist. From the business perspective , I wanted only to generate s

Event Sourcing is like Vector Graphics

I want to emphasize at the outset, that I am not an expert in graphics.  I just have some basic knowledge, but based on that I was able to coin this parallel. I assume, that you have some basic knowledge about Event Sourcing and CQRS , but if you don't please refer to this definition or watch Greg Young's mindblowing 6,5h long classes (if you already do have some knowledge, watch this video anyway - it is worth your time). I also assume that you have some very basic knowledge about Vector Graphics and Raster Graphics . What is an Event? Stop for a moment and think. Probably you will come up with an answer, that an Event is an Aggregate's state change which occurred. And this is a very good answer indeed. Guess what. Vectors can depict the state change too! So Events may be treated as Vectors, right? Below I will write down some similarities that Event Sourcing has with Vector Graphics, and 3rd Normal Form databases have with Raster Graphics. 1. Scali

Convention over implementation with Spring Data

I think that most of us are familiar with the term " Convention over configuration ", but just to remember (from wikipedia): The phrase essentially means a developer only needs to specify unconventional aspects of the application. For example, if there's a class Sale in the model, the corresponding table in the database is called “sales” by default. It is only if one deviates from this convention, such as calling the table “products_sold”, that one needs to write code regarding these names. When the convention implemented by the tool you are using matches your desired behavior, you enjoy the benefits without having to write configuration files. When your desired behavior deviates from the implemented convention, then you configure your desired behavior. For example, the maven project structure uses convention - where our source files, test source files and resources should be placed in order to be compiled, tested and packaged automatically. We save a lot o

My 3 cents on 33rd Degree Conference

One of the best conferences for Java masters in Poland has ended. The 33rd Degree . I've been on the previous one and I really enjoyed it. Totally 5/5. However, this year was a little different. I also liked it, but I think it could be better. Some speakers were inspiring, some were boring. ;) And some were talking about things that I already know... Maybe I should read less? ;) So to shortly sum it up - there was not a single mindfuck during this edition. And that's a pity. I decided to give subjective marks for each presentation that I attended and here they are:

CQRS vs DDD popularity

Let's imagine a situation. You are a person that has some time and wants to learn something new. You have two options briefly presented: Domain Driven Design on the one hand and Command Query Responsibility Segregation on the other. What would you choose? (Before you start reading below, understand that I compare those two concepts only theoretically and I am not taking under consideration how they interact with each other) For me it would be pretty straightforward - DDD of course. Why? I will explain below. However for most people that I have met I see the opposite... I still cannot fully understand why, but let's try to investigate a little... What Google says?  I made some quick investigation in the Google Trends. I typed "cqrs" and "domain driven design". When I typed "ddd" or "command query responsibility segregation" the results were unreliable. We can see that DDD was first and at the very beginning it was m

Changing the mindset - part 4 / 4 - Subtle difference

This is the last article out of the series about changing the mindset. At the beginning we took the Classic approach , and then we introduced three important concepts (in the order): Domain Driven Design ( Modeling the Domain ) Command Query Responsibility Segregation ( Segregation of Responsibility ) Event Sourcing ( Segregation of Responsibility ) In the previous part we separated our Read and Write Models. We also applied Event Sourcing as a persistence mechanism for Aggregates. We also equipped the Aggregate with behavioral methods only, and got rid of getters. Everything looks really nice. The Model is clean, verbose, and everything is explicit (as for such a small example). We have one data store for the Write side, and we don’t have to care about distributed transactions. We can even easily provide historical data. However, if you paste the last piece of code from the previous part to your IDE, you will see that there are many warnings on the fields – "never

Changing the mindset - part 3 / 4 - Segregation of Responsibility

In the previous part we created quite verbose object oriented Model of our Domain. The Domain itself is extremely simple, but try to imagine your Model, which you are working on day by day, that would be so explicit. Wouldn't be easier to understand it? Whatever you can do on an object, you do it directly through methods, which names and arguments, comes strictly from the Domain Language. And even those objects' names come from this Language too. Well, this is just OOP done right, isn't it? There is actually one issue with that approach. We want to show some of the data to the user. And if so, then we have to expose internals. So in addition to our well-crafted, encapsulating behavior methods, we have leaky getters... Clean the model Let's do something that may look a little strange for the first time. Remove those getters. For a moment don't think about the View. Doesn't the Model look pure and clean without them? It has only behavior as a bo

Changing the mindset - part 2 / 4 - Modeling the Domain

In the previous part we created Anemic Entity Match which was connected to another Anemic Entity Team , and they both were ruled by a Service MatchService . We had a bunch of getters and setters in them, which could be executed from any place that we can imagine. We didn't have any behavior in our domain objects. As I previously said, it can be a very good approach... Of course, if you are writing your code in C or Pascal... ;) After all - doesn't those, so called, Entities look like structures or records? And please do not tell me, that getters and setters are encapsulating the state... If we consider ourselves to be Object Oriented Programmers, than we have to start thinking differently. It is not enough to make our objects out of data. We have to teach them how to act. Where to start? OK, so we want to start changing the way we think to more Object Oriented, but where should we begin? If we cannot just define the data and put it into structures, where

Changing the mindset - part 1 / 4 - Classic approach

There are a lot of materials how to model Aggregates and Entities in Domain Driven Design . There are also a lot of materials how to manage your Event Stores, when you are applying Command Query Responsibility Segregation with Event Sourcing . And definitely there are a lot of materials how to combine those ideas together. However, I cannot find any articles about the way that developer’s mindset (and his code) is being changed when he tries to leave the Anemic Domain approach and goes into the deep with all the concepts mentioned above. So let’s take a closer look at it. I will provide an example and try to depict how my mindset was changed when I was adding new things to my code. I will use a very simple domain and model it in the easiest possible way, so as not to obscure the picture. This is the first article out of four that I will write in the nearest future, so stay tuned. One can debate if my approach to modeling the domain is the best, but for this series, I th

2011's mindfucks

Do you know what mindfuck is? Quoting the urban dictionary : An idea or concept that shakes one's previously held beliefs or assumptions about the nature of reality. I like this definition, but I would widen it a bit. This idea or concept doesn't have to be based on held beliefs nor assumptions. It can also broaden the horizon by introducing something completely new. However this has to really change one's perceiving of the reality. Once you see it, you will not be able to miss it again. The 2011 has gone and it is a part of the past right now. It is a good moment to stop for a while and look backwards to see what has happened during the last twelve months. There were two people who messed up in my head in the previous year. I met both on conferences in my home city, Kraków (Cracow). The first person was Linda Rising. I haven't heard about her before, but she gave such a great prelection on the 33rd Degree , that I decided to dig deeper with her work and I d