Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • 2
    "couldn't we still argue that such Domain Objects contain Infrastructure-related logic and thus still violate PI?" No, because "these Domain Object[s] are [still] completely unaware of how they are being persisted." Commented Jan 8, 2013 at 19:28
  • 1
    Then put the infrastructure-related logic in the repository; i.e. cache it. But the key word here is "persistence." An object that is "caching itself" is not persisting itself (i.e. writing it to a storage device); it is merely remembering some previous value. Commented Jan 8, 2013 at 19:42
  • 1
    There are always things that you need to do to your domain objects to make things work with some of the popular ORM's, whether it be virtualising your members, or decorating them with attributes. My question is what is the risk of doing that? At some stage you have to make a decision on how you are going to persist your objects and its unlikely going to change once the decision is made. So is it really that bad? If keeping your domain free of influence from ORM is important to you then maybe don't use an ORM and look at alternative persistence solutions such as NoSQL. Commented Jan 8, 2013 at 19:49
  • 3
    It all comes down to practicality, not slavishly adhering to some abstract principle. I personally believe that there's no such thing as 100% persistence ignorance, since requesting an object requires some form of ID, and that ID is going to be supplied by, and dependent upon, the persistence mechanism. Commented Jan 8, 2013 at 20:16
  • 1
    As an aside, I don't like the term "ORM POCO". It's either an ORM-aware class, or it's a POCO. I don't see how it can be both. But, just in case there is such a thing as an "ORM POCO"... If it's truly a POCO, and it matches your domain requirements, then does it matter if it was generated by an ORM? Commented Jan 8, 2013 at 20:54