(Map|Set|WeakMap)#set() returns `this` ?

Mark S. Miller erights at google.com
Thu Dec 6 07:34:48 PST 2012


On Wed, Dec 5, 2012 at 8:05 PM, Rick Waldron <waldron.rick at gmail.com> wrote:
>
>
>
> On Wed, Dec 5, 2012 at 10:33 PM, Bill Frantz <frantz at pwpconsult.com> wrote:
>>
>> On 12/5/12 at 1:50 AM, jussi.kalliokoski at gmail.com (Jussi Kalliokoski)
>> wrote:
>>
>>> I personally think returning `this` in absence of any meaningful value
>>> (and
>>> chaining in general) is a bad pattern.
>>
>>
>> </lurk>
>>
>> I have to agree with Jussi here. Whenever I consider chaining using the
>> returned values from the various things called, my programming paranoia hair
>> stands on end. Let me try to explain:
>>
>> Whenever I program, I try to trust as little code as possible. With
>> chaining, there are two possibilities for getting the wrong answer in the
>> returned value:
>>
>>   * I or someone else wrote it, but screwed up,
>>   * Someone hostile wrote it and is trying to trip me up.
>>
>> If there is a language construct that allows chaining -- like the Pascal
>> "with" construct -- then I am only trusting the language*, not other
>> fragments of programs. If I depend on things I call returning the correct
>> "this", then I am depending on them and my dependency set is a lot larger. A
>> larger dependency set makes me nervous.
>>
>> Cheers - Bill
>>
>> * For the really paranoid, minimizing the parts of the language depended
>> on is important. Not all JS implementations behave the same way in the
>> corner cases.
>
>
> Again, I reject the notion that "someone might screw up" is a valid argument
> for this, or any, discussion. It's one thing to be aware of the potential
> for misuse, but entirely another to succumb to "fear driven design".

Is "fear driven design" just a derogatory phrase for "defensive programming"?


>
> Rick
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



--
    Cheers,
    --MarkM


More information about the es-discuss mailing list