Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Factories in Presenters in a Model View Presenter and Domain Driven Design Project
    text
    copied!<p>In domain driven design, it appears to be a good practice to use Factories to create your domain objects in your domain layer (as opposed to using a direct constructor or IoC). </p> <p>But what about using the domain object factories in a presenter layer. For instance, say that I was creating a domain object from user input obtained from the presenter. </p> <p>Here's an example, say I have a Configuration domain object that has a number of decimal settings.</p> <p>public class Configuration : PersistantObject {</p> <pre><code> public decimal temperature {get;set;} ...(times 20) public decimal gravity {get;set;} </code></pre> <p>}</p> <p>In order to create this object in the domain layer, rather than the presenter layer, I would have to pass each of these decimal values as function parameters. Creating an unwieldy function definition and call.</p> <p>ie ConfigurationService.CreateConfiguration(temperature, ...(x20), gravity);</p> <p>The perhaps better solution would be to create the Configuration object in the presenter layer, and assign all the values of the configuration object directly from the user input, skipping a lengthy function call.</p> <p>Configuration config = ConfigurationFactory.CreateNewConfiguration();</p> <p>config.temperature = temperature;</p> <p>..(x20).. = ...;</p> <p>config.gravity = gravity;</p> <p>ConfigurationService.SaveNewConfiguration(config);</p> <p>But I'm wondering if this approach is wrong and why? If both of these approaches are wrong, what is the best approach for creating a lengthy object from user input and why?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload