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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:43:11+00:00 2026-05-13T16:43:11+00:00

Boring intro: I know – DDD isn’t about technology. As i see it –

  • 0

Boring intro:

I know – DDD isn’t about technology. As i see it – DDD is all about creating ubiquitous language with product owner and reflecting it into code in such a simple and structured manner, that it just can’t be misinterpreted or lost.

But here comes a paradox into play – in order to get rid of technical side of application in domain model, it gets kind a technical – at least from design perspective.

Last time i tried to follow DDD – it ended up with whole logic outside of domain objects into ‘magic’ services all around and anemic domain model.

I’ve learnt some new ninja tricks and wondering if I could handle Goliath this time.


Problem:

class store : aggregateRoot { 
  products;
  addProduct(product){
    if (new FreshSpecification.IsSatisfiedBy(product))
      products.add(product);
  }
}

class product : entity {
  productType;
  date producedOn;
}

class productTypeValidityTerm : aggregateRoot {
  productType;
  days;
}

FreshSpecification is supposed to specify if product does not smell. In order to do that – it should check type of product, find by it days how long product is fresh and compare it with producedOn. Kind a simple.

But here comes problem – productTypeValidityTerm and productType are supposed to be managed by client. He should be able to freely add/modify those. Because I can’t traverse from product to productTypeValidityTerm directly, i need to somehow query them by productType.

Previously – i would create something like ProductService that receives necessary repositories through constructor, queries terms, performs some additional voodoo and returns boolean (taking relevant logic further away from object itself and scattering it who knows where).

I thought that it might be acceptable to do something like this:

addProduct(product, productTypeValidityTermRepository){...}

But then again – i couldn’t compose specification from multiple specifications underneath freely what’s one of their main advantages.

So – the question is, where to do that? How store can be aware of terms?

  • 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-13T16:43:11+00:00Added an answer on May 13, 2026 at 4:43 pm

    With the risk of oversimplifying things: why not make the fact whether a Product is fresh something a product “knows”? A Store (or any other kind of related object) should not have to know how to determine whether a product is still fresh; in other words, the fact that something like freshSpecification or productTypeValidityTerm even exist should not be known to Store, it should simply check Product.IsFresh (or possibly some other name that aligns better with the real world, like ShouldbeSoldBy, ExpiresAfter, etc.). The product could then be aware how to actually retrieve the protductTypeValidityTerm by injecting the repository dependency.

    It sounds to me like you are externalizing behavior which should be intrinsic to your domain aggregates/entities, eventually leading (again) to an anemic domain model.

    Of course, in a more complicated scenario, where freshness depends on context (e.g., what’s acceptable in a budget store is not deemed worthy for sale at a premium outlet) you’d need to externalize the entire behavior, both from product and from store, and create a different type altogether to model this particular behavior.

    Added after comment

    Something along these lines for the simple scenario I mentioned: make the FreshSpec part of the Product aggregate, which allows the ProductRepository (constructor-injected here) to (lazy) load it when needed.

    public class Product {
      public ProductType ProductType { get; set; }
      public DateTime ProducedOn { get; set; }
      private FreshSpecification FreshSpecification { get; set; }
      public Product(IProductRepository productRepository) { }
    
      public bool IsFresh() {
        return FreshSpecification
          .IsSatisfiedBy(ProductType, ProducedOn);
      }
    }
    

    The store doesn’t know about these internals: all it cares about is whether or not the product is fresh:

    public class Store {
      private List<Product> Products = new List<Product>();
      public void AddProduct(Product product) {
        if (product.IsFresh()) {
          Products.Add(product);
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Beyond the regular boring difference between Cast and As if i know that apple
I know that transactions could be used to bring about atomicity. Like if methodOne()
Think about a speedometer, and imagine all these little strokes around it like 10
I don't know what the proper name for this sort of programming, but all
Boring of googling this question - how to set indentation offset for python in
The Situation (Ignore this it is boring): I have reports that I created using
I want to implement a simple script to do some boring housekeeping on my
Im a novice, apologies up front if this is unclear! I know what I
I know that there are a few questions like this on SOF, but I
I see some websites use fancy icons. An example is this curly leaf icon

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.