2011 in books
Dec 20th
December is traditionally a time of retrospective posts. Forgive me please but I simply can’t resist following this trend. I’d like to share with you my thought about books I read this year. Hope you’ll find it useful when deciding what to read next.
REST in practice
This was the first Kindle book I bought. After reading it I could say I love both the book and the device. I learnt quite a lot about the principles of REST. The hardest part was understanding why these hypermedia are so important but then came the moment of enlightenment. I can for sure recommend reading it.
CSS: The Missing Manual
I must admit I had quite high expectations that I will learn how HTML layouts work and how to efficiently position elements. It turned out to be a book about CSS syntax and very basic stuff I already knew.
Management 3.0
I wanted to learn a little bit about management for quite some time and suddenly this book came out. I simply love all the analogies (i.e. to bacteria) Jurgen uses in the book to explain how such complex systems as software developer teams work. Recommended to everybody, even if you don’t plan to become a manager.
Event Processing in Action
Another high expectation book and another disappointment. I expected a good book on event-driven architectures but actually EPiA is a book about taxonomy and nomenclature of event systems. Not much more than a bunch of definitions.
Dependency Injection in .NET
I bought it via Manning early access program and it was for sure not a waste of money. Although because I had some experience with DI before and have been up-to-date with blogs and tweets of Krzysztof Koźmic and Mark Seeman, there was not much new to me in the book. Still, I don’t regret the money and I can happily recommend the book, especially if you are new to DI.
The Pragmatic Programmer
A friend of mine recommended this book to me so I though I can give it a try. I had mixed feelings after reading it. I can’t recall a single thing that altered my thinking or opened my eyes to some new insight. For sure it is a solid book and at the time of writing it contained some cutting-edge stuff but after a few years these ideas have become mainstream and their understanding is expected even from novice developers.
JavaScript: The Good Parts
Another tentative one. I expected a lot more hardcore stuff in the book. It left me with a feeling that I know JavaScript (which is bullshit). If you happen to don’t know it at all (are there such people?) it may be a good book to start with.
Streamlined Object Modeling
After hearing so many good things about the book on Domain-Driven Design group I simply had to read it. To my surprise I dint’t like it. I could not get rid of a feeling that authors promote some catch-it-all model they developed and claim it solves all problems (even probably hunger in Africa). The only thing I really liked was the modeling heuristic that objects that are active in real world tend to work better if modeled as passive in the domain model and vice-versa.
Working Effectively with Legacy Code
I bought this one because we started to rewrite some legacy code in my current project. I wanted to learn from the expert how to deal with such code. It turned out to be a good, solid book. I don’t remember any particular moments of enlightenment but for sure I learnt a lot.
Continuous Delivery
This is the last one. I’ve been reading it since Saturday and already read about 70%. Continuous Delivery is probably the best book I’ve read this year. Together with REST in Practice and Management 3.0, it totally changed the way I see software development as a process. Thanks Jez and Dave!
Looking into the new year…
There are several themes that dominate my Amazon wishlist for the next year:
- C# (need to refresh my knowledge)
- Lean (having heard a lot about Kanban I finally need to read some ‘classic’ books)
- Architecture (Pattern Oriented series in particular)
I would also like to read some ‘true classics’ like Extreme Programming Explained by Kent Beck. Life will show if this is doable…
.NET is not an enterprise application platform (yet)
Dec 12th
…Windows is. If you have been convinced by Microsoft that .NET is an application platform for the enterprise, here is a list of arguments proving that it is not (yet).
- IIS is not an application server. All it provides is serving dynamic web pages and hosting WCF web services.
- AppFabric have not delivered on its promise. Nobody is using workflows so the only widely usable part of it is the distributed cache (which, I must admit, is nice).
- IIS does not allow to host scheduled tasks. For these you have to use Windows Scheduler which operates on OS level.
- IIS does not work well with custom threading models so things like NServiceBus have to be hosted as Windows Services.
- IIS does not have a decent monitoring & management story. You have to use WMI which, again, is an OS level service that does not speak .NET language and is quite cumbersome do use.
Convinced? So here’s a list of things which you, as a developer, can do to fix this problem
- Extend IIS or create a complementary service that can use the same model as IIS (one core process per system + process per application) that would host scheduled tasks and could incorporate custom threading models thus allowing to run things like NServiceBus. TopShelf would be a good starting point.
- Assembly is not longer a good deployment unit — it is too small. Provide a packaging system that would allow to package several assemblies (a functional module) together. Such a module could be easily deployed (and undeployed) from the application server as a whole.
- Create a decent scheduling library. The only one there is, Quartz.NET, is probably one of the oldest .NET open source projects still in use. It desperately needs a replacement that follows today’s design practices.
- Think about how you could contribute to NetMX or come up with a completely new, lightweight, monitoring & management framework.
Having all these things built, it would be quite easy to assemble an open source private cloud infrastructure. The goal would be to have a farm of servers running either Windows or Linux/Mono that can be treated as one logical machine to which I can easily deploy all kinds of components including (but not only)
- web applications (using various MVC frameworks)
- scheduled services
- message consumers (using various frameworks like NServiceBus or MassTransit)
- web services (using, again, variety of frameworks like WCF or OpenRasta)
delivered in easy to use packages.
Global Day of Code Retreat
Dec 7th
Last Saturday I attended the second Kraków Code Retreat which was a part of the Global Day of Code Retreat. The event was organized by Kraków Software Craftsmanship society, [sckrk].
The organizers did a great job preparing the meeting. There was even a coffee machine for those who, like myself, can’t start a proper coding day without a cup of coffee (or two). Because the event started so early (between 8 and 9 AM), the organizers ensured that we have sandwiches for breakfast. It was a very nice surprise.
On the contrary, the form of the event was not a surprise for me. Partially because I attended the previous code retreat [sckrk] organized in April and partially because the form of these events is pretty much standardized. There are 5-7 sessions, each about 45 minutes long. During each session we try to solve exactly the same problem (the most popular one is Conway’s Game of Life) the best way we can. The assumption is that we work in pairs and we all employ TDD. The amount of time is calculated in such a way that it should be very difficult to finish the solution. The reason for this is, during a code retreat, you should not focus on getting things done but, instead, on writing the most beautiful code you can.
I was quite surprised by the fact that we (I paired with Piotr Leszczyński for this session) managed to solve the problem within the provided time frame. Especially given that I did not manage to solve it during the event in April. The key to our ’success’ (remember, it’s not the completeness of the solution what matters here) was probably the fact that we both have had some experience in both pair programming and TDD. What is more, we did practice these disciplines together in some point in time. I really enjoyed these 40 or so minutes. It would be worth attending the event even for this one session. On the solution side, it was not particularly clever or beautiful. It was not purely object oriented and some abstractions were missing. But my feeling was it was a good SOLID code. The downside of having a complete solution in first try was that I was under it’s influence for the rest of the day. It was hard to think in a completely different way.
The effect was, I spent two sessions refining this solution. One of the improvements was making the coordinates a class on its own. It encapsulated the way neighbourhood (the key concept in Game of Life) is defined. We didn’t have enough time to make the last step and make our game board generic of T where T is an implementation of some Coordinates. It would make changing the coordinate system (for example to spherical or 3D) a trivial task.
The other improvement was made in the method that returned neighbouring coordinates for a given coordinate. In the first solution we just hard-coded it like this:
yield return new Coordinates(x, y - 1); yield return new Coordinates(x, y + 1); ... yield return new Coordinates(x + 1, y);
The improved solution looked like this:
return (from x in Enumerable.Range(-1, 3) from y in Enumerable.Range(-1, 3) select new Coordinate(x, y)) .Except(this);
It puts grater emphasis on the intent. It would be even better if Enumerable.Range method has min and max parameters instead of min and count.
Like I said before, one of the assumptions of core retreat is to test drive the design. The problem with this approach is, it is hard to force a completely different solution only be means of writing proper tests. I wanted to try something different so I convinced Piotr to leave TDD aside for one session. We agreed to use test-first approach but implement the design I proposed. Piotr suggested that we should also refrain from writing any conditional statements (if, switch). This sounded like a fair deal.
What we tried was an actor-based approach. Every cell was an actor which was able to respond to various events. The environment was responsible for routing these events so that cells get events generated by their neighbours. The solution was turn-based so that in the beginning of each turn every cell got events from other cells and at the end — a clock event from the environment. The response for this event could be either ‘alive’ or ‘dead’.
The other interesting thing about this solution was, it allowed us to get rid of conditional statements in a quite elegant way. We used a state pattern to process the events:
public interface IState
{
IState ConsumeAliveEvent();
IEvent GetResponse();
}
There can be four possible states in the game: base (cell will die in next round), after consuming one alive event (will also die), after two (will survive), after three (will survive) and more than three (will die).
Unfortunately we didn’t have enough time to finish the code, but it was quite promising. Especially the tests which were in form of statements like this
given these (events) happened, the cell should generate these events
In quick summary I would like to encourage you to take part in every code retreat event that is organized in you neighbourhood. It is really worth it, event if you have some experience in TDD and/or pair programming.
Events are not an implementation detail
Nov 29th
When listening to many discussion about Domain-Driven Design and Event Sourcing, subjects which I am recently very into, sometimes I have a feeling that events are considered merely a way of persisting aggregates. People tend to discuss benefits events have with regards to storing historical data, having possibility to generate any read model out of events and so on. Reducing event sourcing to such ‘housekeeping’ duties is castrating your architecture.
This point of view is expressed in a way people model their event-based solutions: thinking first about the aggregates and then, within each aggregate, about events they generate. Sometimes the process is even more event-UNcentric when people first implement a command and then start thinking about what event types should be created.
Given the fact that most Event Sourcing practitioners have a background in DDD, we tend to bring our experience from working in data-centric environment to the event-centric world. There is, however, a fundamental difference between these two.
When building a behaviour-oriented DDD solution on top of a data-centric infrastructure (a database) you do your best to hide the database and its schema from the business layer. Over the years we learnt that it is better treated as implementation detail because it does not provide concepts useful to model behaviour. There concepts must be built on top of it. The underlying data layer must not be visible to the outside world because of it’s volatility — it has to change whenever the behaviour it supports needs to change.
On the other hand, when building a similar solution on top of event-centric infrastructure you can (and should) leverage events to model the behaviour. They (not aggregates or anything built on top of them) are the central concept here. Whenever business changes, new event types appear and some old are no longer generated but no event is ever lost. Whatever happened, happened.
Returning to my original thought, in an event-centric solution aggregates should not be treated as first-class citizens. Don’t get me wrong, they are very useful. In a healthy design probably a vast majority of events would be generated via aggregates, but some would not. Aggregates are priceless when it comes to modelling concurrency and to encapsulating business logic.
You may now want to ask a question when should you use aggregates and when not? The answer seems to be simple. Whenever your system needs to respond to some external activity, you just directly inject an event representing what have happened into your system. The idea is, again, whatever happened, happened. You can’t throw concurrency exception at The World saying it is wrong to raise this event right now. You have to humbly acknowledge the fact and record the information. On the other hand, when it is your system who conducted the activity to be communicated by an event, you should use an aggregate to have full control over how and when the event is published.
Have fun building event-centric solutions!
69. spotkanie KGD.NET
Nov 22nd
Chciałbym zaprosić wszystkich na 69. spotkanie Krakowskiej Grupy Developerów .NET. Spotkanie odbędzie się jak zwykle w siedzibie ABB, przy ulicy Starowiślnej 13. Będzie także dostępne on-line dzięki uprzejmości portalu VirtualStudy. Na spotkaniu, jak zwykle, dwie sesje. Tym razem będą to:
Kanban – Usprawnienia bez wysiłku, którą zaprezentuje Paweł Brodziński, oraz
Software as a Service – jedna baza danych, wielu użytkowników, którą przedstawi Maksymilian Majer
Po spotkaniu zapraszamy wszystkich na wspólne piwo. Będzie to okazja, aby podyskutować z prelegentami na temat ich prezentacji w bardziej nieformalnych warunkach. Pierwsze dwie kolejki tym razem (to nie reguła) stawiają prelegenci!
Zapraszam do rejestracji na spotkanie tutaj.



