Design patterns in Javascript
Upcoming SlideShare
Loading in...5
×
 

Design patterns in Javascript

on

  • 990 views

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:

https://github.com/tcorral/DesignPatterns_code

Running examples in:

http://tcorral.github.com/Design-Patterns-in-Javascript/

Code of examples in:

https://github.com/tcorral/Design-Patterns-in-Javascript

Statistics

Views

Total Views
990
Views on SlideShare
981
Embed Views
9

Actions

Likes
0
Downloads
16
Comments
0

2 Embeds 9

http://www.linkedin.com 7
https://www.linkedin.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Design patterns in Javascript Design patterns in Javascript Presentation Transcript

  • Someone has already solved your problems.
  • • 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.
  • Restricts the instanciation of a class to one object.
  • Avoids polluting globals.
  • Allow to use ‘function’ to obtain new objects.
  • Used to clone objects.In Javascript is used to create inheritance.
  • Decouple parts of the code in modules.Avoid failing your full application for some littleerror in one module.
  • Allows to execute more than one method at thesame line.Only one instance of object is needed.
  • Overwritte the behaviour of one method/functionto reduce time on further executions.Ideal for updates.
  • Memoize the executions that have been done.Reduce time on expensive jobs.
  • Nullify
  • Removes all references to local variables to avoid memory leaks.
  • Removes all references to local variables to avoid memory leaks when the method/function returns something.
  • Adapter
  • Converts the interface of a class into anotherthe clients expect.Lets classes work together that couldnt otherwisebecause of incompatible interfaces.
  • Decorator
  • Attach additional responsibilities to an objectdynamically.Decorators provide a flexible alternative tosubclassing for extending functionality
  • Factory
  • Defines an interface for creating an object, butlets subclasses decide which class to instanciate.Factory Method lets a class defer instanciationto subclasses.
  • Observer
  • Defines a one-to-many dependency betweenobjects so that when one object changes state,all its dependents are notified and updatedautomatically.
  • Command
  • Encapsulates a request as an object, thereby letting you parameterize other objects with different requests, queue or log requests, and support undoable operations.
  • Facade
  • Provides a unified interface to a set of interfacesin a subsystem.Defines a higher-level interface that makes thesubsystem easier to use
  • Mediator
  • Defines an object that encapsulates how a set of objects interact.
  • State
  • Allows an object to alter its behavior when itsinternal state changes.The object will appear to change its class.
  • Strategy
  • Defines a family of algorithms, encapsulates eachone, and makes them interchangeable.
  • Compose objects into tree structures to representpart-whole hierarchies.Lets clients treat individual objects andcompositions of objects uniformly.
  • Separates elements of the application in layers.Logic, data and views are separated.
  • M.V.C
  • M.V.C
  • M.V.V.M
  • http://bit.ly/softhire