javascript

Recursos de programación de javascript
In our first iteration in the JavaScript Code Retreat, we worked on the rules to tell if a cell goes on living or if a new cell is created having the restriction of not using conditionals.So we used two very small functions: goesOnLivingWith and isCreatedWith that accepted the number of neighbors as a parameter. We implemented them using TDD and end up with the following tests:The main problem with the names of these tests was that they were tightly coupled to the conditions in the rules we had...
Today I participated in the JavaScript Code Retreat in Valencia.It was a great experience because limiting the possible languages to just one, JavaScript, (that we all knew at least enough to work on the kata) made our practice even more focused. By not having to switch between languages and test frameworks (we all used Jasmine), we could just concentrate in doing our best to craft good code under the constraints of each iteration.It's been fun and I learned a lot again revisiting Conway's Game...
I've just refactored the generalized version of FizzBuzz I posted about recently using Array.map and Array.join functions.This is the version that I had before:and this is the new version using Array.map and Array.join:Even though it was fun coding that "map+join" recursive function of the first version, the second version is much simpler and more efficient (I used jsPerf to compare the two versions, check out the comparison). Had I known Array.map and Array.join before, I could have saved a lot...
Today I read chapters 5 (Functions) and 6 (Applied Functions and Closures) of Test Driven JavaScript development. In them, Christian Johansen goes deep into JavaScript powerful functions talking about functions as first class objects, closures, free variables, recursion, binding, namespaces, etc. I'm enjoying a lot his book.To practice a bit with recursion and closures and also get more acquainted with Jasmine, I decided to do the FizzBuzz kata again but applying some of these concepts. I did TD...
I've started to read the book Test-Driven JavaScript Development written by Christian Johansen that both Carlos Blé and Tomás Corral recommed.The book is great so far (after reading part one). I wanted to follow the examples in the book so I installed JsTestDriver which is the test runner used in the book. Since the book is from 2010, I wasn't sure that JsTestDriver still were the best test runner possible, so I asked Tomás Corral. He kindly answered me that he was now using Karma instead, becau...
As a practice, I'm implementing different design patterns in different languages.I'm using the examples in the great Head First Design Patterns book as the basis for this implementations.The book examples are written in Java, so I'll use other languages.I've started with the Strategy pattern. "The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it." The first implementat...
[PHP Conference Argentina 2013 - 5 de Octubre] Veremos qué es Node.js para un programador PHP. Programa montado sobre el engine de JavaScript V8 de Google. Ejecución en un loop, con IO asíncronico. Node.js como servidor de consola, y servidor web. JavaScript como "lenguaje manteca", muy flexible, con mínima ceremonia de programación, similar a PHP en muchos aspectos, y diferente en otros. Ecosistema de paquetes, parecido a lo que tenemos en PHP con Composer, usando NPM, el manejador oficial de paquetes de Node.js. Veremos que en vez de tener muchas funciones, como PHP, Node tiende a tener modulos, que podemos instalar y consumir en cualquier momento. Donde Node.js comienza a brillar, y diferenciarse de PHP, es en la atención realtime. Veremos soporte de sockets y websockets, y la importancia del asincronismo en IO. Y el precio a pagar: los callbacks, funciones a ejecutar en algún momento futuro. Pero no queremos perder nuestro querido PHP. Entonces, pasaremos a integrar PHP con Node.js. Primer approach: PHP + browser + Node.js, sin apenas comunicación entre PHP y Node. Luego: cómo llamar a código Node desde PHP. Módulos dnode (asincrónico y sincrónico). Ejemplos (desde un simple chat, hasta aplicación distribuida). Y hacia el final... bueno, espero que alguna sorpresa, e tutti li fiocci!
Como la semana pasada no se publicaron noticias, las hemos unido, por lo que en esta entrega, tenemos bastantes noticias: La publicación del manual del administrador de Debian, una nueva librería para gestionar recursos en EC2 desde Python, una presentación sobre Flapjack, otra para hacer pruebas sobre navegadores con JavaScript, otra plataforma de monitorización que se integra con Graphite y Jenkins, otra más que permite exponer un directorio con guiones de bash como API REST, y la adición de nuevas localizaciones a los servicios de CloudFront y Route 53.
[PHP Conference Argentina 2013 - 4 de Octubre] Un nuevo modelo para el diseño de aplicaciones web ha emergido, impulsado por los frameworks cliente Javascript, nuevas funcionalidades en los navegadores, y una expectativa mayor de interfaces de usuario ricas en experiencia. Esta charla te llevará en un recorrido por uno de esos frameworks (AngularJS), y te mostrará como construir un backend optimizado para el mismo, lo cual significa optimizado para la web. Al utilizar funcionalidades normalmente ignoradas de HTTP, puedes desarrollar una arquitectura elegante, con una API HTTP más sencilla, mejorada, y consistente.