Note that there are some explanatory texts on larger screens.

plurals
  1. PODomain Objects and Services
    primarykey
    data
    text
    <p>In <a href="https://stackoverflow.com/questions/428859/what-goes-in-your-domain-model-objects-and-what-goes-in-your-services">this</a> question someone <a href="https://stackoverflow.com/questions/428859/what-goes-in-your-domain-model-objects-and-what-goes-in-your-services#428902">replies</a> "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?</p> <p><strong>Contrived example:</strong></p> <p>As an example lets suppose we have a <code>UserImage</code> 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 <code>Guid</code> if a match is found.</p> <pre><code>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); } } </code></pre> <p>What is avoided or gained by not letting domain objects call services themselves?</p> <p><strong>EDIT:</strong> Are there any good online articles that discuss this specific topic?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload