problem about domain-driven-design-Collection of common programming errors


  • Torbjørn
    c# domain-driven-design immutability
    I’m learning about DDD, and have come across the statement that “value-objects” should be immutable. I understand that this means that the objects state should not change after it has been created. This is kind of a new way of thinking for me, but it makes sense in many cases.Ok, so I start creating immutable value-objects. I make sure they take the entire state as parameters to the constructor, I don’t add property setters, and make sure no methods are allowed to modify the content (only retu

  • HenningK
    wcf serialization soap domain-driven-design soa
    Typical scenario. We use old-school XML Web Services internally for communicating between a server farm and several distributed and local clients. No third parties involved, only our own applications used by ourselves and our customers.We’re currently pondering moving from XML WS to a WCF/object-based model and have been experimenting with various approaches. One of them involves transferring the domain objects/aggregates directly over the wire, possibly invoking DataContract attributes on them.

  • nonot1
    c# domain-driven-design language-design dsl
    So, I’ve got a C# application with a custom types hierarchy that’s ~4 layers deep. This layering exists to provide a clean implementation of data validation and change event propagation.An example would be: DocumentNameValue -> NameValue – > StringValue -> BaseDataValue.The system works fine, but given all the layers of indirection, performance surfers. In absolute terms, it’s not a huge hit, but it does add up.To clarify, the performance issue seems to be as a result of the nested

  • Antineutrino
    c# .net nhibernate domain-driven-design
    I find a lot of posts where it is explained that one should always override Equals/GetHashCode on a NHibernate entity class. If I don’t use Sets, is this really necessary? I simply can’t find a sample where it is shown that missing Equals/GetHashCode can lead to unexpected and wrong behaviour. Everything seems to work perfectly without them. This is really strange that everyone says this is necessary but no one can provide a sample which shows why this is needed .

  • Kane
    architecture business domain-driven-design risk
    I am looking to quantify the cost or problems of bad software development practices. Specifically can software that has been developed resulting in an anemic domain model be quantifiable in terms of business cost or risk?My initial thoughts (which are all nearly impossible to generically quantify) are: -Reduced flexibility. Potential for increased support costs.Any assistance you can offer would be greatly appreciated.

  • Todd Smith
    c# security authentication domain-driven-design roles
    How do you implement Roles and Security in your C# Domain Driven Designs? We have some debate raging on wether it should be implemented by the calling application (ASP.NET MVC) or in the Domain Model itself (model entities and services). Some argue that it should be in the web site itself since that’s where the authentication already exists. But that means you have to re-implement security every time you integrate with the core business systems.As an example: an Admin should be able to do pretty

  • Jim G.
    domain-driven-design repository-pattern ddd-repositories
    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 something like this is

  • Pangea
    domain-driven-design cqrs event-sourcing
    Quoting from Rinat Abdullin’s article:CQRS and Event Sourcing also simplify implementation of the flexibleentity models with various custom fields and properties that are oftendefined at the run-time and used in layout and drag-n-drop designersby the end-users.I fail to understand how the runtime custom field definition is possible with event sourcing and cqrs?

  • Matt
    domain-driven-design
    That is, is there ever a case where a domain model should be available for modification outside of its creation?

  • Ben Foster
    .net events domain-driven-design
    I’ve been reviewing an example of domain event design blogged about recently by Mike Hadlow and created originally by Udi Dahan.Currently we are publishing static events on our domain objects and subscribing to them directly within our services, or via our plugin model (we locate and initialize our plugins at runtime using StructureMap).What is the advantage of using Udi’s design?

  • Joshua Enfield
    .net design domain-driven-design code-smell
    I am noticing occasions where I need to add dependencies to parent classes, and their parents and so on, only because a child class needs it. Is this a code smell? Is it reasonable for a parent class to need information only because a child class needs it?In particular in our [slightly anemic] flavor of DDD this seems to occur with Application Services (Domain boundary) needing information from our application layer to pass on to Domain Services. It is quite painful to add dependencies to app se

  • Yaron Naveh
    c# serialization domain-driven-design persistence
    My domain model looks like this:class Group {private List<Person> persons;public void AddPerson(Person p) {persons.Add(p);DoSideEffect()}public List<Person> GetPersons() {…} }Now I need to persist it. By DDD I cannot add any persistence attributes to this class so xml serializers will not work. BinaryFormatter cannot be used since the format should be readable. I can manually call GetPersons() and persist them – but how am I going to load them back? If I call AddPerson() then there

  • Lijo
    c# nhibernate linq-to-sql tdd domain-driven-design
    I have a IBankAccount interface that I will be passing to the ApplicationService. The changes made on the account objects (in the ApplicationService project) need to be persisted in the database. The repository receives the changes using IBankAccount interface. How can I persist this data into database? This is implemented using LINQ to SQL.Note: Following is a comment from Scott in http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx “Add the interface

  • StackUnderflow
    design design-patterns domain-driven-design factory
    What is your threshold to use factory instead of a constructor to create an object?You always use factory. You use factories only if you have invariant checks other than checking for nulls. You always use constructors You rarely use factories… what are those cases??pros and consUpdate: I am applying factory pattern from Domain Driven Design in my project. And one of the reason behind creating factories is to reduce noise in the domain model. Thanks

  • Harza
    c# generics domain-driven-design
    I have method like this:public static void Raise<TEvent>(TEvent eventToRaise)where TEvent : IEvent { }And I call that method like this:foreach (IEvent evt in entity.UncommittedEvents) {DomainEvents.Raise(evt); }where I assume that this is true:bool areSame = typeof(TEvent) == eventToRaise.GetType();but it seems that it is not true. Instead it is:bool areSame = typeof(TEvent) == typeof(IEvent);Why is that so?Problem here is that I “lost” type of concrete event here. When I pass that type pa

  • Kenneth Cochran
    c# plugins domain-driven-design ioc-container
    I’ve written a program using Domain Driven Design in .NET 2.0 and I’m trying to implement a plugin framework for it.I’ve implemented several types of plugins:Domain PluginA domain aggregate composed of one or more domain classes One or more View/Presenter pairs to display instances of the aggregate An import/export service specific to the domain aggregate A repository classService PluginsDatabase Plugin (embedded or remote) General import/export services (cvs, xml, competitor’s data formats, etc

  • NoPyGod
    entity-framework domain-driven-design repository-pattern
    I have a program using entity framework, and depending on which computer it is run on, it will either connect to a remote database over the network or a local database on the local filesystem.With entity framework, when I create an instance of MyDbContext (which inherits from entity framework’s DbContext) it uses the code first naming conventions and will look in the app.config/web.config for a connection string with the same name (id) as the class -ie.. MyDbContact. Normally this is a very usef

  • Josh Kodroff
    c#-4.0 domain-driven-design cqrs message-bus
    My system uses The Command Pattern with separate handlers. My commands are executed on a CommandService which currently handles all commands in-process.I have certain commands which do at least 1 of these things that are slow operations:Sends an email Generates a PDF Sends a Fax Interacts with 3rd party web servicesI want all of these commands to be handled out of process so that the UI is more snappy. Should I use a messaging bus just for these commands, or should I have the in-process comman

  • abx78
    nhibernate domain-driven-design nhibernate-mapping
    I have two joined subclass reading from the same table having as a discriminator a nullable field. I have been able to read the two entities using a subselect like this:<joined-subclass name=”EntityA”table=”t_entity”subselect=”SELECT * FROM t_entity WHERE t_entity.discriminator is not null”><key column=”t_uid”></key><!– more mapping –> </joined-subclass><joined-subclass name=”EntityB”table=”t_entity”subselect=”SELECT * FROM t_entity WHERE t_entity.discriminator

  • Nozama
    java domain-driven-design illegalargumentexception
    Say we have a method changeUserName(Long id,String newName) which invokes the repository’s findUser(Long id) to find the right user entity and then change its name. Is it appropriate to thow an IllegalArgmentException when findUser returns null ? Or should I instead throw a custom UserNotExistException (extends AppException extends RuntimeException) ?UPDATE:RuntimeException: @nachokk @JunedAhsan Actually I deliberately make all the exceptions unchecked , because I think this way makes client co

  • lko
    c# asp.net-mvc domain-driven-design
    We’re currently considering whether it makes sense (or if the benefits are worth the added code) to introduce a Message based pattern (such as Request Response) into a Domain Driven Design / Service Oriented Architecture under an MVC app (with DI and potentially used by MVC, WCF, Windows Services, etc.).Basically (in MVC) the controller uses an injected service which in turn uses an injected repository to save/update/delete objects.There are Application Services, and Domain Services and the appl

  • Orhan
    doctrine domain-driven-design polymorphic-associations doctrine2
    I need a concrete sample of code with doctrine 2 that uses “polymorphic associations”. Let me clarify myself. I have a Entity called Contract and a contract can have many price rules and these price rules can be different kind of classes and presisted in different tables. I suppose this is what’s polymorphic associations for or am I wrong?class contract {private $id;private $priceRules;}class discountRule implements priceRule{function calculate() {// calculate new price after this rule} }class e

  • Kit
    repository domain-driven-design entity aggregateroot
    Let’s say we have an aggregate root entity of type Order that relates customers and order lines. When I think about an order entity it’s more natural to conceptualize it as not being defined without an Id. An order without an Id seems to be better represented as an order request than an order.To add an order to a repository, I usually see people instantiate the order without the Id and then have the repository complete the object:class OrderRepository {void Add(Order order){// Insert order int

  • Uffe
    asp.net-mvc entity-framework domain-driven-design
    I am designing solution strucure for an application. I am planning to use Domain driven design. Asp.net MVC and Entity framework. Need your inputs in some areas.Data Access is designed using Entity framework code first Reposirotires are built on top of EF Data Acces Domain model is designed usind domain model on top of Repositories Application serveices are built on top of Damain layer UI is developed on top of Application servicesThe flow isUI (controller) –> Application service –> Domain L

  • matori82
    .net exception domain-driven-design enterprise
    I am developing enterprise-like project by using DDD pattern. I have following projects in my C# solution:Domain model – DLL project WebUI – ASP.NET MVC3 project DesktopUI – WPF project DAL – Entity Framework Code First Persistance – SQL Server DatabaseThis project is not large but I am trying to use all good practices of enterprise applications. What I’d like to define now is exception strategy but I am not sure how to approach that. I should probably use Enterprise Library Exception Handling

Web site is in building