beyond applications and software

JavaScript summed up #9: Memoization

Doing the same work twice is never a good thing. Knowing that, a pattern called “Memoization” can help you avoid this. It’s about building functions that remember their previous outputs/return values. [Read more →]

October 1, 2009   1 Comment

JavaScript summed up #8: Reflection

Inspecting objects at runtime is what’s called “reflection”. Maybe you want to know – at runtime – what methods an object has or what type of object it is. You’ve got a couple of tools at hand to do this in JavaScript: [Read more →]

September 24, 2009   2 Comments

JavaScript summed up #7: Dynamic code

JavaScript can be a very dynamic language. To prove this, today we’ll discuss two techniques: dynamic code generation in general and “branching” (a special form). [Read more →]

September 17, 2009   3 Comments

JavaScript summed up #6: Reflow

Actually, I planned to write an article about “Reflow” – an important performance-relevant topic in every highly interactive JavaScript application.
But, as I was doing research for the article, I noticed that there are already a handful of very good articles and resources out there. So, instead of re-describing ;-) the wheel, I highly recommend reading through these:

September 10, 2009   No Comments

JavaScript summed up #5: Configuration values

Maintaining and keeping code clean is always a challenge. And JavaScript is not different here.

In complex applications, JavaScript combines a great deal of application logic with classic GUI concerns. Therefore, temptations are high to put things like labels/texts into code (i.e. hard-coding the values). But already the term “hard-coded” should let you think twice.

[Read more →]

September 3, 2009   No Comments

JavaScript summed up #4: Namespaces

In currently popular versions of JavaScript, there’s no native concept of namspaces, like in C#, Java and Co.
But namespaces are important when it comes to larger applications and/or using third party code. You risk to have conflicts with other code (being it your own code or third party code) that is named the same. Unexpected behaviour, to say it politely, can be the result (apart from polluting the global namespace with a lot of variables is just not very nice…).
So we know we need a way to simulate namespaces in JavaScript, too.

[Read more →]

August 27, 2009   1 Comment

JavaScript summed up #3: Type checking

Since JavaScript currently is a dynamically typed language, the topic of type checking is quite interesting. In certain situations it’s rather important to know of which type the object at hand really is.

Here, we have some dummy objects that we want to type-check:

var num = 12;
var string = "Hello World";
var array = [1,2,3];
var object = { firstProp: 1, secondProp: 2 };
function Car(){};
var car = new Car();

Let’s look at two different ways to check the type of an object.

[Read more →]

August 20, 2009   2 Comments

JavaScript summed up #2: Closures

Closures are a vital part of JavaScript’s dynamic nature. Without it, a lot of things would work totally different. Because of this significance, it’s important to thoroughly understand closures.

So, what _is_ a closure, really?

[Read more →]

August 13, 2009   No Comments

JavaScript summed up #1: Functions

PREFACE: This is the first post in a series of posts about JavaScript. There’ll be roughly one post per week in the next couple of weeks (don’t ask me, yet, how many weeks I’m going to hang in there – a couple, at least! ;-) .
The goal is to give a thorough overview of some important core aspects of the language – ranging from building blocks like closures to best practices like unit testing.
Honor to whom honor is due – I’ve not invented these concepts and best practices but learned them from some of the best – most notably folks like John Resig or Douglas Crockford.

The first post is about the concepts of “functions” in JavaScript.
[Read more →]

August 6, 2009   7 Comments