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 3454830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:32:23+00:00 2026-05-18T09:32:23+00:00

I’m still learning about DDD and I have these two (probably simple) questions: If

  • 0

I’m still learning about DDD and I have these two (probably simple) questions:

If a Factory creates new object/graph/aggregate instances, but also “reconstitutes” objects/graphs from the Repository, then:

(1) Does your service layer functions/jobs/tasks/unit-of-work call into the Factory or a behavioural method on the Entity instance or a DomainService function? I’m lost as to the call stack based on the responsibility of these components.

(2) Do Entity instances even have “behavioural methods” like above? For example does a Post have p.UpdatePost(string bodyText) or is that not a concern of the domain model and so the same should be achieved with the Repository? Or the service layer function, should it be calling the Repository in this case and the entity instance simply have behavioural methods that are specific to the domain and not persistence? But then, why does it sound like “updating a post” is a domain function when that’s the user’s goal?

You can see I’m all over the place. Please help.

  • 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. Editorial Team
    Editorial Team
    2026-05-18T09:32:24+00:00Added an answer on May 18, 2026 at 9:32 am

    (1) Does your service layer functions/jobs/tasks/unit-of-work call into the Factory or a behavioral method on the Entity instance or a DomainService function? I’m lost as to the call stack based on the responsibility of these components.

    Usually – top level retrieves necessary aggregate root and calls a function on it. Sometimes top level retrieves multiple aggregate roots and pass them to domain service, but not often because domain service is a quite strong sign that there is unrecognized aggregate root. At the end – top level ensures aggregate root is persisted.

    (2) Do Entity instances even have “behavioural methods” like above? For example does a Post have p.UpdatePost(string bodyText) or is that not a concern of the domain model and so the same should be achieved with the Repository? Or the service layer function, should it be calling the Repository in this case and the entity instance simply have behavioural methods that are specific to the domain and not persistence? But then, why does it sound like “updating a post” is a domain function when that’s the user’s goal?

    Yes, they do. Domain model should be aware of it’s state changes. And that’s much more beneficial as it seems at first. Great thing about this is that You gain extensibility point. If client will walk week later to You and say that he wants system to check additional things when user updates post – instead of searching every line of post.bodyText="new value", You will be able to go straight to post.UpdatePost method and attach necessary things there.

    On the other hand – CRUD is not mutually exclusive with domain driven design. E.g. – in my application, management of users and their roles is uninteresting enough that I’m not even trying to model it granularly. You need to recognize parts what matters in business Your application is describing and working with.

    Keep in mind that domain driven design makes sense for complex applications only. Simple blog application doesn’t need it.

    (3) Am I wrong in assuming that a service layer (not Domain Services) should encapsulate how an interface interacts with the Domain Layer?

    As I see it – application services are more for orchestrating infrastructure. If there is no infrastructure involved – then application service loses value:

    Application services basically are just facades. And every facade is bad if complexity it adds overweights problems it solves.


    Inside domain:

    //aggregate root is persistence ignorant. 
    //it shouldn't reference repository directly
    public class Customer{
      public string Name {get; private set;}
      public static Customer Register(string name){
        return new Customer(name);
      }
      protected Customer(string name){
        //here it's aware of state changes.
        //aggregate root changes it's own state
        //instead of having state changed from outside
        //through public properties
        this.Name=name;
      }
    }
    
    //domain model contains abstraction of persistence
    public interface ICustomerRepository{
      void Save(Customer customer);
    }
    

    Outside of domain:

    public class CustomerRepository:ICustomerRepository{
      //here we actually save state of customer into database/cloud/xml/whatever
      public void Save(Customer customer){
        //note that we do not change state of customer, we just persist it here
        _voodoo.StoreItSomehow(customer);
      }
    }
    
    //asp.net mvc controller
    public class CustomerController{
      public CustomerController(ICustomerRepository repository){
        if (repository==null)throw new ArgumentNullException();
        _repository=repository;
      }
      public ActionResult Register(string name){
        var customer=Customer.Register(name);
        _repository.Save(customer);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.