Four rules for developers

… according to Sandi Metz, author of POODR. She mentioned these in a Ruby Rougues podcast and I thought they were interesting! 1. Classes can be no longer than one hundred lines of code. 2. Methods can be no longer than five lines of code. 3. Pass no more than four parameters into a method...
Read More

Prototyping and Inheritance in Javascript

A prototype in Javascript is exactly what it sounds like: a prototype for object to follow.  The best way to explain it would be with an example, of course! We’ll throw in some inheritance while we’re at it. Let’s say we have an an Animal object, that has a name and numLegs, which is a...
Read More

Classes in Javascript

For all of those who usually code in OO languages, there’s actually a pretty similar approach in JS. A “class” in JS will have the properties / attributes of the object, along with any methods that might relate to that object. It’s like a template that can be used to create many objects with similar...
Read More

Objects in Javascript

Declaring an object in Javascript can be done in various ways. Object Literal Notation This creates a single object. Initiating an object with literal notation goes like this: var anne = { name: "Anne", age: 32 // adding functions speak: function () { // code; }; }; where the properties are given as a hash...
Read More