HTML5 / Producer-consumer-problem solved with WebWorkers

HTML5 provides the mechanism called “WebWorkers”. This feature is very nice and you can learn more about it here: There is also a new feature called “MessageChannel” which is meant to be used for the communication among the different origins (http://somedomain and https://somedomain:8080). I think this article is useful to learn more about it:

This post is going to create two WebWorkers and let them communicate with each other through a MessageChannel. Moreover, the WebWorkers implement the Producer-consumer-problem. The WebWorker #1 is the producer. It generates Fibonacci numbers and posts the result to the WebWorker #2. The WebWorker #2 receives the numbers and removes some of them. When it’s done with the work it posts the result back to the WebWorker #1. The WebWorker #1 fills some numbers again and posts them back to the WebWorker #2 and so on…

See it in action here:

Fork it on GitHub:

Continue reading

JetBrains WebStorm/PHPStorm + jQuery + JsTestDriver + Jasmine

This post describes a workaround to get the triple jQuery + JsTestDriver + Jasmine working inside JetBrains WebStorm to be able to perform tests from the IDE.

As mentioned in this post there are apparently some issue when you try to run the built-in version of the JsUnitDriver. The result is the following exception that is thrown when you try to capture the browser:

Continue reading

Javascript / Inheriting the “DNA” vs. mixing behaviour

The inheritance approaches in Javascript are discussed quite often. The most people, especially Java developer (me too?), have troubles with proper usage of the inheritance.

There are 3 approaches:

  • prototypical inheritance: this is actually the javascript way
  • functional inheritance: is about mixing objects into other objects
  • classical inheritance: IMHO, this approach doesn’t exist. It can be simulated but it’s not real.

Continue reading