Search the web
Sign In
New User? Sign Up
domaindrivendesign · Domain-Driven Design
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Improving application design with a rich domain model   Message List  
Reply | Forward Message #5851 of 15978 |
Re: [domaindrivendesign] Re: Improving application design with a rich domain model

Sean,

I'm glad that you liked the presentation.

The MoneyTransferService I describe in the presentation is a simplified but typical service in the applications I work on.

public class MoneyTransferServiceImpl implements MoneyTransferService {

    public MoneyTransferServiceImpl(AccountRepository accountRepository,
            BankingTransactionRepository bankingTransactionRepository) {...}
    }

    public BankingTransaction transfer(String fromAccountId,
            String toAccountId, double amount) throws MoneyTransferException {
        Account fromAccount = accountRepository.findAccount(fromAccountId);
        Account toAccount = accountRepository.findAccount (toAccountId);
        fromAccount.debit(amount);
        toAccount.credit(amount);
        TransferTransaction txn = new TransferTransaction(fromAccount,
                toAccount, amount, new Date());
        bankingTransactionRepository.addTransaction(txn);
        return txn;
    }

}

(and, yes, this could probably be shorted to return fromAccount.transferTo(toAccount, amount) , and money shouldn't be a double :-) )

The services are invoked by the web tier, e.g. Spring MVC controller. Each service method is a few lines of code that takes object ids + other data as parameters; calls some repositories to load some entities and then invokes some methods on those entities to do some work etc. You could probably characterize this as an application service rather than domain service but if your services are simple like this one then having a separate domain service isn't generally valuable. However, if the service was fatter and manipulated, for example, XML messages or DTOs, then moving the domain logic into a separate domain service might be a good idea.

Chris

--
Enterprise POJO consulting - http://www.chrisrichardson.net
Author, POJOs in Action - http://www.manning.com/crichardson
Enterprise POJOs blog - http://chris-richardson.blog-city.com
Speaking in 2007 at JavaOne, SpringOne, the Colorado Software Summit, the Spring Experience



On 8/31/07, dkode8880 <dkode8880@...> wrote:

Chris,

This is an excellent description covering many topics. There was a couple of things in
there I was not aware of.

Can you go more in depth on how services should be used in the domain? I was under the
impression that the Service Layer should be a combination of multiple Repositories to
accomplish some sort of group work. Is this accurate?

Thanks again for the excellent webcast!

Sean

--- In domaindrivendesign@yahoogroups.com, "Chris Richardson"


<chris.e.richardson@...> wrote:
>
> Hi,
>
> Back in June at the SpringOne conference I gave a talk on improving
> application design with a rich domain model. The video of the talk has
> now been published. You can find out more about the talk and links to
> the video and slides by going here
> http://www.chrisrichardson.net/springOne2007.html .
>
> It would be great to get your feedback.
>
> Chris
>
> --
> Author, POJOs in Action - http://www.manning.com/crichardson
> Enterprise POJO consulting - http://www.chrisrichardson.net
> Enterprise POJOs blog - http://chris-richardson.blog-city.com
> Speaking in 2007 at the Colorado Software Summit and the Spring Experience
>






Wed Sep 5, 2007 12:48 am

cer
Offline Offline
Send Email Send Email

Forward
Message #5851 of 15978 |
Expand Messages Author Sort by Date

Hi, Back in June at the SpringOne conference I gave a talk on improving application design with a rich domain model. The video of the talk has now been...
Chris Richardson
cer
Offline Send Email
Aug 27, 2007
1:44 pm

I seriously wish all conference presentations had the same online content that yours does... it's almost like attending the conference. ;) Thanks, James...
James Carr
jay_c_the_man
Offline Send Email
Aug 31, 2007
4:58 am

Chris, This is an excellent description covering many topics. There was a couple of things in there I was not aware of. Can you go more in depth on how...
dkode8880
Offline Send Email
Aug 31, 2007
12:57 pm

This post - http://tech.groups.yahoo.com/group/domaindrivendesign/message/4348 - may help you understand the distinction between Service Layer and domain...
randy stafford
randalparker...
Offline Send Email
Sep 1, 2007
2:21 am

Sean, I'm glad that you liked the presentation. The MoneyTransferService I describe in the presentation is a simplified but typical service in the applications...
Chris Richardson
cer
Offline Send Email
Sep 5, 2007
12:54 am

Chris, Thanks again, This is the thinking that I was having so I'm glad I have the right idea. I currently am using C# and I use Castle MonoRail for my MVC...
dkode8880
Offline Send Email
Sep 5, 2007
12:47 pm

Excellent presentation, Chris. My team and I have been practicing DDD for the past year or so, and have a significant and robust stack at this point. We use...
Brad Neighbors
snoopy6996us
Offline Send Email
Sep 2, 2007
12:54 am

... Hi Brad, The possibility of injecting a repository into an entity does enable some interesting designs indeed. Unfortunately the Hibernate's CGLib ...
Geert Pante
geertpante
Offline Send Email
Sep 4, 2007
6:29 am

... Hi Geert, Could you please elaborate on how exactly the interference happens? I'm interested in learning more details about this, because we've been using...
Jing Xue
manifoldronin
Offline Send Email
Sep 5, 2007
5:58 am

... Hi Jing, I remember struggling with this for a while. One of the first issues I had was that Hibernate calls a default constructor of persisted objects to...
Geert Pante
geertpante
Offline Send Email
Sep 5, 2007
8:34 am

... Hi, ... Ah, I see. Yeah, that's a well known "gotcha". I actually even blogged about it a while ago: ...
Jing Xue
manifoldronin
Offline Send Email
Sep 5, 2007
6:29 pm

Hi Brad, Glad you liked the presentation. Injecting dependencies into entities is definitely useful and avoids passing dependencies through many levels of...
Chris Richardson
cer
Offline Send Email
Sep 5, 2007
1:09 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help