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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:25:14+00:00 2026-05-23T00:25:14+00:00

I’m doing my best to learn DDD, but I’m unsure about some really basic

  • 0

I’m doing my best to learn DDD, but I’m unsure about some really basic concepts; Where are your domain objects and services located, and how is the overall layout organized? I have a habit, good or bad I don’t know, that’s why I ask; to make a “Program” class, which holds domain collections, domain objects and service objects. Like example below.

Is this a good or bad approach? And if bad, what are alternatives? I’m so far just working with winforms projects, so that’s my main concern at this time.

Also if you could include some evaluation of my use of “static” objects here? I’m often unsure if to use static, and tend to just throw it on if I know it’s a singleton object (if that’s the correct term).

EDIT:
To explain a bit more, I’m using the New method of the “Program” class to coordinate the different domain objects, and run initial loading from database etc, on program startup. So if you suggest me to get rid of this class, then should I introduce some other services instead to deal with program startup?

Example:

class Form1
{
    private MainClass main;
}

class MainClass
{
    public static UserService UserServ;
    public static UserAccountService UserAccServ;
    public static List<UserAccount> UserAccounts; 
}

class UserService
{
}

class UserAccountService
{
}

class UserAccount
{
    public UserData User;
}

class UserData
{
}

EDIT:
Response to David:

Thanks! To address your points:

1) My example was just a rough type, I do use separate files for each class, and my project is in fact already 10,000 lines of code, although it may not sound like it.

2) Understood tips on interfaces.

3) Understood about assembleys.

4) I’m using Repositories (and FluentNHibernate), I plan to have services depend on them yes. At the moment I have xxxManager classes, which I know is bad, and will work to change them to xxxServices.

5) I understand DI is very popular, and it’s good you make this point, so I know this is a key resolve for my question. I will be learning that. So as far as I understand, you suggest me to inject the services directly to the form class? But what about domain objects? Where do they “live”? Should they all live in some type of service? If that’s the case, what type of services do you create to deal with program-startup logic? I understand the basic concepts of services for persisting data, using repositories etc, but there are probably other type of common service classes that I’m not aware of, related to my question?

PS: I should not have (mistake) named my class “Program”, as this is already a class in C# projects. I use both C# and VB, so actually in C# I usually call it MainClass. So I edited this.

  • 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-23T00:25:15+00:00Added an answer on May 23, 2026 at 12:25 am

    What you are describing is how to organise your dependencies (in this case, your forms project depends on the services).

    A few points about the above code:

    • It looks like you have all of your classes in the same file. Generally you should place every new class in its own file.
    • Your service classes should both implement an interface (IUserService and IUserAccountService) – this enables you to mock your dependencies for unit tests, to swap implementations and to better decouple your application.
    • Your service classes should ideally be in a different assembly (new visual studio project), as should your domain entities (UserAccount and UserData).
    • You might consider creating one or more repositories to deal with simply getting the data to your application services (application services would have a dependency on the repository, the repository would not depend on the service).
    • You have your services in static fields (not a singleton, that is a pattern which uses static fields in C# to ensure that exactly one object will be created for the lifespan of the application). It would be better for you to use DI (see below) instead of your forms using Program.UserService…etc.

    Once that’s done then you’re in a position where you can look at using dependency injection (DI) to provide your services to your application (as opposed to your application being responsible for creating them itself). Ninject would be a good choice to use. Here’s an example of how to implement it but you might have more luck on the Ninject wiki.

    • 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.