Your SlideShare is downloading. ×
Design patterns in Javascript
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Design patterns in Javascript


Published on

Slides of the 'Design patterns in Javascript' talk in @MadridJS …

Slides of the 'Design patterns in Javascript' talk in @MadridJS

Code from talk can be found in:

Running examples in:

Code of examples in:

Published in: Technology

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Someone has already solved your problems.
  • 2. • Abstract those that vary.• Program to an interface not an implementation.• Favor composition over inheritance.• Strive for loosely coupled designs between objects that interact.• Classes should be open for extension but closed for modification.• Depend on abstraction. Do not depend on concrete classes.
  • 3. Restricts the instanciation of a class to one object.
  • 4. Avoids polluting globals.
  • 5. Allow to use ‘function’ to obtain new objects.
  • 6. Used to clone objects.In Javascript is used to create inheritance.
  • 7. Decouple parts of the code in modules.Avoid failing your full application for some littleerror in one module.
  • 8. Allows to execute more than one method at thesame line.Only one instance of object is needed.
  • 9. Overwritte the behaviour of one method/functionto reduce time on further executions.Ideal for updates.
  • 10. Memoize the executions that have been done.Reduce time on expensive jobs.
  • 11. Nullify
  • 12. Removes all references to local variables to avoid memory leaks.
  • 13. Removes all references to local variables to avoid memory leaks when the method/function returns something.
  • 14. Adapter
  • 15. Converts the interface of a class into anotherthe clients expect.Lets classes work together that couldnt otherwisebecause of incompatible interfaces.
  • 16. Decorator
  • 17. Attach additional responsibilities to an objectdynamically.Decorators provide a flexible alternative tosubclassing for extending functionality
  • 18. Factory
  • 19. Defines an interface for creating an object, butlets subclasses decide which class to instanciate.Factory Method lets a class defer instanciationto subclasses.
  • 20. Observer
  • 21. Defines a one-to-many dependency betweenobjects so that when one object changes state,all its dependents are notified and updatedautomatically.
  • 22. Command
  • 23. Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
  • 24. Facade
  • 25. Provides a unified interface to a set of interfacesin a subsystem.Defines a higher-level interface that makes thesubsystem easier to use
  • 26. Mediator
  • 27. Defines an object that encapsulates how a set of objects interact.
  • 28. State
  • 29. Allows an object to alter its behavior when itsinternal state changes.The object will appear to change its class.
  • 30. Strategy
  • 31. Defines a family of algorithms, encapsulates eachone, and makes them interchangeable.
  • 32. Compose objects into tree structures to representpart-whole hierarchies.Lets clients treat individual objects andcompositions of objects uniformly.
  • 33. Separates elements of the application in layers.Logic, data and views are separated.
  • 34. M.V.C
  • 35. M.V.C
  • 36. M.V.V.M
  • 37.