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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:22:52+00:00 2026-05-23T06:22:52+00:00

I’m trying to use domain driven design while creating a website that is publicly

  • 0

I’m trying to use domain driven design while creating a website that is publicly accessible. One problem I’m having is trying to figure out what the aggregate roots should be for my model. I have a pretty good idea of what objects are entity objects and what objects are value objects.

My site, like most public sites, does not allow every user to see every piece of information stored in the site. Instead, they can only see the information they own. In the case of my site users will create “Projects” which they can also share with other users. Yet users can still only see information in projects they created or were invited to join. All the other objects in my model exists within a project and if a project is delete all the objects it contains should also be deleted.

So does this mean that I should have one main “Project” aggregate root type, and one “ProjectRepository” repository? It just seems inefficient to me to load an entire project each time any page on my site is requested. In reality this is not so much of an issue because I’m using NHibernate which will lazy load only the items in the project that are requested. Yet it seems like bad design to have the efficiency of the site depend so heavily on using an ORM with lazy loading.


Here’s an update that will hopefully make my question more clear.

First I’m trying to understand if my Project type should be an aggregate root of my model. A Project can exist by itself, whereas the Reports must exist within a Project. If a Project is deleted the corresponding Reports should be deleted. Does this mean Project could be or should be an aggregate root? This I’m not very clear on.

If Project is an aggregate root then Report should not be correct? As I understand it roots should not be nested in DDD. In addition, only aggregate roots are allowed to be retrieved from repositories. So if Report is not aggregate root then I should not have a ReportsRepository, and instead should only be accessing a Report through a Project retrieved from a ProjectsRepository. So even if a page only requires data from a single report it would need to load the entire Project from the ProjectRepository to get at the report.

In addition, if Project is an aggregate root which contains Reports then removing a Project from a ProjectRepository could also be setup to remove the Reports it contains. Yet if both Project and Report are aggregate roots then wouldn’t allowing the ProjectRepository to remove Reports when an Project is removed break the boundaries between aggregates? Aren’t aggregate roots and their corresponding repositories suppose to act independent from one another?

  • 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-23T06:22:53+00:00Added an answer on May 23, 2026 at 6:22 am

    I think you are confusing concerns. Security (who can view what) is not a domain concern. Don’t let it pollute your domain. If a user cannot view a report within a project, enforce that at someplace other than the domain model.

    In addition, I think you might benefit from decoupling your ViewModel (which is used for reading) from your domain model (which is mostly used for writing). They both share a data model (because they’re reading from the same DB schema), but they really have different purposes.

    In practice (in .NET), decoupling your ViewModel would have most or all of the following characteristics:

    • Your ASP.NET MVC views are bound to a single class which represents all the data on the screen. For example, not just the currently selected value in a <select> element, but a property representing all the possible <option> values in the <select> element.

    These are in the MyProject.ViewModel namespace:

    public class ProjectLead // Note that this class is specifically designed for display.  This is not the domain object.
    {
        public Guid Id;
        public string Name;
    }
    
    public class ProjectViewModel
    {
        public Guid ProjectLeadId;
        public IEnumerable<ProjectLead> ProjectLeads;
    }
    

    Your Edit() controller action would call something like:

    new ProjectViewModelRepository.Load(id);
    

    ProjectViewModelRepository will map your data model (nHibernate classes or ADO.NET data rows or whatever) to the ProjectViewModel instance.

    Then, the controller action called by submitting the form in the UI looks like this:

        public ActionResult Edit(ProjectViewModel viewModel)
        {
            var repo = new ProjectRepository();
            var project = repo.Load(viewModel.Id);
            // Map the properties of the viewmodel to properties/methods of the Project domain class
            repo.Save(project);
        }
    

    The big idea here is the Single Responsibility Principle. ProjectViewModel represents how a project is displayed on the screen. The Project domain class represents the business logic and whatnot associated with a project, independent of how that data is displayed on the screen.

    Separating these things really solved a lot of problems due to the fact that I was using my domain classes for multiple purposes: persistence, domain logic, and display. But… if this all sounds like complete overkill I’d verify whether your domain is complicated enough to really warrant DDD.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6

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.