Saturday, June 4, 2011

This is no Domain Service

After reading this blog entry about why and how to use the command processor pattern in your service layer. While the blog post is worth reading a code example provided by Ian made me think.

public class MyFatDomainService
{
    public void CreateMyThing(CreateMyThingCommand createMyThingCommand)
    {
        /*Stuff*/
    }

    public void UpdateMyThingForFoo(FooCommand fooHappened)
    {
       /*Other Stuff*/
    }

     public void UpdateMyThingForBar(BarCommand barHappened)
     {
        /*Other Stuff*/
     }

     /*Loads more of these*/
}

The service signature looks more than a repository, we have these CRUD methods with the "create" and "update" prefix.

Is this a domain service? I don't think so...

My suggestions is to step back and ask yourself whether you need all this "best practice"/layered architecture/DDD stuff when providing API methods like create, update and delete? Are you building the next excel like business tool creating and updating cells and rows while doing a couple of validations on the input object?

And in case you really identify a domain service give the methods some semantic names :)

3 comments:

  1. Domain services are Windows Communication Foundation (WCF) services that encapsulate the business logic of a WCF RIA Services application. A domain service exposes a set of related operations in the form of a service layer. When you define a domain service, you specify the data operations that are permitted through the domain service.

    ReplyDelete
  2. Register web Domain is a good and very cheap web hosting company in India. They provide affordable and reliable hosting services in India.indian web hosting companies

    ReplyDelete
  3. Thanks for such a nice and updated information.Very long time i am searching this type of the information keep sharing more post,keep up your good work..Web hosting forum

    ReplyDelete