panthomakos
Engineering Interviewing at Strava
A Brief History of Jams at Strava
How Strava Merges Code (Butler Merge Queue)
(Ruby/Rails) Benchmark Your Bundle
Overwriting Console Output in Ruby
Rails - Respect the Active Record
Understanding the Law of Demeter
Clarifying The Ruby GIL
A Simple Rails Boot Time Improvement
The & Operator in Ruby
Courteous Meta-Programming in Ruby
Object Oriented Ruby and Rails in the Complex World of Gems
Using Rails Observers to write Faster Tests and Simpler Models
Dynamic Rescue Clause in Ruby
New Version of Sham Ruby Gem
After_create bug in Rails 3
Re:Avoiding Nested Callbacks in JavaScript
on Thursday June 30, 2011 @02:18PM (#2715130)
You make a good point and thanks for the performance link. I should have been more clear. The first and third examples are only comprable in the way they create closures - which is equivalent, but they are meant to demonstrate different things. The first demonstrates nested callbacks while the last example demonstrates named functions that are organized by closures.
Re:Avoiding Nested Callbacks in JavaScript
on Thursday June 30, 2011 @01:59PM (#2715059)
Absolutely - the code can be re-factored - but your example doesn't demonstrate that you can used named functions/callbacks within closures to further organize code.
Re:Avoiding Nested Callbacks in JavaScript
on Thursday June 30, 2011 @01:45PM (#2715012)
I think you make good points. The reason I used these simple examples was only for simplicity and to illustrate that named function callbacks can be used within closures rather than littering your global space with function declarations. More complex examples would probably have taken away from the core point of the article.
Re:Avoiding Nested Callbacks in JavaScript
on Thursday June 30, 2011 @01:37PM (#2714965)
The closures aren't meant to be more performant, they simply allow you to separate your code. It's not fair to compare the unnamed function example with the closure example, since the first doesn't create closures. If it did - which would be necessary to create both functions - the examples would be equally performant.
Re:Avoiding Nested Callbacks in JavaScript
on Thursday June 30, 2011 @01:35PM (#2714950)
But this is happening anyways with unnamed functions - they will be defined any time the top level function is called. The difference is really just whether or not you are naming your functions.