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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:36:49+00:00 2026-06-17T09:36:49+00:00

After a week of learning about Domain Driven Design 10+ hours a day I

  • 0

After a week of learning about Domain Driven Design 10+ hours a day I started feeling like I was beginning to understand it pretty well until I read this article today:

http://blog.fedecarg.com/2009/03/15/domain-driven-design-the-repository/

The author of that article is saying you inject the Repository into the Domain object and that did not make any sense to me.

I’m no expert on this subject but I think he is wrong but I would like some input from some people here on whether it is right or wrong to inject a Repository into a Domain Object.

With all my reading in the last week everyday as I read another article and another they were all sounding the same to me (which is a good thing) until I saw the article I posted above, it make me think twice if my picture of this pattern is incorrect.

Are you or are you not supposed to inject a Repository?

  • 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-06-17T09:36:50+00:00Added an answer on June 17, 2026 at 9:36 am

    The example shown is using the Active Record pattern. In this pattern, an entity knows how to save itself. This is generally not considered good Separation of Concerns because the class knows about two things: the data properties and how to persist itself.

    Injecting a repository into the Active Record object is better than some Active Record implementations I’ve seen (because you can at least swap out the repository implementation), but in my view (and most of the DDD community) the dependency is backwards:

    The repository should depend on the object it returns, not the other
    way around. The reason for this is that your “domain object” (more on
    that later) can exist (and should be testable) without being loaded or
    saved (that is, having a dependency on a repository).

    So to answer your question, no. You’re not supposed to inject a repository into a domain object.

    However, it’s worth noting that this isn’t really a domain object because it does not have behavior – just simple get/sets (accessors/mutators). It’s just a Data Transfer Object (DTO). If there’s really no behavior, you do not need a domain model – it’s just simple CRUD.

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

Sidebar

Related Questions

I've been learning Python for about a week or so and after my code
I just started learning Python about a week ago. I've made considerable progress thanks
just started learning haskell - love it after a week. At the moment going
I started learning C# a week ago. Today I was trying to install the
After a week of struggling I just got the msdeploy handler up on IIS7
After a week of asp.net mvc2, I still haven’t understood the advantages of ViewData.model
After one week searching and converting many algorithm from other language into php to
How to retrieve wordpress posts that published after last week or last month? I
After studying TCP/UDP difference all week, I just can't decide which to use. I
So, after spending the last week carefully designing and planning out my app, a

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.