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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:30:45+00:00 2026-05-19T23:30:45+00:00

re: S#arp Architecture A bit of a noob question about where to put certain

  • 0

re: S#arp Architecture

A bit of a noob question about where to put certain sorts of domain logic with S#arp. OK, so imagine this domain rule:

When asking for a specific chat room by name, return the room if it already exists, or else create a new one with that name and return it.

Is this Domain Logic? In which case, how do I implement it in my Entity object (as I seem to need access to the Repository to do it)

Is this Controller Logic? In which case I guess I stick it in the MVC controller, easy enough.

Is this Data Access Logic? In which case I build it into the Repository object and the Contoller calls it. Again, easy enough.

I reckon this is Domain Logic, but then I’m not sure how to built it into my Entity. As Entities dont seem to access to Repositories (or am I missing something?).

  • 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-19T23:30:45+00:00Added an answer on May 19, 2026 at 11:30 pm

    From the way you’ve described it, I’d say this would best go in the Application Services layer. (the Tasks layer in the WhoCanHelpMe? example project). For me this is application logic rather than domain logic.

    For the other options:

    • Sharp is designed intentionally so that Entities don’t access the Repositories. (You’ll find quite a lot of articles around on why Entities should be persistence-ignorant.)
    • In general the controllers aren’t really meant to contain any business logic directly – for readability, testability, etc. (Personally I’m comfortable putting logic in there initially and then refactoring it out.)

    One reason I’d be uncomfortable putting the logic directly in a repository is clarity. If you have methods on IChatRoomRepository:

    ChatRoom GetRoomByName (string name);
    ChatRoom GetRoomById (int id);
    

    typically GetRoomById would return null if there is no room for the given id, so it’s not too obvious that the first method will silently create (and presumably persist?) a room if you don’t already have one.

    More conceptually, from DDD Quickly (p56):

    We should not mix a Repository with a Factory. The Factory should create new
    objects, while the Repository should find already created objects. When a
    new object is to be added to the Repository, it should be created first
    using the Factory, and then it should be given to the Repository

    which would suggest that if you’re trying to implement the repository pattern, the creation of a new chat room should happen outside the repository.

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

Sidebar

Related Questions

I am getting this error whenever my S#arp Architecture attempts to start and this
I've been working with S#arp Architecture but this can probably be applied to any
I have been playing about with FluentNhibernate as part of the S#arp Architecture. Below
I'm revisiting and re-implementing the code that caused me to ask this question about
Can someone share their experiences with s#arp architecture. we have decided to follow mvp
What’s the equivalent of S#arp architecture (.net) in the java world. A one stop
I have started using the s#arp architecture which uses FNhibernate and GeneratedBy.HiLo to generate
I know S#arp architecture is built for ASP.NET MVC. But I'm wondering if it
I'm using the S#arp Architecture . I can't remember where I read it, but
Is there any architecture or framework for Desktop applications similar to S#arp architecture for

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.