Archive

Author Archive

DDD Immersion Course review

March 8th, 2010 stiiifff No comments

I recently had the chance to follow a 4-day Domain-Driven Design Hands-on immersion course in Paris, with Eric Evans.

It was very inspirational, probably the most interesting course I’ve followed to date. The amount of knowledge contained in the DDD book can be daunting to master, and the course succeeds in clarifying the most complex aspects of DDD as well as delivering the latest evolutions of the approach.

If you are interested in this course, Paul Rayner has written an amazing series of posts about it:

  • Part One – Introduction. What is DDD? Ubiquituous language? a Model?
  • Part Two – Building-Block patterns (eg. Aggregate. Domain Event. Creative Collaboration etc)
  • Part Three – Strategic design – Bounded Context and context mapping.
  • Part Four – Strategic design (continued) – Core Domain
  • Part Five – More on supple design (Specification pattern). Implementation concerns. Discussion.
  • Part Six – Design and agile.
  • Part Seven – Final. Course takeaways and other thoughts.

Happy modeling !

Categories: DDD Tags:

Donate for NHibernate

March 1st, 2010 stiiifff No comments

A donation campaign has started in order to help a great open source tool become even better : NHibernate.

If you are reading those lines, the probability that you or your customers have been using NHibernate, and leveraging its powerful features, is quite high. In a way, you have benefited from Open Source software at its best.

It is therefore a great opportunity for you or your customers (encourage them !) to show support to the people who have spent countless hours crafting a great free tool, and who will, hopefully, continue to do so ;)

Donate !

Categories: ORM Tags:

Mono track @ FOSDEM 2010

February 22nd, 2010 stiiifff 1 comment

2 weeks ago in Brussels, I had the pleasure to attend FOSDEM 2010, regarded as”The best Free Software and Open Source events in Europe“. I’m not ashamed to say that I’ve no experience with Mono so far, but I’m a curious guy, and the event was not far, and even better, free … so I thought, let’s go have a look to see how things are going in the free world ;-)

All in all, I was pleasantly surprised from what I saw. Apart from the fact that the attendees are somewhat different from those you see at the typical Micro$oft conferences, the atmosphere was very nice and you could see a lot of geeks, some younger, some older, having all one common point : the passion about softwares & new technologies.

I mainly followed the Mono track and here are a few things that I think are worth mentioning:

  • The Mono project & Microsoft are not at war (this may be obvious to some but anyway) … they seem to have healthy collaboration (obviously, within the usual legal boundaries that apply). We are far from the clichés of Microsoft, the Evil Empire vs The Good Free World. This is a good thing, diversity brings more creativity, and thus more choice to people.
  • Miguel de Icaza, the charismatic leader of the Mono project, and Vice President of Developer Platform at Novell, was there to make a state of the union speech. Among other things, he praised entrepreneurship (he seems to like Apple and the iPad), talked about the evolution of C# and how good a language it is for most purposes, and granted the audience a few good quotes:

Any developer below the C# bar is just miserable.

No Coca-Cola today ! (Talking about the fact that he would try no to make a marketing talk about Novell’s products)

  • Mono Develop is improving very nicely. I wouldn’t trade Visual Studio for it yet, but it’s interesting to see how those guys are doing their best to provide a free alternative to the Microsoft star IDE.
  • If in the past, Mono was usually lagging far behind and mostly playing catch-up, they are now able to release their free implementation almost at the same time as Microsoft releases major revisions to C#, .Net & Silverlight. Ok, they may not have all the features of the original implementation but this is still an amazing achievement.
  • Mono also has a few unique features that are yet to make an appearance in the .Net world : Ahead of Time compiler & SIMD extensions.
  • Last but not least, MonoTouch allows you to develop for iPhone & iPad in C#.

All in all, those guys are doing a great job, and, for us, typical .Net developers / consultants, looking at the other side of the fence from time to time, is inspirational.

Therefore, DotNetHub would be very happy to welcome speakers that would like to do a session about the Mono project & related technologies. Don’t hesitate to contacts us !

Categories: Mono Tags:

Dependency Injection Inversion

January 19th, 2010 stiiifff No comments

Seems there is still a lot of confusion about what is Inversion of Control, what is Dependency Injection, what are the differences between the two, and how to apply one or the other properly.

Several people have reacted to a controversial post by Uncle Bob on that topic with, among the most vocal ones, Davy. ;-)

IMHO, some of the best posts on the subject that really make a clear distinction between IoC & DI are the following ones:

The whole point of IoC (forget a minute about DI) is to break the dependencies between your classes and design them as  loosely-coupled as possible (to the point that it’s actually useful of course, it’s not an engineering contest).

All the benefits that you get:

  • Dependency Injection
  • Better testability
  • Better maintainability

are just consequences of the good design of your classes (read about SOLID also).

In the end, it’s just good Object-Oriented design, nothing more. And by good, it doesn’t mean complex, it’s actually quite simple once you got it.

Categories: Castle Project, MEF Tags: , ,

2010 Predictions galore

January 8th, 2010 stiiifff No comments

Just did a quick tour on the net about the predictions being made for 2010 in the .Net world … and what is so striking, is that almost everywhere, Silverlight, with its 4th incarnation, is being touted  as one of the stars of the year.

Here a list of random picks:

In 2010, Silverlight 4 will help you build Line of Business (LOB) applications so easily that it’s gonna be laughable. Think about it for a minute … SL allows you to develop web applications that have desktop-like rich feature sets in a cross-platform manner. Also, those web applications can be taken out-of-browser and used as ocasionally-connected applications. Even better, it can transparently leverage your powerful GPU to integrate some crazy-never-seen-before-groundbreaking UI metaphors. Sounds like heaven ? ;-)

Well not yet, because until recently, it was still difficult to access data from a Silverlight application … you had to go through all that boring thinking to design a 2 or 3 tiers architecture, probably passing some DTOs around, mapping, converting or even better, change-tracking, across tiers. But this is soon going to be the past, as RIA Services will simplify all of that. RIA Services is ADO.Net for Silverlight. It lets you access your database directly in your rich UI, query it, change-track it, validate it, bind it, xaml-ize it. Add some LINQ-icing on top and you’ve got some more great magic happening in there.

Sounds like something familiar … desktop applications, almost-direct database access … didn’t we have that in the past ? Wasn’t it a thing called Client-Server ? Damn yeah ! That thing was so simple, I remember now ! Why did we go through all those crazy architecture evolutions, design patterns, … to finally come back to it ! You gotta be wondering ;-)

Anyway, I hope that by now, you’ve noticed that I was a bit ironic about all of this … because I think that you have to be very careful with the latest cool stuff and not just blindly think it’s gonna solve all of your problems. Silverlight is a very fine piece of technology, but it’s easy to fall into some bad practices. RIA Services will be the same kind of beast. It will bring some interesting abstractions, but as with all abstractions, you’ll have some simplifications that will be applied here and there, so beware.

So, let’s get into the game, here are my predictions for 2010:

  • Silverlight will indeed see a broader adoption, and WinForms / WPF desktop applications will continue to slowly decline. There will also most probably be more and more SL projects that, by trying to do so much in a browser, will have performance, scalability & memory problems. Similarly, backend resources will continue to be used inefficiently.
  • Ayende will most probably add a RIA Services-Prof to its profiler suite, helping developers understanding why the heck are so many HTTP requests being sent from the UI to the backend server.
  • The reality depicted by M. Nygard in 2008 will still hold true in 2010 (just replace J2EE by .Net).
Categories: Silverlight, Uncategorized Tags:

Looking back at 2009, and forward to 2010

December 24th, 2009 stiiifff 4 comments

There will probably be thousands of posts like this one but anyway, here I go with my own … I wanna take a little time looking back at 2009 and then set my personal expectations for 2010.

Overall, 2009 was a great year :-)

  • I finally created my own company ! This gives me a certain degree of freedom in choosing the types of project I want to work on, the knowledge I want to acquire and even more opportunities to meet a lot of very talented people.
  • I learned a lot … especially on how to have a more business-centered focus on software development. Thinking about business value, weighting different solutions benefits vs costs, and also, listening & talking more to the business guys.
  • I read a lot, although I still haven’t finished all the books I started. Functional & concurrent programming, domain-specific languages, Scrum, Business/IT Alignment are in my continuous learning bag.
  • I followed a great course with Udi Dahan and it helped me gain some new perspectives on how to rethink about software design in general. Messaging, SOA & DDD are fascinating topics I want to further learn from.
  • Articles & presentations of Eric Evans on DDD and Udi on CQRS had a tremendous impact on my view of software building. We, software developers tend to focus too much on creating cool frameworks or libraries, and solving complex technical problems, while forgetting about our main goal : providing business value. Sometimes, solving a problem from a business point of view is far easier than at a technical level. Also, we tend to be maniac about every line of code we write … but as E. Evans is saying “Precision design are fragile” & “Not all of a system will be well designed“. Focus your efforts on writing good code in parts of the system that provide most of the business value. It is perfectly fine to write not so good code elsewhere (the duck-tape programmer has its role to play!), just make sure you make everything explicit.
  • Finally, with some friends, I created a new community about the .Net platform & the Agile methodologies, DotNetHub. It’s a very exciting project :-)

So, 2009 was so amazing that I’m eagerly awaiting 2010 !

  • I already booked a DDD immersion workshop with E. Evans in Paris, mid-February, and I’m sure it’s gonna be a great course. Maybe others will follow as I find myself learning a lot during those intensive courses.
  • DotNetHub will keep me busy, organizing great conferences with, well-known and well-known-to-be speakers.
  • I absolutely have to finish all the books I started before I buy any new one !
  • I will restart working on my app based on Northwind and demonstrating DDD coupled with NServiceBus. I have to admit, I got a bit side-tracked by DotNetHub and another major personal event (read further lol).
  • Probably learn some new technical stuff like C# 4.0, VS2010/TFS2010, Dublin & some more F# but honestly, that’s less important and most probably easier than the previous stuff (although F# is quite funky). Using your brain and training your critical sense to filter marketing / wrong piece of information / silver bullets is actually the hardest part of our job.

So, that’s about it folks ! This is the list of my expectations for 2010 … but that’s actually all secondary compared to the main challenge I will have to face : becoming a father end of May 2010 ! ;-) Indeed, my wife is pregnant of my first child. I’m really excited about it … now, on top of my to-do list : read the baby books or get killed :-) lol

Merry Christmas & Happy New Year to all !

Announcing DotNetHub !

December 14th, 2009 stiiifff No comments

I’ve been working with some friends on a project for a while now, and it is finally time to talk about it more publicly as it is eventually coming to life : DotNetHub !

DotNetHub is a new community about the Microsoft .Net Platform as well as the Agile Methodologies.

DotNetHub will be a bit particular for 2 reasons:

  • First, it will be dedicated mainly to french-speaking people, mostly living in Belgium, Luxembourg, France & Switzerland (but, if you are elsewhere, don’t hesitate to contribute !). Why only french-speaking people ? Simply because there are already tons of english-speaking communities, all very good, but my friends and I felt that there was a void to be filled, especially here in Belgium (French people have DotNetGuru & Tech Head Brothers !).
  • Secondly, as mentioned, we will not only focus on technological aspects but also on the methodological ones, something that we find missing in other communities, but that is nonetheless as important. Bringing those two aspects together in the events & conferences we are going to organize will be a big challenge, but it’s worth it !

We’re hoping to have many people joining us in order to create a very dynamic community. We are also actively looking for sponsors … so if you’re interested, please contact us.

I’m already very happy to announce that our first event will take place on the 20th of January with Jonathan “Peli” de Halleux from Microsoft Research, who will talk about “Stubs, Moles & Pex“. Go register on the website, the number of places is limited !

If you have any questions, suggestions, comments, … please visit us ! :-)

Update : A more detailed presentation in french by Pierre-Emmanuel can be found here.

Categories: Agile, Belgium, DotNetHub Tags: ,

Getting a better view from the roof of the Bus

November 3rd, 2009 stiiifff No comments

Last time, I had a first spike with NServiceBus in combination with Castle Windsor, NHibernate & FluentNHibernate, and highlighted the fact that it was quite easy to get those guys up and running together in a clean way, and from there, to process your first messages.

This time, I would like to take a step back, off the Bus, to lay down the foundations of a more concrete & complete example. To do so, I will use the well-known used & abused database sample from Microsoft : Northwind !

I can already hear you all “Northwind, WTF ?!” … except that this time, it’s gonna be different, trust me !

Let’s start by having a look at our veteran database diagram …

NorthwindDiagram

As we can see, Northwind is a traditional sales company, with an online business, which is:

  • Receiving Orders from Customers, classified in different Demographic segments, and shipping those orders via third-party Shippers.
  • Provisioning adequate Stock quantities of Products, arranged in Categories, by buying from several Suppliers, to deliver ordered quantities.
  • Managing Salesmen organized in Territories & Regions.

(yeah, I can get all that from a simple database diagram … impressive imagination huh ? ;-) )

In an SOA world, we wil tend to breakdown the different facets of the company into several independent but cooperating Services.

A naive but all too common way to split our problem domain would probably be as follows:

  • Employee service: manage employees, territories & regions.
  • Customer service: manage customer & demographic segments.
  • Order service: manages customer orders & shippers.
  • Supplier service: manages suppliers & stock.
  • Product service: manages products & categories.

Unfortunately, this simplistic way of defining service boundaries around groups of related concepts most often leads to services that are not autonomous (e.g. call each others, use same database), which violates one of the 4 tenets of SOA (“Services are autonomous“). Plus the fact that it just smells too much like a CRUD API.

A better starting point for modeling services is to analyze the Business Capabilities of the company, that is to say, the distinctive aspects of the company that are contributing to achieve its main goals. Another possibility can also be to model your Services around Bounded Contexts that you would have previously identified, if you are a DDD practitioner. I’m still not yet entirely sure which solution you should prefer and in which conditions … good topic for another discussion.

But in any case, your Services will be better aligned with the Business rather than just being technical CRUD-services.

Here is an attempt at defining the Business Capabilities (BC) and their respective goals in our beloved fictive Northwind company:

  • Marketing BC: maintains a catalog of products, define pricing & promotional operations to maximize sales.
  • Sales BC: accepts customer orders and improves customer relationship.
  • Inventory BC: optimizes the provisioning of product stocks via suppliers to support sales.
  • Shipping BC: optimizes delivery times & costs through shippers.
  • HR BC: manages salesmen to cover sales territories & markets.

They might change as the company’s goals evolve, some being dropped, new ones being added but let’s focus on these ones for now. One service will be defined for each business capability.

Each of those services will eventually use it’s own independent datastore to persist information and will expose its features by accepting incoming Messages and triggering outgoing Events on the Messaging infrastructure.

Those services will be composed to form one or more application(s) that will deliver great value to the company and increase its sales by multiple orders of magnitude !!!

To break with the past, I’ve decided to name this sample Southwind! It sounds warmer and way cooler than Northwind, doesn’t it? :-)  Indeed, it will feature a first personal attempt at building a sample bringing together an Event-Driven Architecture with domain models built following the Domain-Driven Design approach, on top of NServiceBus. Might be a bit ambitious, but it’s so interesting right ?

That’s it for now, till next time where I will focus on the messages & events being exchanged by the different services.

Meanwhile, go read this great article about Event Driven SOA with NServiceBus.

As always, remarks, comments, suggestions are welcome. And if you wanna help building this great sample, you’re more than welcome! ;-)

Business Capabilities

October 23rd, 2009 stiiifff No comments
Categories: Architecture, EDA, SOA Tags:

Stepping onto the Bus

October 12th, 2009 stiiifff No comments

I recently had the chance to follow the Advanced Distributed Systems Design with SOA course with Udi Dahan in Brussels, a rejuvenating experience for various reasons : I had no real-world SOA or Messaging Bus experience, it helped me clear out some misunderstandings I had about DDD and also, although painful at first, Udi finger pointed all the bad habits & misconceptions I had accumulated over the years (I can still hear him squeaking “Northwind ! Northwind !“).

So here I am, entering the realm of SOA, EDA & DDD that might well be heaven on earth for both business people & software-makers, the place we all heard of but never saw. But let’s start slowly, and discover my first endeavor with NServiceBus, shall we? :)

For a good introduction on NServiceBus, I suggest you to read the post from Jan who has been doing research on the same aforementioned topics as well.

This post will focus on how well NServiceBus, NHibernate, FluentNHibernate & Castle Framework play together and how to make them fly in a DDD context. Ok, ok, enough talking, show me the code man !!! :D

To manage my NHibernate sessions (ISession), I like to use the Castle’s NHibernate Integration facility, as it gives me a nice abstraction in the form of the ISessionManager component:

ISessionManager

Next to that, a little more than a month ago, the 1.0 version of FluentNHibernate was released, and it’s really neat for both NHibernate configuration & mappings. So, I like to use it as well:

Fluently.Configure(config)
  .Database(MsSqlConfiguration.MsSql2008
    .DefaultSchema("dbo")
    .ConnectionString(c => c
      .FromConnectionStringWithKey("Northwind"))
    .QuerySubstitutions("true 1, false 0")
    .DoNot.UseOuterJoin()
    .ShowSql())
  .Mappings(m => m
    .FluentMappings.AddFromAssemblyOf<CatalogMap>()
    .ExportTo(System.Environment.CurrentDirectory))
  .BuildConfiguration();

One very nice thing about NServiceBus (and its Generic Host) is that it acknowledges from the start that our softwares have to operate in different environments and for that, it offers a very clean solution : Profiles.

Wrapping it all up, wouldn’t it be nice if I could use Castle’s NHibernate Integration facility for useful components like ISessionManager (and others, more on that later), FluentNHibernate for configuration & mappings and take advantage of NServiceBus Profiles ? Hell yeah !!! Well, that’s actually quite easy & clean. :)

First, configure the NH facility in your config file:

<castle>
  <facilities>
    <facility id="nhibernate.facility" type="Castle.Facilities.NHibernateIntegration.NHibernateFacility, Castle.Facilities.NHibernateIntegration">
      <factory id="nhibernate.factory"/>
    </facility>
  </facilities>
</castle>

Notice that the configuration for the factory is empty … indeed, we want to configure it fluently in the code.

Create a Profile Handler class (implements a IHandleProfile role interface) which simply registers an object into the container (NSB is container-agnostic) :

public class IntegrationProfileHandler : IHandleProfile<Integration>
{
  public void ProfileActivated()
  {
    Configure.Instance.Configurer
      .RegisterSingleton<IConfigurationContributor>(
        new IntegrationNHibernateConfig());
  }
}

… and finally, an implementation of the IConfigurationContributor interface … which is part of Castle’s NHibernate Integration facility, and will be called before NH’s SessionFactory is built in order to, well, contribute to the configuration. :)

public class IntegrationNHibernateConfig : IConfigurationContributor
{
  public void Process(string name, Configuration config)
  {
    Fluently.Configure(config)
      .Database(MsSqlConfiguration.MsSql2008
        .DefaultSchema("dbo")
        .ConnectionString(c => c
          .FromConnectionStringWithKey("Northwind"))
        .QuerySubstitutions("true 1, false 0")
        .DoNot.UseOuterJoin()
        .ShowSql())
      .Mappings(m => m
        .FluentMappings.AddFromAssemblyOf<CatalogMap>()
        .ExportTo(System.Environment.CurrentDirectory))
      .BuildConfiguration();
  }
}

Ok, very nice … but I’m not done yet.

A nice concept that we want to use when querying in a true DDD fashion is the notion of Fetching Strategy (read more about it here & there). We need Fetching Strategies for a very simple reason:

Make sure that once we call into the Domain Model to perform a certain action, it has everything it needs to do its job, without causing lazy-loading to trigger and possibly N+1 select problems.

For that matter, I define a simple interface IFetchingStrategy (IEntityRole is just a marker interface):

public interface IFetchingStrategy<TEntityRole>
    where TEntityRole : IEntityRole
{
  string[] FetchList { get; }
}

… that I can then implement to define a fetching strategy per entity role:

public interface IRegisterProductInCatalog : IEntityRole
{
  void RegisterProduct(string category,
         string productName, string productDescription);
}

public class RegisterProductInCatalogStrategy : IFetchingStrategy<IRegisterProductInCatalog>
{
  public string[] FetchList
  {
    get { return new[] { "Categories.Products" }; }
  }
}

Now, it would be nice if I could get an easy access to those fetching strategies … well, that’s what you use an IoC container for ;) Here is the configuration of Castle’s Windsor container in NServiceBus endpoint’s configuration class:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
  public void Init()
  {
    var container = new WindsorContainer(new XmlInterpreter());

    Configure.With()
      .CastleWindsorBuilder(container)
      .XmlSerializer();

    container.Register(
      AllTypes
        .Of(typeof(IFetchingStrategy<>))
        .Pick(Configure.TypesToScan)
        .WithService.FirstInterface()
    );
  }
}

Fluent configuration for the Bus & the Container ! Woohoo, my head is turning ! :D

Now, for the final part, the MessageHandler that makes use of all those cuties & with the help some little extension methods:

public class ProductManager : IHandleMessages<RegisterProductInCatalogRequest>
{
  public virtual IBus Bus { get; set; }
  public virtual ISessionManager SessionManager { get; set; }
  public virtual IFetchingStrategy<IRegisterProductInCatalog> Strategy { get; set; }

  public virtual void Handle(RegisterProductInCatalogRequest message)
  {
    using (var session = SessionManager.OpenSession())
    {
      var catalog =
            session.For<Catalog>(message.CatalogId)
                   .Apply(Strategy)
                   .UniqueResult<IRegisterProductInCatalog>();

      catalog.RegisterProduct(message.CategoryName,
                              message.ProductName,
                              message.ProductDescription);
    }
  }
}

I don’t know you, but that’s the kind of code that makes me happy (like a hippo). :)

Comments, feedback, suggestions are all welcome ! ;)