typed – Static typing for JavaScript

About two weeks ago I first read about TypeScript, Microsoft´s version of a statically typed language which compiles to JavaScript. Besides the static typing which I´ve actually never missed in JS it supports classes, modules and interfaces. The class keyword is syntactic sugar (like in ES6) and the modules compile down to plain old namespaces. So nothing too special there. However the interface concept looks quite interesting. I actually would like to use interfaces in JavaScript from time to time. But I won´t bother switching to another language which I have to compile just to be able to use them.

Continue reading

JavaScript module formats

What would life be without any contradictions? Although I announced that my blog posts will be much shorter in future here is probably the longest one I´ve ever written :D About one and a half year ago I first got in touch with modularization possibilites in JavaScript. Since then I have worked extensively with namespaces, the Asynchronous Module Definition (AMD) and CommonJS Modules (implemented in Node.js). Today I consider myself pretty skilled in using any of these formats and therefore I want to share with you their pros and cons.

Continue reading

Grunt – a build tool for JavaScript projects

I wasn´t really sure if I wanted to continue writing blog posts. Now I have finally decided to do so and have also realized what has stopped me until now: I invested way too much time in trying to publish well written and informative blog posts. I´m already spending enough time on developing, reading blogs and experimenting with new technologies. So from now on my posts will just be way shorter (and maybe full of typos). Let´s see how that goes.

Recently I got to know Grunt, a “task-based command line build tool for JavaScript projects”. I already converted declarative to use Grunt and have to say it works really great. Its tasks can take care of all that linting, test execution, combining, minification, etc. in an automated way. One task worth to mention is grunt-jasmine-task which executes all Jasmine specs in PhantomJS.

Grunt is also really easy to extend by writing custom tasks. I have already written two myself: grunt-umd to surround code with the universal module definition and grunt-reznik to integrate reznik for AMD dependency analysis. There is also an official collection of contributed grunt tasks available here.

If you are working on some JavaScript project you probably should also be using Grunt.

Testability of DOM ready handlers

I bet you already thought this blog was dead because I didn´t come up with something new for quite a while. You were wrong, here I am again! :) Other than the previous posts about general stuff this one is more code related. It is about the testability of jquery DOM ready handlers.

A DOM ready handler is a function that is passed to jquery and executed as soon as the DOM is fully loaded (put simplified). If the DOM is already loaded by the time registering the handler, the function is executed immediately. You can read about the details of this mechanism here. In most cases such handlers are defined as anonymous functions:

Continue reading

On code comments

Note: In this post I am neither talking about high level documentation nor do I cover the development of publicly used frameworks where good code comments can be very helpful.

The joy of commenting

I was introduced to code comments at the beginning of my studies while learning Java in the first semester. The explanations of our professor came along with the notice that “it is important to document your code”. I really liked the idea of writing code that everybody can understand. In the second semester after we had gotten deep into the principles of object oriented programming we learned about Javadoc. I can´t exactly say why but I was fascinated with the possibility to generate whole HTML documentations out of code comments.

Continue reading

Pragmatism

This is like my fifth attempt to find the right platform for expressing myself and sharing my more or less useful information with the world. A few years ago during my studies and my work at artecho I built my own website based on Drupal. Back then this was fun because I worked a lot with Drupal and could improve my skills this way. Today when I log into my old website I only see a huge cms which is too complicated for a simple thing like writing blog posts.

When I started to work as a developer at AutoScout24 (with great colleagues) I began thinking about a new project to share my ideas and opinions. I started twittering and found it quite comfortable in combination with a Firefox plugin. It is nice to have the possibility to tweet while browsing the web, but with the limitation of 140 characters there isn´t too much information I could share in one post. At the same time I started reading more blogs and feeds using Google Reader (which is a great piece of software by the way).

Continue reading