addyosmani / essential-js-design-patterns

Repo for my 'Learning JavaScript Design Patterns' book
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
4.82k stars 792 forks source link

Fixes: The Observer, Mediator, Facade & Factory Pattern #60

Closed silvenon closed 12 years ago

silvenon commented 12 years ago

As I'm reading the book, I'll send fixes in batches. This is the first one :) First commit represents changes you certainly want, other ones represent changes you probably want.

I'll explain some stuff that might not be obvious, in order of appearance :P

gridUpdate is called before it's defined. Also, I noticed that sometimes you define named functions and sometimes you assign anonymous functions to variables. As far as I know JavaScript, they are pretty much the same, so I suggest you pick one, because it's kind of confusing. For example, gridUpdate is an assigned anonymous function, other grid functions are named.

The function extend is naming it's parameters in the wrong order, because the function seemed like it was extending an extension. Also, the parameter order is unlike other extend functions out there, they all start with the object first, then the extension, so you might wanna change that.

I renamed ratingTemplate to ratingsTemplate because the ID is named that way.

About that Mediator pattern part, I skipped the advanced example because it was to complicated for me, so I don't know how the methods are called there, but I know that method are exposed as capitalized, but used as lowercased.

addyosmani commented 12 years ago

Thanks for the heads up about these issues. I especially appreciate the accompanying PR. I'll review and merge. Thanks!

silvenon commented 12 years ago

No problem, thank you for the book, it seems to cover absolutely everything I wanted to know :D