6 Examples of CSS Custom Properties Improving OOCSS

Nicole Sullivan defines A CSS object like this: Basically, a CSS “object” is a repeating visual pattern, that can be abstracted into an independent snippet of HTML, CSS, and possibly JavaScript. That object can then be reused throughout a site. Nichole Sullivan, Object Oriented CSS A popular interpretation of this has led to us creating […]

Deprecating and Removing JavaScript Object Properties

When creating an application in most languages, it’s very common to store a series of possible values in an object or as class constants. This is especially useful if the values themselves are numbers – it’s far easier to work with numbers, but considerably easier to remember names (strings). If the technique is less common […]

A Simple JavaScript Observer

I see a lot of scripts out there where the original author decided they needed an observer and knocked a simple one together. I’m not complaining about this situation, the observer is an extremely useful design pattern and it’s always reassuring to see one – a good observer can allow very simple and loosely-coupled integration […]

Creating a Template Engine Part 2: The Code

Last time we ripped off a bunch of libraries to create a string interpolation script and explained the composite pattern with a view to ultimately being able to parse and populate this template: <ul> ${#if responses.length} ${#each responses as response} <li>${response.name}</li> ${#end each} ${#end if} ${#if !responses.length} <li><em>No responses</em></li> ${#end if} </ul> If you don’t […]

Creating a Template Engine Part 1: Groundwork

Although I strongly recommend using a popular, well tested engine, I believe that creating your own is a great learning experience. Since I’ve recently done this and couldn’t find any blog posts explaining the process, I thought I’d take the time to explain how one works, hopefully teaching a few budding JavaScripters looking to expand […]

Encapsulation Part 3: Objects

So far I’ve covered encapsulating arrays but objects are a far more common data type to encapsulate. The basic idea is to allow properties to be set, accessed, checked and removed without giving direct access to the object itself. You’ve almost certainly seen structures like this before. For consistency, setting will return the instance and […]

Encapsulation Part 1: Overview

Encapsulation is one of the four major principles of object-oriented programming (the others are abstraction, inheritance and polymorphism which I might cover in a later post). The basic idea behind encapsulation is to provide access to data while still hiding or protecting it. In this series of blog posts, I’ll show how this is done; […]

Well that surprised me

I recently started work on a web-based app for smart phones. Since it was explicitly for mobiles and explicitly not for desktop devices (and I was building it in my own time rather than for a client) I decided not to use jQuery. I’d read a study that showed how large amounts of JavaScript on […]

Help – I don’t know my JavaScript library!

You may have come across some scripts out in the wild that have different versions available for a few libraries and wondered how it’s done – surely the author didn’t write the same script 5 times, how on Earth would he remember to roll out the bug fixes across all the versions? You may also […]