{"id":4326,"date":"2014-03-30T09:53:38","date_gmt":"2014-03-30T09:53:38","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-domain-driven-design-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:53:38","modified_gmt":"2014-03-30T09:53:38","slug":"problem-about-domain-driven-design-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/problem-about-domain-driven-design-collection-of-common-programming-errors\/","title":{"rendered":"problem about domain-driven-design-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8bc7bb10bee96efb190053fe92ffd250?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTorbj\u00f8rn<br \/>\nc# domain-driven-design immutability<br \/>\nI&#8217;m learning about DDD, and have come across the statement that &#8220;value-objects&#8221; 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&#8217;t add property setters, and make sure no methods are allowed to modify the content (only retu<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e0a8cee6e28ff68cd35a0dc11a1fd5ab?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHenningK<br \/>\nwcf serialization soap domain-driven-design soa<br \/>\nTypical 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&#8217;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.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fda2eb93ee0cf0e6f41d896d198e158a?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnonot1<br \/>\nc# domain-driven-design language-design dsl<br \/>\nSo, I&#8217;ve got a C# application with a custom types hierarchy that&#8217;s ~4 layers deep. This layering exists to provide a clean implementation of data validation and change event propagation.An example would be: DocumentNameValue -&gt; NameValue &#8211; &gt; StringValue -&gt; BaseDataValue.The system works fine, but given all the layers of indirection, performance surfers. In absolute terms, it&#8217;s not a huge hit, but it does add up.To clarify, the performance issue seems to be as a result of the nested<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c84f207ea08ae47484ec455ea4e8b8b8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAntineutrino<br \/>\nc# .net nhibernate domain-driven-design<br \/>\nI find a lot of posts where it is explained that one should always override Equals\/GetHashCode on a NHibernate entity class. If I don&#8217;t use Sets, is this really necessary? I simply can&#8217;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 .<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ad3b5dcf591697357a8b2b6936e4b988?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKane<br \/>\narchitecture business domain-driven-design risk<br \/>\nI 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.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/6bf4d11cfab70f3c495cc5e775274beb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTodd Smith<br \/>\nc# security authentication domain-driven-design roles<br \/>\nHow 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&#8217;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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3c8a94e8bd3a691d079556cdf5a0b248?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJim G.<br \/>\ndomain-driven-design repository-pattern ddd-repositories<br \/>\nI&#8217;ve just started working with DDD, so maybe this is a silly question&#8230;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 &#8220;default&#8221; 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();}}}&#8230; }My question is whehter doing something like this is<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b3a337c3d431a344b40e223e0be50803?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPangea<br \/>\ndomain-driven-design cqrs event-sourcing<br \/>\nQuoting from Rinat Abdullin&#8217;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?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ee34912c2f3bb4df3b6e8a84f47df014?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMatt<br \/>\ndomain-driven-design<br \/>\nThat is, is there ever a case where a domain model should be available for modification outside of its creation?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3192eeb39449a86afa994fa9efc83179?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBen Foster<br \/>\n.net events domain-driven-design<br \/>\nI&#8217;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&#8217;s design?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a9d1f9135b43b217b9325eed54745460?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJoshua Enfield<br \/>\n.net design domain-driven-design code-smell<br \/>\nI 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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/646403d51a0d50d498f0347270087623?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nYaron Naveh<br \/>\nc# serialization domain-driven-design persistence<br \/>\nMy domain model looks like this:class Group {private List&lt;Person&gt; persons;public void AddPerson(Person p) {persons.Add(p);DoSideEffect()}public List&lt;Person&gt; GetPersons() {&#8230;} }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 &#8211; but how am I going to load them back? If I call AddPerson() then there<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/x4YHl.gif?s=32&amp;g=1\" \/><br \/>\nLijo<br \/>\nc# nhibernate linq-to-sql tdd domain-driven-design<br \/>\nI 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 &#8220;Add the interface<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ea8de58412eb5dbd6b61ac19e0e7e79f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nStackUnderflow<br \/>\ndesign design-patterns domain-driven-design factory<br \/>\nWhat 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&#8230; 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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5f9268e92d280002078760f29da7dc3b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nHarza<br \/>\nc# generics domain-driven-design<br \/>\nI have method like this:public static void Raise&lt;TEvent&gt;(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 &#8220;lost&#8221; type of concrete event here. When I pass that type pa<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0a9d0aadd049fa597a20fe4274e8d1b9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nKenneth Cochran<br \/>\nc# plugins domain-driven-design ioc-container<br \/>\nI&#8217;ve written a program using Domain Driven Design in .NET 2.0 and I&#8217;m trying to implement a plugin framework for it.I&#8217;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&#8217;s data formats, etc<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/71699330a829554256913498d3beabdc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNoPyGod<br \/>\nentity-framework domain-driven-design repository-pattern<br \/>\nI 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&#8217;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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9e7ef08258f04dab37b43842d261aea8?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJosh Kodroff<br \/>\nc#-4.0 domain-driven-design cqrs message-bus<br \/>\nMy 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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3945e8f6e6e10b745af6c8e86f7e5481?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nabx78<br \/>\nnhibernate domain-driven-design nhibernate-mapping<br \/>\nI 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:&lt;joined-subclass name=&#8221;EntityA&#8221;table=&#8221;t_entity&#8221;subselect=&#8221;SELECT * FROM t_entity WHERE t_entity.discriminator is not null&#8221;&gt;&lt;key column=&#8221;t_uid&#8221;&gt;&lt;\/key&gt;&lt;!&#8211; more mapping &#8211;&gt; &lt;\/joined-subclass&gt;&lt;joined-subclass name=&#8221;EntityB&#8221;table=&#8221;t_entity&#8221;subselect=&#8221;SELECT * FROM t_entity WHERE t_entity.discriminator<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d1aef30263cfdd40cfce2da7c364e3c2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNozama<br \/>\njava domain-driven-design illegalargumentexception<br \/>\nSay we have a method changeUserName(Long id,String newName) which invokes the repository&#8217;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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/05a2d883344191805ff3602bb61261f0?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nlko<br \/>\nc# asp.net-mvc domain-driven-design<br \/>\nWe&#8217;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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b946e521ea4a2ad1738c39454dc3ad9e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nOrhan<br \/>\ndoctrine domain-driven-design polymorphic-associations doctrine2<br \/>\nI need a concrete sample of code with doctrine 2 that uses &#8220;polymorphic associations&#8221;. 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&#8217;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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/22dd9316cf412286a44197f8f8adfce2?s=128&amp;d=identicon&amp;r=PG\" \/><br \/>\nKit<br \/>\nrepository domain-driven-design entity aggregateroot<br \/>\nLet&#8217;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&#8217;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<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fe4584736904b0f3786d653ceb70b4ec?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nUffe<br \/>\nasp.net-mvc entity-framework domain-driven-design<br \/>\nI 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) &#8211;&gt; Application service &#8211;&gt; Domain L<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/37f208b18a759c881c12b81734521edb?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmatori82<br \/>\n.net exception domain-driven-design enterprise<br \/>\nI am developing enterprise-like project by using DDD pattern. I have following projects in my C# solution:Domain model &#8211; DLL project WebUI &#8211; ASP.NET MVC3 project DesktopUI &#8211; WPF project DAL &#8211; Entity Framework Code First Persistance &#8211; SQL Server DatabaseThis project is not large but I am trying to use all good practices of enterprise applications. What I&#8217;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<\/li>\n<\/ul>\n<p>Web site is in building<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Torbj\u00f8rn c# domain-driven-design immutability I&#8217;m learning about DDD, and have come across the statement that &#8220;value-objects&#8221; 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4326","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4326"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4326\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}