I am interested to see how people deal with decision trees when doing DDD. For example we have a requirement that when persisting new instance of particular type, some "default" associations have to be built (quite a few). User is free to change them later on though. So if one creates a decision table, how do you represent this in you domain, or do you? This is in insurance domain, so for example, if I choose one option then all related "default" benefits, options etc, get added to the policy, but user is then free to change it later on.
How do you deal with "defaults" when doing DDD
312 Views Asked by epitka At
2
There are 2 best solutions below
0
Be.St.
On
As suggested use a factory. To implement the default use the "special case pattern" as described by Martin Fowler to have real OOP.
For example if you have a Policy with Benefit and Options properties and they are classes create a derived class like this:
class Policy
{
Benefit Benefit {get;set;}
IList<Option> Options {get;set;}
//Factory
public static Policy CreateDefaultPolicy()
{
var retVal = new Policy();
retVal.Benefit = new DefaultBenefit();
retVal.Options =new List<Options> ();
retVal.Options.Add(DefaultLifeOption);
retVal.Options.Add(DefaultCarOption);
retun retVal;
}
}
class Benefit {}
class DefaultBenefit: Benefit {}
class Option{}
class DefaultLifeOption {}
class DefaultCarOption {}
Related Questions in OOP
- Access objects variable & method by name
- Why does compiler recognize while(true) at compile time but not if(true)
- Pass variables to extended class
- Cast a superclass type to a subclass type?
- Understanding difference in Swift properties for structs and classes in assignment
- Does exist any way to force child class to have at least one field with a specified attribute?
- Symfony : is it better to use a trait or an intermediary class to complete Controller one?
- (Java) What kind of argument is this? With a
- C++ Implementing a Queue of cars in OOP
- Inheritance in openERP (odoo)
- missing 1 required positional argument: 'key'
- how can Object class in ruby be an instance of it's subclass, class "Class"
- How to force others to obey a specific layout for a child class?
- Class variables in OOP
- define_method in a class method
Related Questions in MODEL
- How to create dynamic pages without form_for helper in Rails?
- How to get header and data from Models in Python?
- Sails JS - How to Work With Specific Model Attributes from the Associated Controller
- Django Models - How to relate a single class to several variants
- Custom validation message (in model file) that includes a path not working
- Access database with new pacakage in Laravel 4.2
- Rails 4 Attendance system
- How to pass a specific model field to views' functions or methods?
- same name component and model in cakePhp?
- Laravel 5 Eloquent belongsTo() foreign key won't work
- Custom accessors Eloquent Model
- Laravel 5.0.33 Illuminate\Database\Eloquent\Model not found in line 5
- Django override-able abstract field for inlineformset
- Symfony2 proper use for services
- Subclass of Django Model Not Accessible from Superclass
Related Questions in DOMAIN-DRIVEN-DESIGN
- Should i take DateTime.Now from Database?
- How to avoid anemic data model? Can repositories be injected into entities?
- Defining aggregate roots when invariants exist within a list
- Is it okay to create a DTO counterpart of a table in a database assuming its persistent ignorant domain model and the DTO is in the repository?
- Should i do authorization on my Domain Services?
- Should i validate if related entity exists before insert?
- Using framework event dispatcher to raise domain event
- How to temporarily circumvent domain object's creation contracts when restoring application from backup?
- Domain Driven Design for Rails App: Implementing a service in a basic example
- DDD\CQRS\Event Sourcing and request historical data
- Is it possible to properly use DDD with all building blocks in monolith application?
- Replicate property size from domain to fluent api and viewmodel
- DDD aware of existance of an entity outside the context?
- Is there a way to access a private property in a where clause?
- Should I unite business domains into one business layer
Related Questions in DECISION-TREE
- Kaggle Titanic: Machine Learning From Disaster Decision Tree for Cabin Prediction
- Complex conditional filter design
- training and testing image data with neural network tool in MATLAB
- What is the equivalent to rpart.plot in Python? I want to visualize the results of my random forest
- Can I manually create an RWeka decision (Recursive Partitioning) tree?
- What is causing this StackOverflowError?
- Why do I get this error below while using the Cubist package in R?
- create decision tree from data
- Scaling plots in the terminal nodes of ctree graph
- Saving decision tree's output into a text file
- Implement all possible questions on a node in Decision Tree in Sklearn?
- Decision Tree nltk
- How to implement decision trees in boosting
- scikit learn decision tree export graphviz - wrong class names in the decision tree
- Random forests performed under expectation
Related Questions in MDD
- about correct-by-construction incremental design processes
- Model based UI generaton (runtime or build time)
- Problem with adding a special github project (mdict-java) to android studio project
- Open Source Tools for MDA/MDD
- How much does Enterprise Architect support OCL language?
- Model-driven development: What is a transform?
- Android app using Acceleo
- How do you deal with "defaults" when doing DDD
- Model-based generation of project documentation
- I don't like MDD but like UML - why should I use MDD if I think it is useless ?
- Is implementing a code generator a sort of model driven design/ model driven software developement?
- Model class files code generation for Java, C# and Objective-C
- Best practice to call a Repository class method in another Controller-Service-Repository in Spring Boot?
- Installing VC++ 2010 doesn't fix dll loading problem
- MDD: How dynamic is MDD at runtime?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
This is not specific to DDD per se, you would normally implement this using a Factory to create your default aggregate root. As this behavior is business specific and probably subject to change, externalizing the responsibility for object creation to the factory is better than letting the aggregate root deal with this itself.