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

  • SEARCH
  • Home
  • 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 8277789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:47:40+00:00 2026-06-08T08:47:40+00:00

When implementing DDD in an application which contains a lot of CRUD functionality, coupled

  • 0

When implementing DDD in an application which contains a lot of CRUD functionality, coupled with a web-API of some sort, you end up in a situation where something which could be made relatively simple with the tooling provided by the platform becomes more difficult. For example:

Say we have a User object, and you’re trying hard to not create an anemic domain model, so you have more expressive operations modeled:

class User {
    public void terminateAccount(TeminationReason reason);
    public void reactivateAccount();
}

The above class is nice, because it lets us mark the account as terminated and set the reason at once. Clearly an improvement over setEnabled(false), and setTerminationReason(..).

The rub is, lets say we have something like a JAX-RS web service which can GET/PUT over that user. The framework (JAX-RS, JAXB) will easily serialize and deserialize our DTO objects for us. Now, where we could’ve previously done:

entity.setEnabled(dto.isEnabled);
entity.setTerminationReason(dto.getTerminationReason);

we have to instead:

if (entity.isEnabled() && !dto.isEnabled()) {
    entity.terminateAccount(dto.getTerminationReason);
} else if (!entity.isEnabled && dto.isEnabled) {
    entity.reactivateAccount();
}

The big disconnect here being the business oriented interface of the domain object, and the CRUD-style access pattern over a RESTful API. Since both DDD and REST are best practices in their own rights, what lessons has everyone here learned to make the code above less painful/repetitive/etc?

PS – We’re using DTOs because when using an ORM framework behind the scenes, actually serializing the Entities to XML/JSON is problem since we can’t limit the lazy loading. There are also different attributes you typically want to expose over the RESTful API (reference URLs, etc) which don’t belong in the domain model. I’m open to suggestions here too.

  • 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-06-08T08:47:42+00:00Added an answer on June 8, 2026 at 8:47 am

    I think the issue here is that you’re trying to use a single DTO to represent the User entity across all APIs. Instead, if you have a separate DTO for each operation, containing only the required data, your code would be much simpler.

    For example, the TerminateAccount API would have a DTO with only the termination reason, and your code would simply be:

    user.terminateAccount(dto.terminationReason);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

implementing publishActivity in PHP using the REST API using this code: $activity = array(
Before implementing j_security_check using MySQL realm authentication in my web app. I had the
When implementing the Strategy Pattern, where does one put the code that determines which
Implementing the very first scala example I ran into some problems probably tipical for
When implementing HTTP services in node.js, there is a lot of sample code like
When implementing a Matrix construct using arrays, which would be more efficient? Using a
I'm new to DDD. I have an existing ASP.NET application (not MVC) and I
Whilst implementing my first MVVM application in WPF, I've been wondering about the pros
Implementing a web service that uses Transport-level security with WCF over HTTP is pretty
Is implementing a code generator a sort of model driven design/ model driven software

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.