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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:23:53+00:00 2026-05-23T16:23:53+00:00

Again – i’m confused about DDD things :) I have architeture (I’m still working

  • 0

Again – i’m confused about DDD things 🙂

I have architeture (I’m still working on it) that in short hand looks like that:

DataLayer:
 EntityDao -> Implementing domain layer interfaces (NHibernate)
DomainLayer:
 EntityRepository -> Repository for each entity with injected Dao
 DomainObjects/Entitys -> Some logic
UI
 ASP.Net MVC

And I’m right now in that point where I feel to create and use some Service class. I have some questions with that:

1.Should I create at least one service for each entity/domain object ?

2.a.Should services have “query” method like Find, FIndAll, FindAll(LINQQuery)?

2.b.Should I stop to use Repositorys in upper layers (UI) to get sets (“Find”-like methods) of entity’s and start to use only services?

3.If answer on 2 question is No – Should I use Services and Repository in parallel fashion (When in UI I just need to get all entity’s I use Repository.FindAll, when I need to get some “logical” list of that entity’s i use Service.FindXXX method)?

4.Somehow I feel that Repositorys don’t fit in Domain layer – should I separate them somehow and in DOMAIN leave only domain specific objects like Entity’s and Services ? If Yes – give me some structure example how to achieve that.

Examples of some objects:

Dao:

public class NHibernateDao<T> : IDao<T>
{
    public NHibernateDao() { }

    public T Get(object id)
    {
        T entity = (T)NHibernateSession.Get(entityType, id);
        return entity;
    }
    public T Load(object id)
    {
        T entity = (T)NHibernateSession.Load(entityType, id);
        return entity;
    }
    public virtual T Update(T entity)
    {
        NHibernateSession.Update(entity);
        return entity;
    }
    ...

Repository:

public class BaseRepository<T>:IRepository<T>
{
    private DataInterfaces.IDao<T> mDao;

    public virtual T Get(object id)
    {
        return mDao.Get(id);
    }
    public virtual void Delete(T entity)
    {
        mDao.Delete(entity);
    }
    public virtual T Update(T entity)
    {
        return mDao.Update(entity);
    }
    public virtual IQueryable<T> FindAll()
    {
        return mDao.FindAll();
    }
    ...

Domain objects, at the moment , it’s mainly get/set container – background of this question is to remove that anemic model.

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

    1. One service per entity?

    No. You do not need to create one service for one entity.
    In DDD you would create services for operations that do not naturally map to a single entity (or value object). A good service (from Evans) :

    • The operation relates to a domain concept that is not a natural part of an entity or value object.
    • The interface is defined in terms of elements of the domain.
    • The operation is stateless

    So a service can consume many entities and there might be many entities that aren’t consumed by a single service at all.

    2a. Should services have “query” methods (..)?

    No. Generally speaking those are repository methods and are not placed on services. However, there can be operations on a service that return a collection of entities.

    2b.Should I stop to use Repositories in upper layers (UI) to get sets (“Find”-like methods) of entity’s and start to use only services?

    That might be a good idea. Often, when an application uses many repositories in the UI layer, the UI performs domain operations on multiple entities. These operations should typically be implemented in the domain layer; either in the entities themselves, or in services.

    3. Should I use Services and Repositories in parallel from the UI?

    Better not, see above; although there might be situations where you can quickly create part of your UI by doing so.

    4. Somehow I feel that Repositoriess don’t fit in Domain layer …

    You’re right, you should only put repository interfaces in the domain. See Kostassoid’s answer for an example.

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

Sidebar

Related Questions

Me again... I have an XML File that contains different categories which I would
Once again a question about the garbage collector in actionscript-3: If I have a
Once again a question about extjs. I use EXT 4.0.2 and have a couple
Again a simple thing. I have a stylesheet that parses XML and XSL files.
Again I have a question about an ssh issue: On a embedded system (no
Once again I have a question about Eclipselink/MOXy with external metadata mapping file. I
again I have a question that is not so easily googlable. Let's assume BIOS
Again I would like to get your opinion about a design issue. I have
again. I have a menu that I'm building. Everything works fine, except for the
again. I have a script that is using the jQuery UI plugin to generate

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.