A case against private variables and functions in JavaScript

arrr im a private, you cant access me
(not sure if the pirate image + caption was created by Zeh Fernando, he sent it to me a couple years ago, forgot to ask him…)

Another polemic subject and something that I’ve been delaying for a while, I’ll try to explain how I got to my conclusions and I’m sure a lot of people won’t agree until they experience the same problem or realize how often it may happen on a real project and specially if it does happen with a code you don’t “own” and/or can’t change without compromising future updates… The advice is mostly about JavaScript (since it’s what I’ve been coding more lately and where I think the issue is bigger) but it also fits other languages.

Not so long ago I had an opposite opinion about this subject - I would always set everything to private and only changed to protected/public if needed - try to understand what made me change my opinion and pay attention every time you find yourself “tied” or doing lots of hacks just because you can’t monkey-patch a simple function/variable.

Read more…


js-signals v0.7.0 and CompoundSignal

Last week I released a new version of js-signals, I usually avoid creating posts at each release since I think people can simply watch the project on Github or are already following me on twitter (and I always send a twit after each release) but I added a few “advanced” features that may be useful on specific cases, that’s why I decided to create a post about it, I think some explanation may help people identify good use cases for those features.

Read more…


The problem with CSS pre-processors

This post is very polemic, I thought a lot before publishing it, please try to be open-minded and read the whole thing before commenting, it is not supposed to become a flame war. Please read the about page to understand the objective of this blog and the way I think about it.

I’ve been considering to use a CSS pre-processor like SASS, LESS, Stylus, etc, for a very long time. Every time someone asked me if I was using any of these tools/languages I would say that I’m kinda used to my current workflow and I don’t really see a reason for changing it since the problems those languages solves are not really the problems I’m having with CSS. Then yesterday I read two blog posts which made me reconsider my point of view so I decided to spend some time today studying the alternatives (once again) and porting some code to check the output and if the languages would really help to keep my code more organized/maintainable and/or if it would make the development process easier (also if they evolved on the past few years).

Read more…


Trust no Strings

Been delaying to write this post for a long time, I think it’s something that experienced developers or people coming from strong typed languages like Java or C# probably already know what I’m going to talk about but for JavaScript developers I think it will be an important information since everyday I see someone (or some famous open-source project) doing it “wrong”.

Strings are evil

Strings are error-prone, a small typo error and your application won’t work as expected and the compiler/environment/VM/etc probably won’t give you any error messages, consider the code below:


Did you noticed something wrong? “February” and “month” were misspelled, depending on how the code is written you won’t see any error message and have no idea why the month isn’t being displayed and why the event listener isn’t being called…

Read more…


JavaScript chaining and Trainwreck.js

source images from public domain (1, 2) and edited by Miller Medeiros

Yesterday I released a piece of code that I wrote a long time ago, it’s called trainwreck.js and it’s main purpose is to provide easy method chaining.

The main reason behind it is because a lot of people don’t really understand how chaining works and end up extending jQuery or underscore.js just to be able to use chaining…

Read more…