HR Week 2: Classes, Algorithms and D3

In week 2 we expanded on instantiation patterns to creating classes, got our hands dirty with algorithms and started using an open sourced charting library (d3). We are settling into a regulated pace where each week is broken down to 3 sprints. Each sprint covers an overarching theme and is tied to a project that we execute in pairs. In addition to sprints, we start off every morning with toy problems (these are typically common interview questions) and we start off every week with a self-assessment. These are a lot of fun and have been great for tracking personal progress even though we don’t get graded.

What we covered this week:

Sprint 1: Subclassing

A class is any construct that can produce a fleet of similar instances–objects that conform to the same interface. @mracus

Classes are blue prints from which objects are created. In addition to that, classes can be used to create hierarchies where a subclass inherits properties from a parent class. Kind of like biological classification: a polar bear shares all of the properties of a mammal plus additional properties of its own. This can be done using the techniques described in last week’s post. There is large debate in the JavaScript community on using prototypal versus pseudoclassical instantiation. By nature, JS is a prototype language (where relationships are created through delegation) but because people attributed JS to Java, the writers were pressured into creating a mask for JS to make it look more like Java, a class-based language. Thus pseudoclassical was born and to date, remains the industry standard. More on what prototype vs pseudoclassical instantiation is here and a visual representation here. Important note on pseudoclassical: This style utilizes the keyword “this”. You cannot assign anything to it because JS does this internally, but you can use it to reference a context in your code. Here are the 2 most important rules to keep in mind when you use or see “this”:

The keyword this generally refers to the object to the left of the dot AT CALL TIME of the function referencing ‘this’. The keyword ‘’this’ can’t possibly mean anything until the function it appears within is running. @mracus

Continue reading

Advertisements