domain-driven-design

DDD Approach to Access External Information

为君一笑 提交于 2019-12-17 07:42:06
问题 I have an existing bank application classes as shown below. The banks account can be of SavingsBankAccount or FixedBankAccount. There is an operation called IssueLumpSumInterest. For FixedBankAccount, the balance need to be updated only if the owner of the account has no other account. This demands the FixedBankAccount object to know about other accounts of the account owner. How to do this by following SOLID /DDD/GRASP/Information Expert pattern? namespace ApplicationServiceForBank { public

Refactoring code to avoid anti-pattern

扶醉桌前 提交于 2019-12-17 05:15:35
问题 I have a BusinessLayer project which has the following code. The domain object is FixedBankAccount (which implements IBankAccount). The repository is made as a public property of the domain object and is made as an interface member. How to refactor it so that repository will not be an interface member ? The domain object (FixedBankAccount) makes use of the repository directly to store the data. Is this a violation of Single Responsibility Principle? How to correct it? Note: The repository

Is it ok for entities to access repositories?

不问归期 提交于 2019-12-17 03:16:57
问题 I've just started working with DDD, so maybe this is a silly question... Is it ok for an entity to access a repository (via some IRepository interface) to get a value at runtime? For example, I want to enforce a "default" selection for a property: class Person { private Company _employer; public Company Employer { get { return _employer; } set { if(value != null) { _employer = value; } else { _employer = employerRepository.GetDefaultEmployer(); } } } ... } My question is whehter doing

EF 6 share the same entity between different DbContexts?

假如想象 提交于 2019-12-14 04:01:12
问题 I am using ASP.NET MVC 5 with EF 6. I am trying to follow DDD patern and I have IdentityContext and AddressContext. public class IdentityContext : IdentityDbContext<ApplicationUser> { public IdentityContext() : base("DefaultConntection", throwIfV1Schema: false) { } public static IdentityContext Create() { return new IdentityContext(); } } public class AddressContext: DbContext { public AddressContext(): base("DefaultConntection"){} public DbSet<Location> Locations { get; set; } } When I am

Can repository pattern be used for loading of “partial entities”

牧云@^-^@ 提交于 2019-12-14 00:33:55
问题 I'm trying to get better understanding of repository pattern in Domain Driven Design. All examples of repository pattern implementation are dealing with entities only. But what if i need to retrieve only some part of entity? For example, i have Client entity with large amount of properties. Can i define something like this in ClientRepository: public IEnumerable<string> GetClientsNames() { ... } of even: class ClientBaseInfo //includes some subset of properties of Client entity { public

Domain Driven Design issue regarding repository

◇◆丶佛笑我妖孽 提交于 2019-12-14 00:26:01
问题 I am trying to implement the DDD so I have created the following classes - User [the domain model] - UserRepository [a central factory to manage the object(s)] - UserMapper + UserDbTable [A Mapper to map application functionality and provide the CRUD implementation] My first question is that when a model needs to communicate with the persistent layer should it contact the Repository or the mapper? Personally I am thinking that it should ask the repository which will contact the mapper and

Reporting errors from the application services layer

ε祈祈猫儿з 提交于 2019-12-13 21:14:36
问题 I'm implementing web application based on Spring MVC and organized around DDD concepts. Currently I try to implement ticket reservation functionality. The customer can see number of tickets available for the particular event. Then, he can enter number of tickets to be reserved and submit form. Request is received by controller which calls application service responsible for registration. Application service logic is as follows: Validate incoming parameters: 1A. Check if event with the given

Operations on entities within a aggregate root

我只是一个虾纸丫 提交于 2019-12-13 14:07:52
问题 If i have designed an AR like the below, how do you think i should go about say updating a property in one of the order line objects ? For Example how can i change the title for one of my order lines (example question) This is the Order Aggregate Root public class Order { private readonly int id; private readonly Customer customer; // Customer is another Aggregate private readonly IList<OrderLine> orderLines; private readonly IOrderLineFactory orderLineFactory; public Order(int id, Customer

DDD: How to handle large collections

醉酒当歌 提交于 2019-12-13 13:08:06
问题 I'm currently designing a backend for a social networking-related application in REST. I'm very intrigued by the DDD principle. Now let's assume I have a User object who has a Collection of Friends. These can be thousands if the app and the user would become very successful. Every Friend would have some properties as well, it is basically a User. Looking at the DDD Cargo application example, the fully expanded Cargo-object is stored and retrieved from the CargoRepository from time to time.

DDD Reporting Scenarios

眉间皱痕 提交于 2019-12-13 12:45:48
问题 I'm trying to create a reporting/analysis web app that will use MVC3, EF and DDD approach. I'm havign a hard time to come up with entities or object classes for aggregated tables on existing database. For example, I have Orders and OrderLine as an aggregate and Customers as Entity. This three objects can be modeled using DDD approach but what if I want to have an OrdersAggregate Table which will contatins all the details like customer name, payment type, etc. Should I create an object class