domain-driven-design

In DDD Architecture where do I keep helper classes?

寵の児 提交于 2019-12-20 02:07:16
问题 I'm working in a DDD project where contains these layers: UI, Application, Domain and Infrastructure. Where should the helpers classes live? Update: I'm talking about a Object Dumper Helper for example. 回答1: It depends on what kind of helper you are talking about. If it's a Helper that format a value in a friendly display format, then it would fit better in the UI. If you are talking about a SqlServer helper, then it goes to Infra. 回答2: Classes like [Something]Helper , [Something]Manager and

In DDD Architecture where do I keep helper classes?

*爱你&永不变心* 提交于 2019-12-20 02:07:14
问题 I'm working in a DDD project where contains these layers: UI, Application, Domain and Infrastructure. Where should the helpers classes live? Update: I'm talking about a Object Dumper Helper for example. 回答1: It depends on what kind of helper you are talking about. If it's a Helper that format a value in a friendly display format, then it would fit better in the UI. If you are talking about a SqlServer helper, then it goes to Infra. 回答2: Classes like [Something]Helper , [Something]Manager and

Data access layer design in DDD

不羁的心 提交于 2019-12-19 21:51:24
问题 Excuse me for my poor English. Ok, I'm thinking about DDD approach now and it sounds great but... There is one little question about it. DDD says that the domain model layer is totally decoupled from the data access layer (and all other layers). So when the DAL will save some business object it will have access to public properties of this object only. Now the question: How can we guarantee (in general) that a set of public data of an object is all we need to restore the object later? Example

How linq 2 sql is translated to TSQL

拟墨画扇 提交于 2019-12-19 11:43:46
问题 It seems Linq2sql doesn't know how to construct the TSQL while you transform linq2sql object into domain object with constructors. Such as: from c in db.Companies select new Company (c.ID, c.Name, c.Location).Where(x => x.Name =="Roy"); But when using settable attributes, it will be OK. from c in db.Companies select new Company { ID = c.ID, Name = c.Name, Location = c.Location }.Where(x => x.Name =="Roy"); I don't want to allow those attributes to be settable. How can I achieve this? And can

Searching for a Child across Aggregate Roots

岁酱吖の 提交于 2019-12-19 10:32:48
问题 The repository pattern suggest that you can only pull aggregate roots. But how would you retrieve a single child using only it's uniqiue identity(Child.ID) if you do not know it's parent(root)? class Parent { public int ID { get; set; } IEnumerable<Child> Children { get; private set; } } class Child { public int ID { get; private set; } public virtual Parent Parent { get; private set; } // Navigational model } My application is stateless (web), for simplicity, the request only contains the ID

Unit testing value objects in isolation from its dependencies

淺唱寂寞╮ 提交于 2019-12-19 08:50:45
问题 TL;DR How do you test a value object in isolation from its dependencies without stubbing or injecting them? In Misko Hevery's blog post To “new” or not to “new”… he advocates the following (quoted from the blog post): An Injectable class can ask for other Injectables in its constructor.(Sometimes I refer to Injectables as Service Objects, but that term is overloaded.). Injectable can never ask for a non-Injectable (Newable) in its constructor. Newables can ask for other Newables in their

Implementing repository for EF4 using DDD and IoC

这一生的挚爱 提交于 2019-12-19 03:24:07
问题 I think I'm going in circles. I'm working on an MVC 3 solution using EF4 & POCOs (database-first) and IoC. My repository and UoW patterns were mostly adopted from this article and this article. My solution is made up of the following projects: Implementations: Presentation (MVC site) Domain Services (business layer) Domain Repository (data access) Domain Context (my EF4 edmx and generated context) Domain Models (my EF4 generated POCOs) Interfaces: Domain Services Interfaces (business layer

DDD - Validation of unique constraint

女生的网名这么多〃 提交于 2019-12-18 19:06:13
问题 In DDD you should never let your entities enter an invalid state. That being said, how do you handle the validation of a unique constraint? The creation of an entity is not a real problem. But let say you have an entity that must have a unique name and there is a thousand instances of this entity type - they are not in memory but stored in a database. Now let say you want to rename an instance. You can't just use a setter... the object could enter an invalid state - you have to validate

DDD - how to rehydrate

断了今生、忘了曾经 提交于 2019-12-18 16:58:49
问题 Question : what is the best, efficient and future proof way to rehydrate an aggregate from a repository? What are the pro's and con's of the provided ways and are my perceptions correct? Let's say we have an Aggregate Root with private setters but public getters for accessing state Behaviour is done through methods on the aggregate root. A repository is instructed to load an aggregate. At the moment I see a couple of possible ways to achieve this: set the state through reflection (manual or

DDD - how to rehydrate

我与影子孤独终老i 提交于 2019-12-18 16:58:32
问题 Question : what is the best, efficient and future proof way to rehydrate an aggregate from a repository? What are the pro's and con's of the provided ways and are my perceptions correct? Let's say we have an Aggregate Root with private setters but public getters for accessing state Behaviour is done through methods on the aggregate root. A repository is instructed to load an aggregate. At the moment I see a couple of possible ways to achieve this: set the state through reflection (manual or