domain-model

What exactly is the difference between a data mapper and a repository?

亡梦爱人 提交于 2019-11-30 00:26:20
Well I've been trying to find out the difference between data mapper and repository, but up to now I still have not. It seems to me that the expert programmer said "Repository is another layer of abstraction over the mapping layer where query construction code is concentrated". It seems understandable but is still somewhat very abstract. I read this article on stackoverflow before, and it just made me even more confused: How is the Data Mapper pattern different from the Repository Pattern? I guess what I need are simple explanations and concrete/practical examples on how the two patterns

Domain Driven Design, Domain objects, attitude about Setters

a 夏天 提交于 2019-11-29 03:56:17
Been watching some Greg Young videos lately and I'm trying to understand why there is a negative attitude towards Setters on Domain objects. I thought Domain objects were supposed to be "heavy" with logic in DDD. Are there any good examples online of the bad example and then they way to correct it? Any examples or explanations are good. Does this only apply to Events stored in a CQRS manner or does this apply to all of DDD? I'm contributing this answer to complement Roger Alsing answer about invariants with other reasons. Semantic information Roger clearly explained that property setters don't

DDD: Entity identity before being persisted

百般思念 提交于 2019-11-28 23:44:56
问题 In Domain Driven Design, one of the defining characteristic of an Entity is that it has an identity. Problem: I am not able to provide a unique identity to Entities on instance creation. This identity is only provided by the repository once the entity is persisted (this value is provided from the underlying database). I cannot begin to use Guid values at this point. The existing data is stored with int primary key values and I cannot generate a unique int on instantiation. My solution: Each

Inheritance vs enum properties in the domain model

こ雲淡風輕ζ 提交于 2019-11-28 18:36:54
I had a discussion at work regarding "Inheritance in domain model is complicating developers life". I'm an OO programmer so I started to look for arguments that having inheritance in domain model will ease the developer life actually instead of having switches all over the place. What I would like to see is this : class Animal { } class Cat : Animal { } class Dog : Animal { } What the other colleague is saying is : public enum AnimalType { Unknown, Cat, Dog } public class Animal { public AnimalType Type { get; set; } } How do I convince him (links are WELCOME ) that a class hierarchy would be

Having Separate Domain Model and Persistence Model in DDD

為{幸葍}努か 提交于 2019-11-28 15:35:27
I have been reading about domain driven design and how to implement it while using code first approach for generating a database. From what I've read and researched there are two opinions around this subject: Have 1 class that serves both as a domain model and a persistence model Have 2 different classes, one implementing the domain logic and one used for a code-first approach Now I know opinion 1) is said to simplify small solutions that do not have many differences between the domain and persistence models but I think it breaks the single responsibility principle and by that introduces a lot

Domain Driven Design, Domain objects, attitude about Setters

醉酒当歌 提交于 2019-11-27 22:13:19
问题 Been watching some Greg Young videos lately and I'm trying to understand why there is a negative attitude towards Setters on Domain objects. I thought Domain objects were supposed to be "heavy" with logic in DDD. Are there any good examples online of the bad example and then they way to correct it? Any examples or explanations are good. Does this only apply to Events stored in a CQRS manner or does this apply to all of DDD? 回答1: I'm contributing this answer to complement Roger Alsing answer

Iterator versus Stream of Java 8

杀马特。学长 韩版系。学妹 提交于 2019-11-27 17:36:10
To take advantage of the wide range of query methods included in java.util.stream of Jdk 8 I am attempted to design domain models where getters of relationship with * multiplicity (with zero or more instances ) return a Stream<T> , instead of an Iterable<T> or Iterator<T> . My doubt is if there is any additional overhead incurred by the Stream<T> in comparison to the Iterator<T> ? So, is there any disadvantage of compromising my domain model with a Stream<T> ? Or instead, should I always return an Iterator<T> or Iterable<T> , and leave to the end-user the decision of choosing whether to use a

Rich vs Anemic Domain Model

Deadly 提交于 2019-11-27 16:50:21
I am deciding if I should use a Rich Domain Model over an Anemic Domain Model, and looking for good examples of the two. I have been building web applications using an Anemic Domain Model, backed by a Service --> Repository --> Storage layer system, using FluentValidation for BL validation, and putting all of my BL in the Service layer. I have read Eric Evan's DDD book, and he (along with Fowler and others) seem to think Anemic Domain Models are an anti-pattern. So I was just really wanting to get some insight into this problem. Also I am really looking for some good (basic) examples of a Rich

What is Java domain model?

房东的猫 提交于 2019-11-27 12:39:31
I am studying a Spring book and they mention Java domain model. What is that? A domain model (the term is not at all Java specific) is a class that models something in the problem domain, as opposed to a class that exists for technical implementation reasons. Domain model instances often need to be persisted in a database, and in Java, they typically conform to the Java Beans specification, i.e. they have get and set methods to represent individual properties and a parameterless constructor. Spring and other frameworks allow you to access these properties directly in your JSPs. For example, in

Inheritance vs enum properties in the domain model

ぃ、小莉子 提交于 2019-11-27 11:30:49
问题 I had a discussion at work regarding "Inheritance in domain model is complicating developers life". I'm an OO programmer so I started to look for arguments that having inheritance in domain model will ease the developer life actually instead of having switches all over the place. What I would like to see is this : class Animal { } class Cat : Animal { } class Dog : Animal { } What the other colleague is saying is : public enum AnimalType { Unknown, Cat, Dog } public class Animal { public