Re: Thoughts and questions about data mapping and DDD in general

"[email protected] [domaindrivendesign]" <[email protected]> 28 Apr 2017 16:23:05 +0000
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <[email protected]>
--9nlWnTS9ocNmxdhsK3FKVLWiM6a5jwOaA8HvrLV
Content-Transfer-Encoding: base64
Content-Type: text/plain; charset="UTF-8"

SGkgUGVkcm8sDQogSSBsb3ZlZCB0aGUgd2F5IHlvdSBleHBsYWluZWQgZXZlcnkgc3RlcHMuIA0K
IEkgYWxzbyBwcmFjdGljZSBEREQgYW5kIGluIG15IHByb2plY3Qgd2UgZGlkIGFsbCBvZiB0aGUg
YWJvdmUgc3RlcHMgZXhhY3RseSB5b3Ugc2FpZC4NCiANCg0KIEhvd2V2ZXIgd2UgZG8gMiB0aGlu
Z3MgZGlmZmVyZW50LiANCiANCg0KIDEpIEhvdyB3ZSBzYXZlIGRvbWFpbiBvYmplY3RzDQogSW4g
b3JkZXIgdG8gc2F2ZSBkb21haW4gbW9kZWxzIHdlIGRvIG5vdCBjb252ZXJ0IGl0IGluIHNvbWUg
b3RoZXIgZHRvLiANCiBXZSBqdXN0IHNhdmUgdGhlIERvbWFpbiBNb2RlbCBhcyBpdCBpcy4gV2Ug
dXNlIEVudGl0eSBGcmFtZXdvcmsgYW5kIGl0IHN1cHBvcnRzIENvZGUgRmlyc3QgdGhhdCBpcyB3
aGF0IHdlIHVzZS4gT3VyIFJlcG9zaXRvcnkgaW1wbGVtZW50YXRpb24gaW4gdGhlIEluZnJhc3Ry
dWN0dXJlIGRpcmVjdGx5IHNhdmVzIEVudGl0eSAoIEFnZ3JlZ2F0ZSBSb290ICkgaW4gRGF0YWJh
c2UuDQogVGhlcmVmb3JlLCB3ZSBkbyBub3QgbmVlZCBtYXBwZXIgaGVyZS4NCiANCg0KIDIpIEhv
dyB3ZSBtYXAgZG9tYWluIG9iamVjdCB0byBVSSBkdG9zDQogSW4gb3VyIGFwcGxpY2F0aW9uIGxh
eWVyIGl0c2VsZiB3ZSBoYXZlIGNsYXNzIGNhbGxlZCBhcyBBc3NlbWJsZXIgYW5kIHRoYXQgY2xh
c3MgYmFzaWNhbGx5IGNvbnZlcnRzIE1vZGVsIFRvIERUTyBhbmQgRFRPIHRvIE1vZGVsLiANCiBG
b3IgZXhhbXBsZSBpZiBJIGhhdmUgT3JkZXIgQWdncmVnYXRlIFJvb3QgVGhlbiBJIGhhdmUgT3Jk
ZXIgRm9sZGVyIGluIEFwcGxpY2F0aW9uIFNlcnZpY2UgTGF5ZXIuIE9yZGVyIEZvbGRlciBoYXMg
T3JkZXJBcHBTZXJ2aWNlLmNzIGFuZCBPcmRlckFzc2VtYmxlci5jcy4gDQogT3JkZXJBcHBTZXJ2
aWNlIHRha2VzIGRlcGVuZGVuY3kgb2YgT3JkZXJBc3NlbWJsZXIgYW5kIGNhbGxzIE1hcFRvRHRv
IG1ldGhvZCBieSBnaXZpbmcgZG9tYWluIGVudGl0eS4gQmFzaWNhbGx5IHdlIGhhdmUgb3VyIG1h
cHBlciBpbiBBcHBsaWNhdGlvbiBsYXllciBpdHNlbGYuIA0KIA0KDQogSG9wZSB0aGlzIGhlbHBz
IQ0KIA0KDQo=


--9nlWnTS9ocNmxdhsK3FKVLWiM6a5jwOaA8HvrLV
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit





<head>

<style type="text/css">
<!--

/* start of attachment style */
       .ygrp-photo-title{
         clear: both;
         font-size: smaller;
         height: 15px;
         overflow: hidden;
         text-align: center;
         width: 75px;
       }
       div.ygrp-photo{
         background-position: center;
         background-repeat: no-repeat;
         background-color: white;
         border: 1px solid black;
         height: 62px;
         width: 62px;
       }

       div.photo-title 
         a,
         div.photo-title a:active,
         div.photo-title a:hover,
         div.photo-title a:visited {
           text-decoration: none; 
       }

       div.attach-table div.attach-row {
         clear: both;
       }

       div.attach-table div.attach-row div {
         float: left;
         /* margin: 2px;*/
       }

       p {
         clear: both;
         padding: 15px 0 3px 0;
	 overflow: hidden;
       }

       div.ygrp-file {
         width: 30px;
         valign: middle;
       }
       div.attach-table div.attach-row div div a {
         text-decoration: none;
       }

       div.attach-table div.attach-row div div span {
         font-weight: normal;
       }

       div.ygrp-file-title {
         font-weight: bold;
       }
 /* end of attachment style */
        -->
        </style>
        </head>
<html>
<head>
<style type="text/css">
<!--
#ygrp-mkp {
  border: 1px solid #d8d8d8;
  font-family: Arial;
  margin: 10px 0;
  padding: 0 10px;
}

#ygrp-mkp hr {
  border: 1px solid #d8d8d8;
}

#ygrp-mkp #hd {
  color: #628c2a;
  font-size: 85%;
  font-weight: 700;
  line-height: 122%;
  margin: 10px 0;
}

#ygrp-mkp #ads {
  margin-bottom: 10px;
}

#ygrp-mkp .ad {
  padding: 0 0;
}

#ygrp-mkp .ad p {
  margin: 0;
}

#ygrp-mkp .ad a {
  color: #0000ff;
  text-decoration: none;
}
-->
</style>
</head>
<body>



<!-- |**|begin egp html banner|**| -->

<br><br>

<!-- |**|end egp html banner|**| -->


<div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">Hi Pedro,</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">I loved the way you explained every steps.&nbsp;</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">I also practice&nbsp;<span class="il">DDD</span>&nbsp;and in my project we did all of the above steps exactly you said.</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;"><br></div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">However we do 2 things different.&nbsp;</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;"><br></div><div class="gmail_default" style="fon
 t-family:verdana, sans-serif;font-size:small;"><b>1) How we save domain objects</b></div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">In order to save domain models we do not convert it in some other dto.&nbsp;</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">We just save the Domain Model as it is. We use Entity Framework and it supports Code First that is what we use. Our Repository implementation in the Infrastructure directly saves Entity ( Aggregate Root ) in Database.</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">Therefore, we do not need mapper here.</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;"><br></div><div class="gm
 ail_default" style="font-family:verdana, sans-serif;font-size:small;"><b>2) How we map domain object to UI dtos</b></div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">In our application layer itself we have class called as Assembler and that class basically converts Model To DTO and DTO to Model.&nbsp;</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">For example if I have Order Aggregate Root Then I have Order Folder in Application Service Layer. Order Folder has OrderAppService.cs and OrderAssembler.cs.&nbsp;</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">OrderAppService takes dependency of OrderAssembler and calls MapToDto method by giving domain entity. Basically we 
 have our mapper in Application layer itself.&nbsp;</div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;"><br></div><div class="gmail_default" style="font-family:verdana, sans-serif;font-size:small;">Hope this helps!</div><div><br></div>



<!-- |**|begin egp html banner|**| -->

<br>


<br>

<!-- |**|end egp html banner|**| -->


<div width="1" style="color: white; clear: both;"/>__._,_.___</div>

      
  

    
    <div id="fromDMARC" style="clear:both; margin-top: 10px;">
         <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
         Posted by: [email protected]         <hr style="height:2px ; border-width:0; color:#E3E3E3; background-color:#E3E3E3;">
    </div>
<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

  <img src="http://geo.yahoo.com/serv?s=97476590/grpId=8116923/grpspId=1705007181/msgId=24820/stime=1494000670" width="1" height="1"> <br>

<!-- |**|end egp html banner|**| -->

  
<!-- |**|begin egp html banner|**| -->

<br>



   
     
 
        <!-- |**|begin egp html banner|**| -->
        <div id="ygrp-vital" style="background-color: #f2f2f2; font-family: Verdana; font-size: 10px; margin-bottom: 10px; padding: 10px;">

        <span id="vithd" style="font-weight: bold; color: #333; text-transform: uppercase; "><a href="https://groups.yahoo.com/neo/groups/domaindrivendesign/info;_ylc=X3oDMTJlODF0a2o1BF9TAzk3MzU5NzE0BGdycElkAzgxMTY5MjMEZ3Jwc3BJZAMxNzA1MDA3MTgxBHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQ5NDAwMDY3MA--" style="text-decoration: none;">Visit Your Group</a></span>

     <ul style="list-style-type: none; margin: 0; padding: 0; display: inline;">
            <li style="border-right: 1px solid #000; font-weight: 700; display: inline; padding: 0 5px; margin-left: 0;">
      <span class="cat"><a href="https://groups.yahoo.com/neo/groups/domaindrivendesign/members/all;_ylc=X3oDMTJmOTBzbWFyBF9TAzk3MzU5NzE0BGdycElkAzgxMTY5MjMEZ3Jwc3BJZAMxNzA1MDA3MTgxBHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0OTQwMDA2NzA-" style="text-decoration: none;">New Members</a></span>
      <span class="ct" style="color: #ff7900;">3</span>
    </li>
                                              </ul>
  </div>


<div id="ft" style="font-family: Arial; font-size: 11px; margin-top: 5px; padding: 0 2px 0 0; clear: both;">
  <a href="https://groups.yahoo.com/neo;_ylc=X3oDMTJkM3MxdTg2BF9TAzk3NDc2NTkwBGdycElkAzgxMTY5MjMEZ3Jwc3BJZAMxNzA1MDA3MTgxBHNlYwNmdHIEc2xrA2dmcARzdGltZQMxNDk0MDAwNjcw" style="float: left;"><img src="http://l.yimg.com/ru/static/images/yg/img/email/new_logo/logo-groups-137x15.png" height="15" width="137" alt="Yahoo! Groups" style="border: 0;"/></a>
  <div style="color: #747575; float: right;"> &bull; <a href="https://info.yahoo.com/privacy/us/yahoo/groups/details.html" style="text-decoration: none;">Privacy</a> &bull; <a href="mailto:[email protected]?subject=Unsubscribe" style="text-decoration: none;">Unsubscribe</a> &bull; <a href="https://info.yahoo.com/legal/us/yahoo/utos/terms/" style="text-decoration: none;">Terms of Use</a> </div>
</div>

<!-- |**|end egp html banner|**| -->

  </div> <!-- ygrp-msg -->

   


  <br>

<!-- |**|end egp html banner|**| -->


<div style="color: white; clear: both;"/>__,_._,___</div>
</body>

</html>

--9nlWnTS9ocNmxdhsK3FKVLWiM6a5jwOaA8HvrLV--