ddd-repositories

Setting up a repository pattern in MVC

北战南征 提交于 2019-12-09 15:29:17
问题 I'm trying to figure out how the Repository pattern works and how it can be implemented in a custom MVC pattern. As far as i understand it, the Repository is a layer which simply returns data from an entity class or saves the entity class to a persistent layer. Now i currently see it like this: A request comes in into my controller to create a user. Just a username and password. My controller will do something like this: function CreateAction ( ) { $userRepo = new userRepository ( ); $user =

Is DDD suited for all kinds of application?

 ̄綄美尐妖づ 提交于 2019-12-08 17:45:16
问题 One common reaction that I see for a lot of questions asked here and other forums are like "You don't need to do DDD for that. Its a simple CRUD application, DDD is an over-engineering". Well I am new to DDD and I feel there are a lot of elements in DDD that has universal appeal and can be used across the board, irrespective of the fact whether your application is complex enuf to mandate DDD. For example, layering of application, differnent artifacts that DDD recognises etc. May be start with

Can an Entity access a Repository?

半城伤御伤魂 提交于 2019-12-08 09:38:28
问题 Say I've got two simple entities: User and Review. How bad is it if User calls the Review repository? What is the "clean" way for the User to get its Reviews? class User { public function getReviews() { return reviewRepository.findByUser(this); } } I did have a look at this question, but although they say this is a bad practice, I didn't find an answer there. 回答1: The clean way in DDD is to have the UserRepository fill the reviews of the User when asking for a User. class UserRepository {

Is it ok for a DDD repository work with summary objects in addtion to “real” objects

北城余情 提交于 2019-12-07 09:39:50
问题 Say I'm creating a repository to store digital E-Books as shown in the interface below. This repository will store the actual text of the book, as well as the metadata that identifies the book (title, author, publisher, ISBN etc..). public interface IBookRepository { void AddBook(Book newBook); void DeleteBook(int bookId); void UpdateBook(Book updatedBook); Book GetBook(int bookID) } public class Book { public int BookId {get; set;} public string Title {get; set;} public string Author {get;

soft delete in DDD

℡╲_俬逩灬. 提交于 2019-12-06 15:25:45
问题 I have a scenario where a given entity may be marked for soft delete or a hard delete based on some logic when a user requests delete. Approaching this problem from DDD paradigm, i see some issues :- DDD proposes use of Repository object for all persistence related stuff where the domain layer just defines such repo interface (containing typical methods like store, remove, find) and the infrastucture layer containing the actual implementation. Given that, for my problem here then , the logic

Persistence encapsulated via the domain, or persistence via the Repository?

房东的猫 提交于 2019-12-06 14:40:49
问题 If my Domain Model is not supposed to know/care about the Repository, then how does some behaviour like .UpdateOrder(...) , that encapsulates a CRUD-Update, interface with the Repository? Through a Domain Service? Ok, then my Repository has an effective CRUD-Update that's used in conjunction with my .UpdateOrder(...) . That's fine. But i don't want someone to use the Update method on the Repository, i want them to go through the behaviour on the Entity (use UpdateOrder() instead). I'd prefer

How update an entity inside Aggregate

限于喜欢 提交于 2019-12-06 13:37:31
问题 I have an aggregate named Campaigns every with a root entity named campaign, this root entity has a list of attempts (entity) public class Attempts: IEntity<Attempts> { private int id; public AttempNumber AttemptNumber {get;} //other fields } public class Campaign: IEntity<Campaign> //root { private int id; public IList<Attempt> {get;} //other fields } Im using a method to add a campaign attempt public virtual void AssignAttempts(Attempts att) { Validate.NotNull(att, "attemps are required for

DDD design understanding

纵然是瞬间 提交于 2019-12-06 09:55:18
问题 I've been starting to learn about DDD and I have couple of questions so that I can improve my understanding of it. So a typical DDD architecture looks like this Domain Layer => this layer should be technology agnostic and should contain the following Domain.Entities (different from the persistence layer Entities, should contain only validation rules ? any other domain business should go here?) Domain.ValueObjects (objects that do not require to be unique in the domain, should contain only

DDD: where should logic go that tests the existence of an entity?

时间秒杀一切 提交于 2019-12-06 05:35:27
问题 I am in the process of refactoring an application and am trying to figure out where certain logic should fit. For example, during the registration process I have to check if a user exists based upon their email address. As this requires testing if the user exists in the database it seems as if this logic should not be tied to the model as its existence is dictated by it being in the database. However, I will have a method on the repository responsible for fetching the user by email, etc. This

DDD: Where is it most appropriate to get a list of value objects

淺唱寂寞╮ 提交于 2019-12-06 04:47:12
问题 I've got a value type called "Product Type" that is assigned to a product. (A product has one product type) To allow the user to select the type from a list, I'm going to fill a dropdown. Where is it most appropriate to retrieve the list of product types? A class implementing a repository pattern? Edit: Clarified by changing product code to product type. A product type is something like "DVD"/"CD"/"Blu Ray"/etc. 回答1: Product seems to be aggregate root, so list of product types should be in