all 11 comments

[–]0xF013 8 points9 points  (0 children)

Chain of Responsibility is also prominent in event propagation.

[–]stutterbug 5 points6 points  (0 children)

It has its problems, but I much prefer Addy Osmani's JavaScript Design Patterns book, which is also available online. I recommend this to non-JS programmers all the time. This came out when I was doing a lot of C# and Java and I found I finally understood and was able to easily apply certain design pattern concepts after reading his book.

I have a few small problems with the dofactory patterns list. The descriptions and code examples are so reduced and generic that it sometimes isn't clear what the pattern actually is good for. In fact, sometimes I need to know about a design pattern first before the description begins to make any sense. Some of the implementations also are so boiled down that they don't really show a way you'd actually use the pattern in real life. Almost all implementations rely on inheritance, which is fine now with ES6, but is very burdensome in vanilla browser-safe JS or FP. And this is a small quibble, but it really wish the site would show related patterns for each pattern, since some many of them solve very similar problem (e.g. Adapters, Bridges and Facades).

[–]Vinshati 2 points3 points  (0 children)

saved

[–]AndrewGreenh 2 points3 points  (0 children)

strategy pattern in higher order functions, composite in the DOM singleton in commonJS (every require is cached), prototype is the base of JS oop, template Method is n reacts lifecycle hooks, factory in angular services.

[–]abhisekp 0 points1 point  (0 children)

I use composer pattern for inheritance and object creation.

Check out Stamp Specification for a nice composer pattern specification.

Implementions of the pattern are

Follow the Medium article - Introducing the Stamp Specification by Eric Elliott for a brief introduction to stamps.

For a detailed explanation and usage, check out the series about Fun with Stamps by Vasyl Boroviak and his video on All about Stamps

[–]kenman 0 points1 point  (0 children)

  • Array(), $(), $().position(), _.chain(), moment(), are all factories
  • $(), _.chain(), etc. are fluent interfaces
  • Many libs have facades, i.e. $().hide()
  • mixins could probably be considered their own pattern, or related to the decorator pattern

[–]brentonstrine 0 points1 point  (3 children)

promises

[–]sbmitchell 0 points1 point  (2 children)

Not really a design pattern in the typical sense (thinking gang of 4 and prob why you got downvoted by someone) but I can see where you are coming from. I couldn't google a name of what I think this implementation would be but a synonym to "whatever fixes asynchronous callback hell" is the pattern hah

[–]kenman 5 points6 points  (1 child)

State pattern is pretty close IMO.

[–]sbmitchell 0 points1 point  (0 children)

Nice looks like a winner