Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 109933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:08:51+00:00 2026-05-11T02:08:51+00:00

In this question someone replies You never let the domain object implementations call services

  • 0

In this question someone replies ‘You never let the domain object implementations call services by themselves!’. Is this statement a hard fast rule of DDD or does it depend on your own application and architecture?

Contrived example:

As an example lets suppose we have a UserImage object in our model that gets populated from an uploaded image by a user. And then lets suppose that we can submit this image to a 3rd party service that can identify thumb prints and return a Guid if a match is found.

public IThumbPrintService {     Guid FindMatch(Bitmap image); }  public class UserImage {     public Bitmap Image {get; set;}      public Guid ThumbPrintId {get; set;}     public bool FindThumbPrintMatch() {        // Would you call the service from here?        ThumbPrintId = _thumbPrintService.FindMatch(this.Image);        return ! ThumbPrintId.CompareTo(Guid.Empty);     } }  public class RoboCopUserImageService : IUserImageService {      // Or move the call to a service method       // since it depends on calling a separate service interface      public bool FindThumbPrintMatch(UserImage userImage) {         userImage.ThumbPrintId = _thumbPrintService.FindMatch(userImage.Image);         return !userImage.ThumbPrintId.CompareTo(Guid.Empty);                  } } 

What is avoided or gained by not letting domain objects call services themselves?

EDIT: Are there any good online articles that discuss this specific topic?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:08:52+00:00Added an answer on May 11, 2026 at 2:08 am

    This is the Spreadsheet Conundrum: does the phone dial the phone number, or does the phone number dial itself on the phone?

    You might find Double Dispatch to be interesting reading, though overkill in your situation, I reckon.

    The Single Responsibility Principle is often at odds with the OO tenet of Tell, Don’t Ask. My feeling on the subject has oscillated, and I have settled on the following conditions when logic should go into a domain object:

    • The logic should be domain logic, i.e. nothing like image.load() or image.save()
    • The logic shouldn’t give the object more than ‘one reason’ to change in the domain. This is a re-statement of the SRP.
    • The logic shouldn’t be forced into the object. In other words, if you end up doing something like trying to calculate the sum of some property in a list of domain objects without using a getter, think twice.

    In your situation, I’d opt against putting the call to the service inside the entity object, mainly because the service doesn’t seem like it is related to your domain, but more related to persistence. Domain objects should be coupled to domain concepts, and I don’t think the service you gave qualifies.

    An example where I think calling a service in an entity might be acceptable would be if your application used a third-party workflow server to manage parts of its state. Essentially, this is the State Pattern with the states defined at run-time.

    I think it is acceptable to have domainObject.moveToNextState() (assuming this code ‘makes sense’ in your ubiquitous language) call the service that talks to your server because the workflow server manages a part of the domain model.

    I’ll add that DDD is very interested with following the language of the domain. Do you hear domain experts saying ‘A user image finds if its thumb print matches those in the XYZ vendor service’? Or do they say ‘The XYZ vendor service, given a thumb print, indicates whether that thumb print exists’? Go with the one that makes the most sense in your domain.

    Some more thoughts (I’ve thought about this issue a lot because it is central to design):

    • In the Evans DDD book, an Account entity has methods like credit(Amount), debit(Amount), transferTo(Account, Amount) and accrue(), but a FundsTransferService has a transfer(Account, Account, Amount) method. The transferTo method doesn’t call any service, but merely handles the logic that involves Accounts, like crediting and debiting the right amounts.

      The FundsTransferService, in addition to co-ordination, has its own rules to check, rules that don’t fit into Accounts. The exact amount to credit or debit might involve outside parties. This makes it awkward for transferTo to call the service.

    • For simple objects, like the UserImage, significant domain logic that can fit in the object itself might be scarce because it isn’t, as far as I can tell, an Aggregate. Aggregates, I think, present more of an opportunity to house domain logic. The Account example is likely an Aggregate.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 88k
  • Answers 88k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Got wonderful answers at comp.compiler May 11, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer If you have written it in javascript, well...that always executes… May 11, 2026 at 5:47 pm
  • Editorial Team
    Editorial Team added an answer I doubt that it even needs to escape strings -… May 11, 2026 at 5:47 pm

Related Questions

I'm hoping someone has seen this before because I can't for the life of
The "goto" statement comes straight out of ASM or any other assembler language. Here's
I asked this question before, Here however I think I presented the problem poorly,
I am designing the application in Flex that connects to some web services to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.