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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:05:16+00:00 2026-05-13T00:05:16+00:00

Just wanted to get the groups thoughts on how to handle configuration details of

  • 0

Just wanted to get the groups thoughts on how to handle configuration details of entities.

What I’m thinking of specifically is high level settings which might be admin-changed. the sort of thing that you might store in the app or web.config ultimately, but from teh DDD perspective should be set somewhere in the objects explicitly.

For sake of argument, let’s take as an example a web-based CMS or blog app.

A given blog Entry entity has any number of instance settings like Author, Content, etc.

But you also might want to set (for example) default Description or Keywords that all entries in the site should start with if they’re not changed by the author. Sure, you could just make those constants in the class, but then the site owner couldn’t change the defaults.

So my thoughts are as follows:

1) use class-level (static) properties to represent those settings, and then set them when the app starts up, either setting them from the DB or from the web.config.

or

2) use a separate entity for holding the settings, possibly a dictionary, either use it directly or have it be a member of the Entry class

What strikes you all as the most easy / flexible? My concerns abou the first one is that it doesn’t strike me as very pluggable (if I end up wanting to add more features) as changing an entity’s class methods would make me change the app itself as well (which feels like an OCP violation). The second one feels like it’s more heavy, though, especially if I then have to cast or parse values out of a dictionary.

  • 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-13T00:05:16+00:00Added an answer on May 13, 2026 at 12:05 am

    I would say that that whether a value is configurable or not is irrelevant from the Domain Model’s perspective – what matters is that is is externally defined.

    Let’s say that you have a class that must have a Name. If the Name is always required, it must be encapsulated as an invariant irrespective of the source of the value. Here’s a C# example:

    public class MyClass
    {
        private string name;
    
        public MyClass(string name)
        {
            if(name == null)
            {
                throw new ArgumentNullException("name");
            }
    
            this.name = name;
        }
    
        public string Name
        {
            get { return this.name; }
            set
            {
                if(value == null)
                {
                    throw new ArgumentNullException("name");
                }
                this.name = value;
            }
        }
    }
    

    A class like this effectively protects the invariant: Name must not be null. Domain Models must encapsulate invariants like this without any regard to which consumer will be using them – otherwise, they would not meet the goal of Supple Design.

    But you asked about default values. If you have a good default value for Name, then how do you communicate that default value to MyClass.

    This is where Factories come in handy. You simply separate the construction of your objects from their implementation. This is often a good idea in any case. Whether you choose an Abstract Factory or Builder implementation is less important, but Abstract Factory is a good default choice.

    In the case of MyClass, we could define the IMyClassFactory interface:

    public interface IMyClassFactory
    {
        MyClass Create();
    }
    

    Now you can define an implementation that pulls the name from a config file:

    public ConfigurationBasedMyClassFactory : IMyClassFactory
    {
        public MyClass Create()
        {
            var name = ConfigurationManager.AppSettings["MyName"];
            return new MyClass(name);
        }
    }
    

    Make sure that code that needs instances of MyClass use IMyClassFactory to create it instead of new’ing it up manually.

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

Sidebar

Related Questions

I just wanted to get the general consensus on which is a better mode
Just wanted to check if there is any configuration or parameter to get statistics
I'm new to objective C and I just wanted to get a general clarification
Just wanted to know if overriding UITabBarController would get my app rejected? Is it
I just wanted to know how to get the logged in apple id in
Im adding facebook one-login to my website. Just wanted to get some feedback from
Just wanted an opinion, or at least a rule of thumb over which is
Iam trying to implement memcache in my web application and just wanted to get
Just wanted to get feedback on how I am planning to architect my API.
In my application i just wanted to get number of sales in a day

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.