background preloader

A lire

Facebook Twitter

Les domaines dans Node.JS, à quoi ça sert ? « naholyr.fr. Les domaines sont l’une des grandes nouveautés de Node.JS 0.8.

Les domaines dans Node.JS, à quoi ça sert ? « naholyr.fr

J’étais un peu circonspect quand je les ai vus arriver, ayant un peu de mal à comprendre le cas pratique auquel ils répondaient. Puis je suis tombé sur un cas dans la vraie vie Je vais vous le partager en version simplifiée, et on va voir comment le corriger à l’aide des domaines. Un module en apparence innocent En l’occurrence, le module était request. Une bonne manière par exemple de télécharger un fichier serait donc la suivante: Hélas, le .on('error') est souvent laissé de côté. Un évènement n’est pas une exception Ça semble une évidence, mais il faut en saisir toute la portée: une exception n’a évidemment aucun sens dans un code asynchrone, le programme est passé hors du bloc try/catch depuis longtemps quand l’erreur survient, et retourner d’un coup dans le catch serait très complexe à gérer pour le développeur.

Le cas qui ruine le moral Et là on tombe sur le module mal codé. Et là c’est mort. La solution avant En détails. The Seven Deadly Sins of Cloud Computing Research. Decorator pattern. Intent[edit] Decorator UML class diagram Subclass the original "Component" class into a "Decorator" class (see UML diagram);In the Decorator class, add a Component pointer as a field;Pass a Component to the Decorator constructor to initialize the Component pointer;In the Decorator class, redirect all "Component" methods to the "Component" pointer; andIn the ConcreteDecorator class, override any Component method(s) whose behavior needs to be modified.

Decorator pattern

This pattern is designed so that multiple decorators can be stacked on top of each other, each time adding a new functionality to the overridden method(s). Note that decorators and the original class object share a common set of features. In the previous diagram, the "operation()" method was available in both the decorated and undecorated versions.

The decoration features (e.g., methods, properties, or other members) are usually defined by an interface, mixin (a.k.a. Motivation[edit] UML Diagram for the Window Example Examples[edit] Java[edit] Terrific. Underscore.js. Introduction - Documentation - Spine. Spine is a lightweight framework for building JavaScript web applications.

Introduction - Documentation - Spine

Spine gives you an MVC structure and then gets out of your way, allowing you to concentrate on the fun stuff, building awesome web applications. Spine is opinionated in its approach to web application architecture and design. Spine's architecture complements patterns such as de-coupled components and CommonJS modules, markedly helping with code quality and maintainability. The library is written in CoffeeScript, but doesn't necessarily require CoffeeScript to develop applications. You can use CoffeeScript or JavaScript, whichever language you're most familiar with. Spine is tiny, the core library comes in at around 600 lines of CoffeeScript. Core values MVC - The MVC pattern, or Model View Controller, is at the heart of Spine applications. Why should you use Spine? JavaScript frameworks are a dime a dozen, and more are appearing everyday. But don't take our word for it. Components. Backbone.js.

Re-using Backbone.js Models on the server with Node.js and Socket.io to build real-time apps. Quick intro, the hype and awesomeness that is Node Node.js is pretty freakin' awesome, yes.

Re-using Backbone.js Models on the server with Node.js and Socket.io to build real-time apps

But it's also been hyped up more than an Apple gadget. As pointed out by Eric Florenzano on his blog a LOT of the original excitement of server-side JS was due to the ability to share code between client and server. However, instead, the first thing everybody did is start porting all the existing tools and frameworks to node. Faster and better, perhaps, but it's still largely the same 'ol thing. Basically, Node.js runs V8, the same JS engine as Chrome, and as such, it has fairly decent ECMA Script 5 support.

So, that is what makes underscore.js so magical. So what kind of stuff would we want to share between client and server? Enter Backbone.js A few months ago I got really into Backbone and wrote this introductory post about it that made the frontpage of HN. Var _ = require('underscore')._, backbone = require('backbone'); So what?! State! Unifying Application State State syncing The magical Socket.io.