Re: Implementation for Deleting Entities from an Aggregate

"Jose Fernandez [email protected] [domaindrivendesign]" <[email protected]> Tue, 6 Sep 2016 19:02:15 -0400
Newsgroups gmane.comp.programming.domain-driven-design
Message-ID <[email protected]>
--Apple-Mail-DDF458FB-EE2B-463A-818D-616FE29A272B
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

In my own experience, 95% of my "entities" are AR. There are really few cas=
es where you need to have an entity as part of the Aggregate that is not an=
 AR per se. As a rule of thumb I create always AR. Then I start seeing case=
s where I know I won't be manipulating an entity directly (crud operations)=
. Only then I start refactoring to make them an entity of an aggregate.=20

Don't fall in the AR -> Entity -> VO trap. No all aggregates need the combi=
nation of these three in order to be "good DDD".  Most of my aggregates are=
 a single AR with some VO (Telephone for example). You normally want to cre=
ate a VO to encapsulate all of the validation and parsing, etc., but only p=
ersist the number. Then you can use Telephone within your Customer AR and O=
ffice AR, etc.=20

Also if your aggregate has more than 3 entities... It's about time for you =
to refactor. Smelly smelly.=20

Sent from my iPhone

> On Sep 6, 2016, at 12:30 PM, Caleb Cushing [email protected] [domai=
ndrivendesign] <[email protected]> wrote:
>=20
> given mongodb is a document database, you may not want to try removing su=
b entities in such a way. You, imho, need to persist the aggregate as a who=
le. If you want to persist these sub entities separately, perhaps make them=
 a separate aggregate. Repositories generally have aggregates persistested =
as a whole anyways, regardless of storage type, it's a good way to know whe=
n you have an aggregate.
>=20
>> On Tue, Sep 6, 2016 at 11:15 AM [email protected] [domaindrivendes=
ign] <[email protected]> wrote:
>>=20
>>=20
>> I have toyed with the idea of doing that, when refining my aggregates.  =
The one thing that keeps steering me away from this is that the concept of =
comments really doesn't make any sense outside of the posts that they annot=
ate.  As I expect the requirements to continue to change over time, though,=
 I have not ruled it out.
>>=20
>> Thank you!
>>=20
>>=20
>=20
> --=20
> Caleb Cushing
>=20
> http://xenoterracide.com
>=20

--Apple-Mail-DDF458FB-EE2B-463A-818D-616FE29A272B
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><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">


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

<br><br>

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


<div>In my own experience, 95% of my "entities" are AR. There are really few cases where you need to have an entity as part of the Aggregate that is not an AR per se. As a rule of thumb I create always AR. Then I start seeing cases where I know I won't be manipulating an entity directly (crud operations). Only then I start refactoring to make them an entity of an aggregate.&nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Don't fall in the AR -&gt; Entity -&gt; VO trap. No all aggregates need the combination of these three in order to be "good DDD". &nbsp;Most of my aggregates are a single AR with some VO (Telephone for example). You normally want to create a VO to encapsulate all of the validation and parsing, etc., but only persist the number. Then you can u
 se Telephone within your Customer AR and Office AR, etc.&nbsp;</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Also if your aggregate has more than 3 entities... It's about time for you to refactor. Smelly smelly.&nbsp;<br><br>Sent from my iPhone</div><div><br>On Sep 6, 2016, at 12:30 PM, Caleb Cushing <a href="mailto:[email protected]">[email protected]</a> [domaindrivendesign] &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>












 

<span style="display:none">&nbsp;</span>



    <div id="ygrp-text">
      
      
      <p></p><div dir="ltr">given mongodb is a document database, you may not want to try removing sub entities in such a way. You, imho, need to persist the aggregate as a whole. If you want to persist these sub entities separately, perhaps make them a separate aggregate. Repositories generally have aggregates persistested as a whole anyways, regardless of storage type, it's a good way to know when you have an aggregate.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 6, 2016 at 11:15 AM <a href="mailto:[email protected]">[email protected]</a> [domaindrivendesign] &lt;<a href="mailto:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="border-left:1px #ccc solid;">






        




<div>





<br><br>




I have toyed with the idea of doing that, when refining my aggregates.&nbsp; The one thing that keeps steering me away from this is that the concept of comments really doesn't make any sense outside of the posts that they annotate.&nbsp; As I expect the requirements to continue to change over time, though, I have not ruled it out.<div><br></div><div>Thank you!</div>





<br>


<br>




<div width="1" style="color:white;"></div>



</div></blockquote></div><div dir="ltr">-- <br></div><div data="gmail_signature"><div dir="ltr">Caleb Cushing<div><br></div><div><a href="http://xenoterracide.com">http://xenoterracide.com</a></div></div></div>
<p></p>

    </div>
     

    





<!-- end group email -->

</div></blockquote>



<!-- |**|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: Jose Fernandez &lt;[email protected]&gt;         <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=24812/stime=1473202938" 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=X3oDMTJlc3Bmb2tsBF9TAzk3MzU5NzE0BGdycElkAzgxMTY5MjMEZ3Jwc3BJZAMxNzA1MDA3MTgxBHNlYwN2dGwEc2xrA3ZnaHAEc3RpbWUDMTQ3MzIwMjkzOA--" 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=X3oDMTJmYnBwZHRxBF9TAzk3MzU5NzE0BGdycElkAzgxMTY5MjMEZ3Jwc3BJZAMxNzA1MDA3MTgxBHNlYwN2dGwEc2xrA3ZtYnJzBHN0aW1lAzE0NzMyMDI5Mzg-" style="text-decoration: none;">New Members</a></span>
      <span class="ct" style="color: #ff7900;">4</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=X3oDMTJkNWtqaHIxBF9TAzk3NDc2NTkwBGdycElkAzgxMTY5MjMEZ3Jwc3BJZAMxNzA1MDA3MTgxBHNlYwNmdHIEc2xrA2dmcARzdGltZQMxNDczMjAyOTM4" 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>
--Apple-Mail-DDF458FB-EE2B-463A-818D-616FE29A272B--