You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Brian LeRoux <b...@brian.io> on 2013/12/13 00:11:14 UTC
[Node 101] Part 2: Avoid the Triangle of Doom
Flatten your async code. New fashion advocates promises, generators,
events, or one of the streams apis.
The classic method is to write small testable modules (see part 1) and
flatten your tree.
Turn code that looks like this [1] into this [2].
[1]
https://github.com/apache/cordova-js/blob/b75096a1bade9ca6aa0d38a2039fd922ad7c1a95/test/runner.js#L99-L136
[2]
https://github.com/apache/cordova-js/blob/ced04a4ec71f144dd2cd6c2e9392e3b1fc725ec1/tasks/lib/test-browser.js
Re: [Node 101] Part 2: Avoid the Triangle of Doom
Posted by Marcel Kinard <cm...@gmail.com>.
I started a wiki page to capture these discussions for future contributors. https://wiki.apache.org/cordova/OneOhOneEducation
Re: [Node 101] Part 2: Avoid the Triangle of Doom
Posted by Anis KADRI <an...@gmail.com>.
+1. I am a noob to promises but I think the syntax is better (I don't like
deep nesting) and it makes flows easier to handle (which makes the async
concept easier).
Other than that I love these [Node 101]. We should share knowledge more
often!
On Thu, Dec 12, 2013 at 4:33 PM, Brian LeRoux <b...@brian.io> wrote:
> And yes promises are great. I find them to be more sugar than actual help
> but to each his own. Same practices apply.
>
>
> On Fri, Dec 13, 2013 at 11:32 AM, Brian LeRoux <b...@brian.io> wrote:
>
> > Sorry, lets see if I can make it more obvious.
> >
> > https://gist.github.com/brianleroux/7938149
> >
> >
> > On Fri, Dec 13, 2013 at 10:41 AM, Josh Soref <jsoref@blackberry.com
> >wrote:
> >
> >> Brian wrote:
> >> >Flatten your async code. New fashion advocates promises, generators,
> >> >events, or one of the streams apis.
> >>
> >> While flattening with promises is greatŠ
> >>
> >>
> >> >The classic method is to write small testable modules (see part 1) and
> >> >flatten your tree.
> >> >
> >> >Turn code that looks like this [1] into this [2].
> >>
> >> Š I can¹t figure out how your two example blobs relate.
> >>
> >> For the sake of people trying to learn patterns, can you please ensure
> >> that your [1] and [2] are obvious ³before² and ³after²?
> >>
> >> >[1]
> >> >
> >>
> https://github.com/apache/cordova-js/blob/b75096a1bade9ca6aa0d38a2039fd922
> >> >ad7c1a95/test/runner.js#L99-L136
> >> >[2]
> >> >
> >>
> https://github.com/apache/cordova-js/blob/ced04a4ec71f144dd2cd6c2e9392e3b1
> >> >fc725ec1/tasks/lib/test-browser.js
> >>
> >> ---------------------------------------------------------------------
> >> This transmission (including any attachments) may contain confidential
> >> information, privileged material (including material protected by the
> >> solicitor-client or other applicable privileges), or constitute
> non-public
> >> information. Any use of this information by anyone other than the
> intended
> >> recipient is prohibited. If you have received this transmission in
> error,
> >> please immediately reply to the sender and delete this information from
> >> your system. Use, dissemination, distribution, or reproduction of this
> >> transmission by unintended recipients is not authorized and may be
> unlawful.
> >>
> >>
> >
>
Re: [Node 101] Part 2: Avoid the Triangle of Doom
Posted by Brian LeRoux <b...@brian.io>.
And yes promises are great. I find them to be more sugar than actual help
but to each his own. Same practices apply.
On Fri, Dec 13, 2013 at 11:32 AM, Brian LeRoux <b...@brian.io> wrote:
> Sorry, lets see if I can make it more obvious.
>
> https://gist.github.com/brianleroux/7938149
>
>
> On Fri, Dec 13, 2013 at 10:41 AM, Josh Soref <js...@blackberry.com>wrote:
>
>> Brian wrote:
>> >Flatten your async code. New fashion advocates promises, generators,
>> >events, or one of the streams apis.
>>
>> While flattening with promises is greatŠ
>>
>>
>> >The classic method is to write small testable modules (see part 1) and
>> >flatten your tree.
>> >
>> >Turn code that looks like this [1] into this [2].
>>
>> Š I can¹t figure out how your two example blobs relate.
>>
>> For the sake of people trying to learn patterns, can you please ensure
>> that your [1] and [2] are obvious ³before² and ³after²?
>>
>> >[1]
>> >
>> https://github.com/apache/cordova-js/blob/b75096a1bade9ca6aa0d38a2039fd922
>> >ad7c1a95/test/runner.js#L99-L136
>> >[2]
>> >
>> https://github.com/apache/cordova-js/blob/ced04a4ec71f144dd2cd6c2e9392e3b1
>> >fc725ec1/tasks/lib/test-browser.js
>>
>> ---------------------------------------------------------------------
>> This transmission (including any attachments) may contain confidential
>> information, privileged material (including material protected by the
>> solicitor-client or other applicable privileges), or constitute non-public
>> information. Any use of this information by anyone other than the intended
>> recipient is prohibited. If you have received this transmission in error,
>> please immediately reply to the sender and delete this information from
>> your system. Use, dissemination, distribution, or reproduction of this
>> transmission by unintended recipients is not authorized and may be unlawful.
>>
>>
>
Re: [Node 101] Part 2: Avoid the Triangle of Doom
Posted by Brian LeRoux <b...@brian.io>.
Sorry, lets see if I can make it more obvious.
https://gist.github.com/brianleroux/7938149
On Fri, Dec 13, 2013 at 10:41 AM, Josh Soref <js...@blackberry.com> wrote:
> Brian wrote:
> >Flatten your async code. New fashion advocates promises, generators,
> >events, or one of the streams apis.
>
> While flattening with promises is greatŠ
>
>
> >The classic method is to write small testable modules (see part 1) and
> >flatten your tree.
> >
> >Turn code that looks like this [1] into this [2].
>
> Š I can¹t figure out how your two example blobs relate.
>
> For the sake of people trying to learn patterns, can you please ensure
> that your [1] and [2] are obvious ³before² and ³after²?
>
> >[1]
> >
> https://github.com/apache/cordova-js/blob/b75096a1bade9ca6aa0d38a2039fd922
> >ad7c1a95/test/runner.js#L99-L136
> >[2]
> >
> https://github.com/apache/cordova-js/blob/ced04a4ec71f144dd2cd6c2e9392e3b1
> >fc725ec1/tasks/lib/test-browser.js
>
> ---------------------------------------------------------------------
> This transmission (including any attachments) may contain confidential
> information, privileged material (including material protected by the
> solicitor-client or other applicable privileges), or constitute non-public
> information. Any use of this information by anyone other than the intended
> recipient is prohibited. If you have received this transmission in error,
> please immediately reply to the sender and delete this information from
> your system. Use, dissemination, distribution, or reproduction of this
> transmission by unintended recipients is not authorized and may be unlawful.
>
>
Re: [Node 101] Part 2: Avoid the Triangle of Doom
Posted by Josh Soref <js...@blackberry.com>.
Brian wrote:
>Flatten your async code. New fashion advocates promises, generators,
>events, or one of the streams apis.
While flattening with promises is greatŠ
>The classic method is to write small testable modules (see part 1) and
>flatten your tree.
>
>Turn code that looks like this [1] into this [2].
Š I can¹t figure out how your two example blobs relate.
For the sake of people trying to learn patterns, can you please ensure
that your [1] and [2] are obvious ³before² and ³after²?
>[1]
>https://github.com/apache/cordova-js/blob/b75096a1bade9ca6aa0d38a2039fd922
>ad7c1a95/test/runner.js#L99-L136
>[2]
>https://github.com/apache/cordova-js/blob/ced04a4ec71f144dd2cd6c2e9392e3b1
>fc725ec1/tasks/lib/test-browser.js
---------------------------------------------------------------------
This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.