[erlang-questions] If you are homesick for object.selector

Evan Miller <>
Mon Jan 28 17:16:07 CET 2013


On Mon, Jan 28, 2013 at 7:18 AM, Robert Virding
<> wrote:
> There was an even better one mentioned in the test:
>
> if(hasrating)
> {
>     thechkbox = currRating[0].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.children(2).children(0).children(0)
>     thechkbox.disabled = false;
> }
>
> :-)
>

>From my understanding of the Law of Demeter, a proper rewrite would look like:

if (hasrating)
{
   thechkbox = currRating[0].firstChildOfFirstChildOfThirdChildOfParentOfParentOfParentOfParentOfParentOfParent();
   thechkbox.disabled = false;
}

--
Evan Miller
http://www.evanmiller.org/



More information about the erlang-questions mailing list