- Addy Osmani (twitter github website)
- Charles Max Wood (twitter github Teach Me To Code Rails Summer Camp)
- Jamison Dance (twitter github blog)
- Joachim Larsen (g+ github website)
- Design Patterns
- Christopher Alexander
- Gang of Four
- The Pragmatic Programmers
- MVC (Model View Controller)
- MVVM (Model View ViewModel)
- Active Views
- Mustache templates
- Allows you to separate concerns across the team. (Designers on HTML/View and Developers on Models and ViewModels)
- Data Bindings
- Moo tools
- MVP (Model View Presenter)
- Observer Pattern
- ECMAScript Harmony
- Prismatic (Jamison)
- Vim-coffee-script (Jamison)
- Coders at Work (Jamison)
- Udacity (Jamison)
- plos1 (Joachim)
- Amazon Prime (Chuck)
- Eye Dropper Tool (Chuck)
- LastPass (Chuck)
- Idiomatic.js by Rick Waldron (Addy)
- Pulley (Addy)
- Code Painter (Addy)
- Steve Jobs: One Last Thing (AJ)
- Pirates of Silicon Valley (AJ)
CHUCK: All right. So, should I kick the show off?
JAMISON: Let’s do it.
ADDY: Let’s go for it then.
CHUCK: All right. What episode number are we on? See, I got to open up the show notes. Shows you how awake I am.
JAMISON: Twelve, I think.
CHUCK: That sounds right to me.
JAMISON: [Chuckles] Chuck, you sound like way more tired than you did 30 seconds…
ADDY: I’m going to get coffee. One second.
JAMISON: I think you are actively falling asleep right now.
ADDY: We are roughly around episode… or something.
CHUCK: [Chuckles] Yeah. We’ve done about a dozen.
ADDY: Welcome to episode… your guess is as good as ours.
JAMISON: Howdy, howdy.
CHUCK: We also have Joachim Larsen.
JAMISON: Hey, it’s me with the dogs.
CHUCK: AJ O’Neal is in the chat right now, so he’ll probably just tell us important and happy things in the chat and we’ll voice for him. We also have a special guess, and that is Addy Osmani.
ADDY: Hi. I have no dogs.
CHUCK: [Chuckles] And I’m Charles Max Wood from…
JOACHIM: You can have one of mine.
CHUCK: All right. Yeah we love those projects – jQuery Modernizr.
JOACHIM: jQuery rules!
CHUCK: Yeah Joachim was telling us how much he loves jQuery. Anyway, so were having discussions before the show and I think it’s interesting to talk about before we jump in on design patterns; we were talking about TodoMVC. Is that what it’s called?
ADDY: Yeah that’s what it’s called.
CHUCK: You wanna just explain what that is and why you did it?
So I thought, “Why not create a project that has the exact same solution in every single one of these frameworks?” So how does solution x try to structure models and views and controllers and what other bits and pieces it might have? And I just want to make it really easy for developers to you know, get a feel for what a framework was like before they went and explored it further. So you know, maybe you will take a look at 10 frameworks, maybe you will take a look at 5 and you will just find 2 that you really like and just go see if it’s a good fit for your project — that’s the essence of what TodoMVC is all about.
CHUCK: All right. Cool. And I think it was Joachim that pointed out that not all of the frameworks really compare in the same way, feature to feature and whatever. So, what’s kind of your take on that because you know, you look at some and they have different capabilities than others?
ADDY: Absolutely and that’s the challenge that we are trying to solve for the past while. I mean, in our upcoming releases, we are trying our best to sort of make each implementation as consistent as possible so that the developers has a fair view of what they can do with the framework versus how much extra effort they might have to go to get it, as good as something a little bit more mainstream for example.
But we realize that it’s really, really difficult getting a baseline application to help you compare 20 or 30 different frameworks. And one way that we are going to try addressing that is by coming up with a bunch of end-to-end applications. So you know, a complete application built with Backbone or Ember or CanJS or any of the others, so the developers can get a really good feel for how all the other little parts involved in building an application are solved by that framework. And we are going to try documenting that as much as we can and then hopefully, that will give developers an even better way of making their minds up about what to use.
JAMISON: Wait, wait, wait so you are saying that you didn’t build the TodoMVC stuff because you had a lot of to-do things?
ADDY: Absolutely. I woke up one day and I thought, “Well, why don’t I have an application in 20 different frameworks for each of the different aspects of my life?” I need to remind myself that.
JAMISON: Yeah it seems like it really helps you organize.
CHUCK: Yeah you finished reading Getting Things Done and you said…
CHUCK: …”I need to do some to-do applications.”
Now pattern address a ton of things; like developers are going to go into projects and wonder, “Well, what’s the best way for me to separate concerns,” and “What’s the best way for me to offer simple APIs that are easy for people to consume, but which will still allow me to be complex behind the scenes if I need to,” or “How do I decouple my application so that each part of it doesn’t have to directly speak to another part?” And patterns help us with all of these things.
CHUCK: Yeah. Absolutely. And were they first originated with the book The Gang of Four or is that…
CHUCK: Yeah and I just wanna back you up on that because I have a college degree in Computer Engineering. It’s not Computer Science, but I took quite few Computer Science classes. And yeah I don’t think the word “design” and “pattern” were even used in the same sentence [chuckles] together.
JOACHIM: The closest you get is probably “algorithms” and “data models”.
CHUCK: Yeah. That’s true.
JOACHIM: They only kind of scratches the surface, especially in terms of interactions and reusability.
JAMISON: We did some design pattern stuff in one of our classes. I think one of the dangers with the design patterns though is that people build patterns instead of applications. Eventually, it’s like other… I don’t know cool new things that you discover in computing, like you first learned about meta-programing in Ruby or like async stuff in Node.js and you go and do horrible, awful things with it by using it where it doesn’t need to be used.
ADDY: Yeah I completely agree with that. People, don’t use design patterns if you are not using it for the right reasons. Like I’ve seen people that will just see a design pattern in my book or another book or they’ll see some article about a design pattern…
[Kid’s voice in the background.]
ADDY: [Chuckles] That’s cool. And they’ll be like, you know, “I should be using what the cool kids are using. Surely it’s on Hacker News, I should be using it.” But that’s completely the wrong reason to be using the pattern. You should be studying what patterns are available, form your own conclusions about them and try to pick out what makes the most sense for your project.
JAMISON: Yeah I think that’s a really good way to put it.
CHUCK: Yeah. One thing that I’ve found with design patterns that I think is interesting is that, in a lot of cases, I’ll start building something and I’ll get it mostly fleshed out and then some other developer will come and look at my deal and go, “Oh, you are using the observer pattern!” [Chuckles] and I’m like, “I am? I guess I am!” And I think that’s just… it’s also a good way of checking your homework I guess, where you can get in and have a look and go, “Okay, yes this problem actually fits this design pattern.” And that’s sort of what I intuitively wind up building.
ADDY: Exactly. I mean, the thing I like about design patterns is that you get like this formal language that helps us to commonly share an idea. And it’s harder for us to describe syntax and semantics and things like that about what a pattern is versus just saying, “Hey, I’m using the observer pattern.”
CHUCK: Yeah. AJ pointed out, “Patterns aren’t invented; they are discovered.” And yeah, it’s so interesting. At the same time, you know, you can also look at a problem and at the same time, realize that a particular pattern describes well what you wanna do. And then exactly what you were saying, then you can start to explain to somebody else instead of saying, “Well, we need this out here that does this and this over here that does this.” You can just look at them and go, “Well, we are going to use these pattern and we are going to tweak it a little bit this way to match our problem.” And so it does; it defines that language that then immediately provides this huge amount of context around the way that you are going to approach and solve the problem.
JOACHIM: I think it’s also important to realize or it’s important for developers to realize that there are really nice and interesting problems to solve at higher levels of abstraction as well. Like if you listen to [unintelligible] all the time and it’s one of those things where you start from fresh or bring what you have on before because there’s no kind of building blocks in terms of that. But I’m sure Addy is working on that.
CHUCK: And you know, there were few quite interesting ones in there. One that I wanna jump on real quick that I thought was interesting where you had the dry pattern which I don’t really think of as a design pattern.
ADDY: Whilst it’s not necessary, there is a disclaimer right above the dry pattern that says it’s not necessarily a design pattern, but it is a nice way of thinking. And sometimes, when developers try approaching problems, they sometimes forget that you don’t have to include as much repetition in your code and you don’t have to be doing things in several different ways when you can simplify them down to maybe 5 or 6 lines of code instead. And its jut one of those patterns that I guess improve readability and remove the need to include a ton of code that doesn’t have to be there, I guess.
CHUCK: Yeah that makes a lot of sense. And you know, the first time I was exposed to it was when I was reading the Pragmatic Programmer. But yeah, it’s something that they talk a lot about when you are programing in Ruby and rails is DRY and that’s why you have MVC. And I think it’s an interesting principle that definitely applies to a lot of these because you wind up putting together these design patterns to help you avoid the repetition and avoid the problems that come out of repetition. But yeah, it’s an interesting thing and you know, I can see how it might kind of come and bump up against what a design pattern is. Anyway, that makes a lot of sense. So, one of the other design patterns that I wanted to ask about that I don’t completely get is MVVM. I understand that it is similar to MVC, but I don’t completely understand how they are related and what the differences are.
So in MVC, we’ve got sort of three parts; we’ve got models, views and traditionally, controllers. The models manage the main specific data for an application. So if we are creating something like say Facebook, you probably have models representing users and photos and videos and stuff like that. Models might have validation rules and defaults for example. So if you upload a photo for example a model can have a default state to make sure that it is visible to everybody on your timeline. And when models change, they modify anybody that is watching the model about that. So, views for example.
Now views in MVC at least are representation of models that have a filtered-down look of their current state. So looking at, say, the user model again, you could easily have multiple views for that model or you can have one that shows the movies you’ve watched on Netflix, the music that you’ve listened to on Spotify, etc. And views usually observe models and they are notified when models change. But they also come in two different flavors; and this is going to come back into something I’m going to talk about in MVVM. Views have two flavors; it can be passive or they can be active.
ADDY: So views can be passive or they can be active. Now a passive view is consider relatively dumb; and that means that it’s mostly manipulated by a controller. But an active view is something that has a lot more logic in it; it might have data bindings, it might have events, it might have behaviors. And patterns like MVVM use active views. I’ll go into a little more detail about that soon.
And then again at MVC, we’ve got controllers and they are supposed to be like intermediate or between models and views. And I guess they are classically responsible for few different things. You know, they update the view when the model changes and they update the model when a user changes the views. So if you are for example editing the caption on a photograph, that’s you editing a model effectively. So your controller will then update that for you and you’ve made changes to the view.
And so, it can be challenging sometimes if developers are reading classical literature and saying, “Well okay I sort of get what MVC is but why is it that all these frameworks I’m using approach it a little bit differently?” And the reason for that is usually because the framework authors have interpreted the pattern a little bit differently or they found that you can be a little bit more flexible with it; and that’s with Backbone at least, that’s a good thing. It means that I can develop an application that maybe just has a single model and multiple views and doesn’t need a controller at all. But it can get challenging. S
So I’ll talk what MVVM now. So we’ve talked about models using controllers. In MVVM, which stands for Model View ViewModel. The model is very, very similar to what it is in MVC. The view is mostly the same, but it has some subtle differences that are worth noting. So the view in MVVM is essentially an interactive user interface and it represents the state of another component MVVM called the ViewModel. Now the ViewModel is like the specialized controller and it acts like a data converter. So whatever information you have in your model, the ViewModel can change that information into view information. And it can also pass commands from like the view to the model.
So one example for that is like your MVVM model might contain a data tribute in UNIX timestamp format, and your view model can actually go and format that into something a little bit more friendly for your view. So when it actually goes to displaying it, the view doesn’t need to convert that data itself. It could have if you wanted it to do that…. I just heard someone said I’m hypnotizing to listen to.
CHUCK: Yeah that was Joachim on chat.
CHUCK: I was just thinking something along the same lines. I was like, “Man, he is a really dynamic speaker.” Explain things very well though.
JAMISON: You talk pretty.
ADDY: When you say that, I translate that in my brain as, “He has no social life.”
CHUCK: You should hear our other shows; Jamison is over there.
ADDY: All right. So we were talking about model, ViewModel and ViewModel essentially act as a middle man between your models and your views, and they can also expose methods for helping you to maintain view state. Now going back to the view again for a moment, the MVVM view like we talked about the idea of views being both passive and active; where the passive one is dumb but the active one isn’t. The view in MVVM is actually active; meaning that it does a little bit more.
MVVM strongly promotes this idea of data bindings. Now if you’ve explored frameworks like KnockoutJS before, you are probably aware of this idea of having data bindings in your markup which are then passed on to other parts of your application. Some developers like them, some feel bad — it’s a little counter intuitive having sort of logic and bindings in your mark up and they could be completely separate.
CHUCK: That sounds like Mustache to me where they try and strip all the logic out and it’s just dumb data.
ADDY: Yeah but it can also contain events and behaviors and stuff like that. But I guess the framework that most people know MVVM for or probably will know MVVM for is Knockout at the moment or I guess Kendo MVVM which is another variation by another company. But in Knockout, your views effectively just a HTML document with the markup in it, declarative bindings and those link to your ViewModel.
It took me a long time to really appreciate why someone would want to use data bindings in their markup, but the reason why I guess MVVM is of interest to some people is that you might have a team where you have I guess UI developers and UI designers that wanna be working on your view. And you wanna be able to allow the rest of the developers working on your project to focus on the ViewModel and the model, so things that contain more of the business logic and behavior. And so, pattern can help you with that because those designers can be focusing on the view, they could be including sort of data bindings in the mark up without having to go writing logic themselves. And it can be useful in that sense.
JOACHIM: From the performance aspect though, if you need to like refresh only one aspect of the UI, then it becomes a valuable thing to be able to do.
JOACHIM: I mean sometimes like you are really big UIs with thousands of elements then if you are refreshing the whole thing or you know, yeah.
CHUCK: So I’m a little curious then after everything that you’ve done with TodoMVC and you know, looking at these different design patterns and stuff, which of the MVC or MVVM or MVP — which we didn’t talk about Model View Presenter, which of all these libraries do usually prefer on your projects?
JAMISON: And you can’t say, “It depends on the project!”
ADDY: I’m somewhat glad Yehuda isn’t on this call.
So, I mentioned earlier that I’m writing a book about Backbone.js and so, it’s probably not a huge surprise that the one that I currently prefer the most is Backbone. The reason for that in addition to some of the sort of reasons enterprisey reasons like there’s a huge community around it, lots and lots of ways to extend it and tons and tons of large companies actually investing in building apps with Backbone, I find that it’s extremely flexible. And something that you’ll find even people who are like committing codes of Backbone.js will tell you is that, once you really understand how Backbone works, even if it doesn’t completely support MVC in its classical form, it’s flexible enough that you can use it in a way that works best for your project without subscribing to just one way of doing things.
As I mentioned before, I’m currently working on a rather large application with AOL where we effectively have an extremely small number of views and models in the application event though it’s quite large. And I’m making use of a huge amount of component reuse in there, but this is something that I personally find Backbone really useful for because it’s flexible enough for me to do whatever I want with it. If I wanted to introduce additional parts in there, if I wanted to say, I don’t know, spin off some other layer that further breaks down concerns in a way that Backbone doesn’t do at the moment, it’s not that difficult for me to do that. And I don’t know that I could say that about all of the other frameworks that are out there. Having said that, I will say that I’m excited about some of the other frameworks that are out there – just so that that they don’t gang up and beat me.
I really, really, like Ember, I think that once they have a lot of documentation and some more solid examples down –which I know that Yehuda and Tom are working on at the moment — that’s going to be phenomenally interesting to see.
CHUCK: I have to say while you are looking that up, I’m really disappointed we are not going to have like you and Jeremy tag teaming on Yehuda — the Backbone versus Ember Round 2.
ADDY: I’m more than happy to let Jeremy and Yehuda do that themselves and just sit back in the audience.
CHUCK: [Laughs] I have to say though that it wasn’t… I was very grateful that it wasn’t this huge bash fest and at the same time… I mean, it was so interesting because you know, they are talking about these tradeoffs and some of it was in a really high level, design level and some of it was you know, they really got down into the nitty gritty of how their frameworks work. And I think it turned out to be more informative than it really turned out to be hostile. If you haven’t listened to it, I highly recommend you go back and give it a good listen because it was really informative about how these people think about the problems that they are trying to solve, and especially since they are trying to solve general problems, using these particular design patterns as opposed to you know, a very specific problem for a very specific website.
JOACHIM: Can I just quickly ask you Addy, what do you think about YUI3?
ADDY: To be completely honest, I haven’t used it extensively myself, another member of our team built a YUI example on the TodoMVC but you know, I’m sure I can take another look at it one of these days.
JOACHIM: It strikes me because we see all these smaller startups starting up frameworks and they all seem to basically be recapitulating the functionality that’s in YUI3 already. And with a lot of these different things, now we need EnyoJS for loading, we need all these other things for dynamic binding. And these are the things that already… in YUI I’m just wondering if it’s a Yahoo name and the purple color that are [24:21 unintelligible]
ADDY: I think that you made a really interesting statement that YUI already has most of these things sorted out. I think a few years ago, we had the Dojo camp for example saying something very, very similar. And I love Dojo. I’m not saying anything bad about Dojo, but I think that we’ve come to a point where we understand that you know, developers are diverse enough that they are not always going to want to do things in a single subscribed way, you know, a framework might give it out of the box. And we do currently have I guess enough tools that it’s not that difficult for us to put together our own toolkit if we need to. There are situations where it’s going to take a lot more time to and you have to make sure you’ve got built processes that work and take care of unit testing — all those things on your own — but I guess it works for some developers and some prefer something a little bit more packaged.
CHUCK: All right. Did you find what you were looking for on Can.js?
ADDY: Yeah it’s got a ton of useful things; one of the nice things I found about Can is that it’s also built in a way where all the individual components of it… I’ll read these off very, very quickly. You’ve got can.model and can.ejs and routers and observers and all sorts of things. But all of these different parts can actually function outside of this library. So you can actually take bits and pieces of it and start using them separately, which I thought was actually quite interesting.
But Can.js is also… we’ve got the team over at Bitovi were kind enough to build us to-do apps for TodoMVC. And Can was built in a way where it’s not just saying, “You can use jQuery with this.” They’ve actually the effort of creating special builds of their library, where you can be using it with jQuery or Zepto, Dojo or YUI or Moo Tools and it will use whatever functionality those libraries already have to avoid sort of duplicating it on top.
CHUCK: And you can’t even find it on Google.
JAMISON: That’s a really cool feature. I know that one of the things that bothers me about Backbone is its dependence on jQuery. And I know if you can kind of rip it out, but I just wished that more people went through the effort of making their libraries kind of selector library and AJAX library agnostic. So that’s really cool.
JOACHIM: Wasn’t that the other way around? Because I mean there’s functionality in Underscore which is more of a tighter bound dependency which duplicates functionality in jQuery.
ADDY: In some cases, that’s true. And I’ve heard some people say… there are cases where you might only need 10% of what Underscore has and yet most people will still include the whole thing. I think it’s an amazing project but at the same time, I think that the idea of building your library in a way where you are using the best parts of whatever else someone else is going to be including on the page is a really interesting take on it. And I would love to see more frameworks trying that out. I think it’s an interesting idea.
CHUCK: Cool. Well, let’s get back to design patterns for a minute. Does anyone have another design pattern they wanna talk about? I mean, I have a whole bunch but…
JAMISON: I think it will be cool to talk more about MVP. You mentioned it briefly but we didn’t really define what it is and how it differs.
CHUCK: That would be me.
ADDY: [Laughs] Was it because you didn’t wanna know what MVP was?
CHUCK: No, I’m the MVP “Most Valuable Player”.
JAMISON: Got it.
ADDY: I should probably also mention that this whole class of architectural patterns is known as MV* I think Yehuda actually mentioned to me on Twitter a few days ago that he is going to start calling this MV*. So its MV*.
Anyway, back to MVP. So MVP is quite similar to MVC and some people would even say that Backbone is a little bit more MVP than it is MVC. But the idea is if you want to reuse as much presentation logic as possible in your application, MVP is what you are going to probably end up using. And I should probably say MVP is Model View Presenter. So let’s say you’ve got applications where you might have complex views and a lot of user interaction that you might find MVC isn’t the best fit for because you are probably going to require a huge number of controllers for it, for example. I say “controllers”, but fit that in to whatever it is that the frameworks are using, consider a controller.
In MVP all that complex logic can usually be encapsulated into a much smaller number of presenters, like you can use a single presenter for it if you wanted. And that can greatly simplify maintenance in some cases. So like, MVP views are usually defined through an interface. This is slightly different to the way MVC and MVVM works. So when you’re defining MVC, MVP view is defined current interface and that interface is technically the only point of contact that you have between the system and your view. And MVP also less developers like their presentation logic without having to wait on designers to produce the layouts and the graphics for the application and stuff like that. So in that light, it’s a little bit like MVVM, without the data bindings.
JAMISON: I was going to say this sounds a lot like MVVM.
ADDY: Yeah. It’s a little bit like MVVM without the data bindings. So, one can almost say that MVP is essentially MVC with a slightly more designer friendly way of doing things. It’s not massively different. I’ll put it that way.
JAMISON: So I have a broader question about all these stuff. These all seem similar. I mean does it really matter whether you choose MVVM or MVP or MVC or whatever?
CHUCK: It does matter. How else are you going to know who’s right?
JAMISON: [Laughs] That’s true. But there’s this little bit of like paralysis of choice; like you have 30 different frameworks that it seems like the effort you would spend to evaluate them all carefully might be wasted if you would just pick one and do it, you know.
ADDY: That is true in one sense. But the way that I usually approach this is my knowledge of these patterns means that when I do pick a framework, understanding how they were classically defined — so understanding how MVC was classically defined for example — means that I have a better idea of perhaps how I could go about using a framework. So, with Backbone for example, knowing that it perhaps has a lot more controller logic in the view means that if I wanted to, I could be a little bit more classic and separate that out further if I wanted to — if found out that easier. It just means that you know, if I’m using Knockout’s MVVM, perhaps taking on some learning’s that other people have had when they were using MVVM for things like, you know, Flex development or Windows presentation foundation, it really does hurt me saying these things…
ADDY: But people were using those things, [chuckles] taking on the learning’s they had can be useful to you. And I would say you know, don’t go learning these patterns thinking that that’s going to be the be-all and end-all of how you actually go using a framework or how you go out picking out a framework; it’s not. In a lot of cases, frameworks are going to be using something completely different; they might be saying their own variation of MV* or M** even.
JAMISON: So it sounds like you are saying that knowing these patterns helps you understand how to best use the strengths and weaknesses of different frameworks? So, kind of like working with the framework instead of fighting against it?
JAMISON: Okay. That makes sense.
CHUCK: Yeah. It will also help you in a lot of cases. For example, even if it’s not strictly MVVM or MVC, if it’s somewhat, you know, if it’s close enough to be lumped in with the other ones that are also following MVC. Then in a lot of cases, you can make the distinctions and make the right decisions in the first place as to which frameworks you want to use because your problem set and the way that you are going to approach this particular application matches up better with MVP over MVC.
CHUCK: And so, you know, it works both ways; both in the decision on which one to use and then later on in how you use it and how you can possible take advantage of some of the features that it has or doesn’t have based on that design or the design pattern.
ADDY: Essentially, yeah you are right. The Observer Pattern is all about sort of having subscribers that watch other objects we call publishers and we provide a means for subscribers and publishers to have this relationship where whenever something interesting happens in your application, your subscribers can go and react based on that. And the reason you do any of these stuff is to try decoupling your application further.
So one problem that developers regularly have these days is they’ll build things in a way where every part of their application is speaking directly to another part. So you might have multiple modules that are responsible for a variety of different things. And so you’ll say, “Okay I’m going to have the module response for you know, I guess composing how a shopping cart is going to look. How a shopping basket is going to look on the screen,” is being directly tied to a module that perhaps deals with currency or something like that. That’s a really, really bad example but let’s imagine two modules directly communicating with each other. The problem there is that when I go and I want to start building parallel applications, I’m going to perhaps run into an issue where I’m building the exact same logic multiple times over rather than reusing the work that I’ve previously done.
And instead of you building things in a way, where you know, every single module is speaking to another module directly, using the observer pattern, can be really, really useful because it just means that you’re broadcasting out events of interest and other parts of your page or application is going to react to that. And this is also useful because you can build your application in ways using the observer, so that it could be even I guess fail safe or fail proof because other parts of your application might not necessarily I guess crash if you know, someone isn’t directly touching them.
I guess an example of that is… let me think… so let’s say we have a mail application and you are going to have a few different views of this; you are going to have composer view, you are going to have inbox, you are going to have contacts and so on and so forth. Using the Observer Pattern can mean that even if one part of your application crashes, let’s say that you know, something that controls pulling in the messages crashes, because I’m just going to be broadcasting events saying, “Okay there are new messages that are now available. Someone has triggered an action to create a new composition window or there’s a new notification for new message having arrived.” I can actually build my system to be reactive so that none of the other code responsible for stuff even gets touched if that part falls over. I don’t know if I’m explaining that as well as I could be.
JOACHIM: Another example could that if you are dynamically loading in widgets. So you are loading in widgets later on that might be showing a different kind of interface to the basic models that you have. So you can basically load in all kinds of widgets later on independently to each other.
ADDY: Yup. Exactly. But the whole idea with the Observer Pattern is really just to make sure that your system is as free from, I guess, coupled connections as possible.
ADDY: I don’t think it’s something that’s inherent to the language, but you will find in most environments that there is some need to have a decoupled way of communicating and broadcasting. It’s not necessarily always referred to implicitly as you know, the observer pattern or the publish-subscribe pattern. But you know, if we took jQuery for example, I know that not everybody on the call likes jQuery…
JAMISON: [Laughs] You can just say, “Joachim”.
ADDY: [Chuckles] So quite a few versions ago, we actually had this concept of having custom events in jQuery where you could have sort of you could bind something and you could trigger actions etc. and whilst we didn’t explicitly say that that was the observer pattern or that was a publish-subscribe implementation, it effectively could have been used for that.
And Ben Alman who’s a really, really popular plugin writer in the jQuery community actually just created a nice wrapper around that. Because even though that particular library didn’t say, you know, we have we support pubsub, it’s possible to use existing event systems in many cases to either simulate that behavior or do something very, very similar to it.
CHUCK: Yeah that makes sense. All right. Well we are running out of time. We did get a question on Twitter. It looks like it was from Chris Smith. Is that the one that you were going to read, Jamison?
JAMISON: Yeah that was the one that I was thinking about.
CHUCK: It’s not related to design patterns but we’ll ask.
JAMISON: Yeah he is asking why do you favor AMD Require.js? Is it just real world needs or just the belief that it makes sense? It sounds like it is like because it’s just practically the best thing after right now or because you think it’s the best thing overall.
ADDY: So let me flip backwards. Is he trying to say why do I prefer AMD over common.js for example or why do I use AMD at all?
JAMISON: Over common.js because I think you have to use some kind of script like dependency resolution thing. I just hate the require everything in global scope and figure out…
ADDY: Absolutely. I mean, my modern module formats, even though you know, some people would say that their interim standards really do help us a lot and I love that they get rid of the global issues and the name spacing issues and dependency and stuff like that.
So the reason why I love AMD is A. dependency management; it’s really, really useful for that, even if you are just talking about sort of on page load or you are talking about dynamic dependency resolution. I think someone mentioned the idea of dynamically pouring in content when a user needs it, which a number of large applications do these days. And it makes it extremely trivial to handle things that way. It handles the synchronous loading really, really well. It’s used by a number of major libraries like Dojo, jQuery, Moo tools, runs well on the browser, has plugin support, you can sort of export AMD, exports of AMD can be of any format. You can have like objects, you can have JSON functions, numbers, anything you want. And I like that it’s somewhat compatible with ECMAScript next to ECMAScript Harmony using translation tools. I like AMD for all those reasons and more.
Common.js is a nice alternative to other people like you don’t have the same define wrapper to worry about. But I sometimes feel that the Common.js works better on the server than it does in the browser and you know, although both of them do translate to Harmony, I just prefer AMD.
CHUCK: All right. Cool. We are out of time, so let’s go ahead and get into the picks. Did we warn you about the picks, Addy?
ADDY: No. no you didn’t.
CHUCK: So I’m really trying to get better about that. But anyway, so basically, the idea is we just pick things that we like or enjoy. I mean, we’ve had people pick music, or books or TV shows or movies. We also tend to pick things that help us in programming; so you know, we’ve picked tools and IDEs and what have you. So feel free to just think about those kinds of things. And we’ll make Jamison start off so you can kind of get an idea of how this works.
JAMISON: All right. So my first pick is Prismatic. It’s as app that does a bunch of like social network analysis, machine learning and natural language processing to basically recommend interesting articles to you. And I think there’s been some other stuff like this before but Prismatic has been far the best tool I’ve ever seen as far as signal to noise ratio and actually getting things that I’m interested in. I think it’s in beta, which means you might need an invite, but I just like signed up for it and got in. So maybe it’s more open now.
And I’ll do one more. It’s an eBook called Coders at Work. It’s a bunch of interviews with great minds in software development and Computer Science. And it’s kind of leaned a little bit more towards the old guard kind of people from the 80s and 90s and earlier. And it’s just really cool. There were a lot of people in it that I had never heard of, but it turns out they are incredibly influential in things that I use day to day. It’s just a really good read about people solving technical problem and doing interesting stuff.
One more pick — Udacity. It’s one of these online course thing that was started up by Stanford. I got my sister and my dad to sign up for the CS101 class, which is awesome. I’m trying to turn them into nerds.
CHUCK: [Laughs] Nerd converter huh? All right, Joachim what are your picks?
JOACHIM: I’m going to pick Plos1. It’s now the largest scientific journal. And it’s open access; this basically means that people can go in and read stuff and I’ve been spending more time than I should on that and that’s why it’s my only pick.
CHUCK: All right. I’ll go ahead and jump in and go next. So I’m going to do a couple of picks basically just right off of my browser here. The first one is I have an Amazon Wish list.
JAMISON: Oh you can’t pick your wish list, Chuck.
CHUCK: No, I’m just saying I have this plug in, okay? And it makes it nice for me to add stuff for my wish list, but the thing that I really love about Amazon is Amazon Prime. Basically what you get out of that, I haven’t tried getting the free access to the videos, but I guess you get free access to several videos. You also get access to the lending library for certain eBooks, but the big thing is that you get your shipping for free. And I’ll tell you, I have already earned back what I spent on Amazon Prime with the free shipping; just ordering equipment for producing the audio shows and things like that, along with a whole bunch of other junks that I didn’t need to buy. So Amazon Prime is definitely a pick.
One other one that I have here is a Color Picker. It’s an eye dropper tool. I’ll actually put a link on the show notes, but basically if you click on it, then you can click anywhere else in your browser and it will give you back the hex number for the color. So I’ll just put that in here as well.
The other one that I have that I really like is LastPass. I know a lot of people use One Password and used that one a while ago and I don’t know why but it just didn’t work for me the way that I wanted it to but LastPass really does. It’s nice too because I can actually share my passwords with my virtual assistant and then he can go ahead and do things like post podcast episodes. And you know, log in to the websites and things like that that I got up. So it really pays off that way and I really, really dig it. So those are my picks.
Addy, do you have any?
JAMISON: What can you say about semi-colon?
ADDY: Don’t start.
CHUCK: Comma first, right?
JAMISON: Yeah, it’s great.
ADDY: We’ve had enough about semi colons today. The next one is a project called Pulley. My friend Sindre Sorhus and John Resig sort of been updating this project. And the idea behind Pulley is that it’s a really easy to use GitHub pull request lander, and it makes it easy to avoid sort of messing up pull requests and ending up in like a messy commit stream, where you’ve got ticket trackers that don’t automatically close tickets and all that stuff. But it can squash all of the code for a pull request into a single commit, which can just make it a little bit easier to read, but they’ve just released a brand new version like I think an hour ago. So it’s useful to put that out there.
CHUCK: All right. Cool. It looks like AJ had a few picks too. He’s picking Steve Jobs: One Last Thing and Pirates of the Silicon Valley. And anyway, it looks like you can watch them for free if you have Amazon Prime or on YouTube.
So, anyway, with that, we’ll go ahead and wrap up. And just wanna thank you again Addy for coming on the show.
JAMISON: Thank you. This was awesome.
CHUCK: We are talking about doing a Book Club, so keep an ear out for that and over the next few weeks… let me pull up my list here, one person that — if you are interested in MVVM — that we are going to be talking to in a few weeks is Steven Sanderson from Knockout.js. So if you want to hear more about that, then we are going to be talking to him on the 8th of May.