Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think, when chaining is used to access some property, it is done in two (or at least two) different situation. One is the case that you have mentioned, for example, in your presentation module, you have an <strong>Order</strong> object and you would like to just display the owner's/user's address, or details like city. In that case, I think it is of not much problem if you do so. Why? Because you are not performing any <strong>business logic</strong> on the accessed property, which can (potentially) cause tight coupling. </p> <p>But, things are different if you use such chaining for the purpose of performing some logic on the accessed property. For example, if you have, </p> <pre><code>String city = order.user.address.city; ... order.user.address.city = "New York"; </code></pre> <p>This is problematic. Because, this logic is/should more appropriately be performed in a module closer to the target attribute - city. Like, in a place where the Address object is constructed in the first place, or if not that, at least when the User object is constructed (if say User is the entity and address the value type). But, if it goes farther than that, the farther it goes, the more illogical and problematic it becomes. Because there are too many intermediaries are involved between the source and the target.</p> <p>Thus, according to the the Law of Demeter, if you are performing some logic on the "city" attribute in a class, say <strong>OrderAssmebler</strong>, which accesses the city attribute in a chain like order.user.address.city, then you should think of moving this logic to a place/module closer to the target.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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