Talks

Summarized using AI

A model walks into a JavaScript framework

Tony Navarre • October 26, 2012 • Earth

In the talk titled "A model walks into a JavaScript framework," Anthony Navarre discusses the limitations of conventional JavaScript MVC frameworks and emphasizes the need for developers to rethink their approach to front-end development. He highlights the common challenge that many developers face, particularly when transitioning from back-end development—where they may be more comfortable—into the complexities of JavaScript's asynchronous and event-driven nature.

Key Points:
- Industry Comfort Zones: Navarre notes that developers often get trapped in a binary thinking of either models or views, limiting their ability to explore more effective design patterns.
- Discomfort with JavaScript: He expresses that his unease with JavaScript stems from its significant differences compared to Ruby, particularly concerning unpredictable variables and how functions are treated as first-class citizens, leading to complex callback chains.
- Nesting Callbacks: He points out the risks involved with nested callbacks, and he encourages developers to acknowledge when they might be encountering exceptions as a result.
- Need for Different Patterns: The speaker urges developers to embrace and learn from patterns outside their immediate experience, particularly those from Objective-C frameworks like CoCo, which have proven to be effective in managing complexity in MVC applications.
- Examples of Other Patterns: While specific examples are not detailed in his talk, he mentions that delegation is one such pattern that could greatly enhance manageability in JavaScript code.
- Conclusion: Navarre concludes by calling for a broader exploration of patterns, especially from Objective-C, imbuing JavaScript development with improved methodologies that could lead to more robust, maintainable code without falling back into old habits.

In essence, Navarre advocates for expanding the collective understanding of design patterns in front-end development, stressing that innovations in one programming environment can lead to significant advancements in another. It is a call to action for JavaScript developers to break free from traditional constraints and elevate their coding practices.

A model walks into a JavaScript framework
Tony Navarre • October 26, 2012 • Earth

Help us caption & translate this video!

http://amara.org/v/FGgL/

Rocky Mountain Ruby 2012

00:00:05.960 So, a model walks into a JavaScript framework. The controller says, 'What are you having?' The model replies, 'You tell me.'
00:00:16.080 Uh, I'm Anthony Navarre. I work at Factory Design Labs, and I have a bone to pick with JavaScript MVC frameworks. Well, that's not quite right. I don't have a bone to pick with JavaScript MVC frameworks specifically, but rather with the way we, as an industry, have pigeonholed ourselves into thinking everything is either a model or a view. We need to stop this notion. I think that, on the whole, many of us in this room understand that we need to explore other patterns.
00:01:05.280 However, there's a problem. We're very comfortable in the back end; at least I am when writing JavaScript. I'm much more comfortable in the back end than on the front end. I believe part of this discomfort stems from the fact that JavaScript is quite different from Ruby—we deal with asynchronous operations and event-driven paradigms that are less common in Ruby.
00:01:17.560 JavaScript has unpredictable variables, especially when it comes to dealing with users. I won’t delve too deeply into that for now, but I should also mention that one of the key differences is how functions are treated as first-class citizens in JavaScript, allowing us to pass them around more freely. There's something troubling about my discomfort with that, leading me to often write bad JavaScript.
00:01:37.840 I find myself in situations where I have callbacks nested inside other callbacks. By the way, does anyone know what happens when you encounter an error in such a situation? That's called an exception. I fully acknowledge my fault in this. I believe the overarching reason many of us fall into this trap is that we don’t know which patterns to reach for, as the patterns that apply to front-end development aren't necessarily applicable to back-end development.
00:02:21.760 I propose that we examine more of what's learned from Objective-C frameworks like CoCo. It's a battle-tested MVC framework for iPhone development and has built-in patterns that complement MVC. Although I don’t know too much about it myself, it’s worthwhile to consider how we can apply these patterns from Objective-C to our JavaScript development.
00:02:59.920 There are numerous patterns on the front end that can enhance our work in JavaScript. I won’t go over all of them here, but a few that come to mind are definitely relevant. For example, delegation: you get an object to act as the delegate for another object. The first talk this morning provided a perfect illustration of pushing responsibility to another object.
00:03:47.879 I believe we should leverage more patterns from Objective-C. While I won’t provide any specific examples after this talk, I think it’s crucial that we begin exploring these ideas to enhance our JavaScript code. Thank you very much.
Explore all talks recorded at Rocky Mountain Ruby 2012
+12