domain-driven-design

DDD: DTO usage with different logic

≡放荡痞女 提交于 2019-12-23 05:23:48
问题 I am currently working on a DDD project and recently faced an issue regarding the use of DTOs. I have the following DTO in my domain (code is in php but could be in any language): class TranslationDto { private $locale; private $text; public function getLocale(...); public function getText(...); } The goal is that the UI will give the domain a DTO with a locale and its corresponding text. So for example, if the locale "FR" is not translated, the DTO will look like the following: // UI =>

What format is data in when passed to a domain layer for validations

五迷三道 提交于 2019-12-23 04:55:20
问题 I am confused about what form data is supposed to be in when passing data from a User Interface in the Presentation Layer to an Application Layer then the Domain Layer for validations. I am passing in a DTO but I've heard I should not. Rather that I should only pass in primitives and scalars to the Domain Layer. I'm not sure how this is done if not using a DTO class structure. Below is how I am using a DTO from my UI: My User Interface may have values as follows on screen: Product Name:

Event Aggregator Error Handling With Rollback

安稳与你 提交于 2019-12-23 04:05:15
问题 I've been studying a lot of the common ways that developers design/architect an application on domain driven design (Still trying to understand the concept as a whole). Some of the examples that I saw included the use of events via an event aggregator. I liked the concept because it truly keeps the different elements/domains of an application decoupled. A concern that I have is: how do you rollback an operation in the case of an error? For example: Say I have an order application that has to

Should I Pass a repository to a Domain Method that fires an Event

大兔子大兔子 提交于 2019-12-23 03:50:09
问题 slightly related to this question: Should I pass a repository to a domain object method that needs to fire an event after the methods actions have occurred and been persisted? In this case the system needs to send emails of after the domain object's status is changed. Whilst unlikely, it could happen that the status change would not be persisted in which case the email should not be sent. I could use a domain service to do the work, but all the logic of status changing belongs and is

Domain security involving domain logic

隐身守侯 提交于 2019-12-23 03:42:17
问题 Together with my application's domain logic I am trying to outline the security model. I am stuck with a requirement that prevents me from considering security just a cross-cutting concern over my domain logic. Here follows my situation. A user in my system can potentially be allowed to create a certain kind of objects, say, 'filters'. I introduce a permission called 'CREATE_FILTER', and a user is either allowed to create filters or not, depending on whether the admin assigned such a

Appropriate spot for security evaluations - business logic or data access

北战南征 提交于 2019-12-23 02:54:16
问题 Pardon the length here...hopefully I didn't go overboard... I'm in the process of working on my first production MVC application and I'm trying to stick to DDD principles in the process. I've run into some questions related to how to deal with the security requirements of the application and thought I'd see if the SO community could offer some best-practice suggestions. Domain Information To use a simplified explanation, this application will have AffiliateCompanies , Users , and Customers .

Service Layer are repeating my Repositories

社会主义新天地 提交于 2019-12-22 11:44:27
问题 I'm developing an application using asp.net mvc, NHibernate and DDD. I have a service layer that are used by controllers of my application. Everything are using Unity to inject dependencies (ISessionFactory in repositories, repositories in services and services in controllers) and works fine. But, it's very common I need a method in service to get only object in my repository, like this (in service class): public class ProductService { private readonly IUnitOfWork _uow; private readonly

Implementing a Saga/Process Manager in a CQRS http application

一世执手 提交于 2019-12-22 10:53:59
问题 Following this example: https://msdn.microsoft.com/en-us/library/jj591569.aspx (Figure 3) How it fits in a http application? The user should perform a http request to the PlaceOrderController, which will send a PlaceOrderCommand, but how would the Order Process Manager answers the "9. Order Confirmed" to the user? How is the controller aware of that, in order to return this info to the user? Thanks 回答1: You simply don't answer "Order Confirmed" immediately. Take a look at how Amazon and other

Populate the domain model from data layer, or query database direct?

别来无恙 提交于 2019-12-22 10:12:10
问题 Say I have a domain model where 3 objects interact, Reservation , Vehicle and Fleet . The Fleet has many Vehicles, and each Vehicle can have many Reservations. e.g. Fleet -1--*- Vehicle -1--*- Reservation If I want Fleet to have a method getMostPopularVehicle() , I could have it iterate each Vehicle and count the number of Reservations. If I then want to introduce an ORM for persistence, should I (1) have getMostPopularVehicle() call a data layer method to populate the Fleet, Vehicles and

BL Services: Exception or Method Result?

北城以北 提交于 2019-12-22 09:47:53
问题 What is the best way and why? V1: try { var service = IoC.Resolve<IMyBLService>(); service.Do(); } catch(BLException ex) { //Handle Exception } V2: var service = IoC.Resolve<IMyBLService>(); var result = service.Do(); if (!result.Success) { //Handle exception } 回答1: Exceptions are better in my opinion. I think that DDD code is first and foremost good object oriented code. And the debate about using exceptions vs return codes in OO languages is mostly over. In DDD context I see following