Posts

Modular Design Patterns and Inheritance

Last week we talked about JavaScript inheritance  and if you recall we had talked about modular design patterns in JavaScript  just a month ago. I would also like to talk about how to connect both modules and class inheritance. We've already discussed that modules are classes. So if we can link classes by inheritance relationship, the logical half of our brain suggests that we should be able to link modules as well. The logic prevails - we can. AMD and inheritance I'll be using the classes we defined in the inheritance article, Mammal and Dog , and create modules from them. Let's start with our super class: (function () { 'use strict'; define(function() { function Mammal() { this.age = 0; console.info("Mammal was born"); } Mammal.prototype.grow = function() { this.age += 1; console.log("Mammal grows"); }; return Mammal; }); }()); Let's use it in our entry point JavaScript file. Just t...

R dynamic report generation with Knitr

Image
Let us change our traditional attitude to the construction of programs: Instead of imagining that our main task is to instruct a computer what to do, let us concentrate rather on explaining to humans what we want the computer to do.               Donald E. Knuth, Literate Programming, 1984 Overview and Motivation So what is dynamic documentation and why do we need it. As opposed to usual programming, R programs were intended to used as report for not development oriented folks, whether they are data scientists, statisticians or managers. Moreover by nature, R programs don't tend to be huge spanning across hundreds of thousands of code lines. All these led to a huge demand good documentation framework. But how do you document a report? One may of course is to write a passage and then paste a copied graph into it, however once something changes one must re-copy all the graph, which is of course very tedious and non-rewarding procedure...

Object Oriented JavaScript - Inheritance

Up until now, we've talked about Object Oriented JavaScript  programming. Creating classes though doesn't make you code truly object oriented. What you lack is polymorphism , which is achieved through inheritance. JavaScript is a bit confusing for developers coming from Java or C++, as it's all dynamic, all runtime, and it has no classes at all. It's all just instances (objects). Even the "classes" we simulate are just a function object. Prototype Chain When it comes to inheritance, JavaScript only has one construct: objects. Each object has an internal link to another object called its prototype. That prototype object has a prototype of its own, and so on until an object is reached with null as its prototype. null, by definition, has no prototype, and acts as the final link in this prototype chain . Object.create After being long advocated for ,  EcmaScript 5  has standardized a new method called  Object.create . To keep up with progress, I...

JavaScript Developer Toolkit - Emmet

This is a second article about JavaScript developer's toolkit and today we're going to talk about Emmet . If you've missed the first article about the useful tools for JavaScript developers, have a look at it here . What is Emmet? Essentially it gives you shortcuts you can type that expand into full HTML or CSS. Like nav>a*5  will expand into a <nav> tag with eight links inside it with empty hrefs . <nav> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> </nav> Or, try div.module*2>p*2>lorem and press tab . Firstly it will convert div.module*2  into two < div> elements and associate them with a module css class. After that it will look at >p*2  and create two <p> elements. In the end >lorem  will fill the paragraphs with famous lorem ipsum text. Take a look at the prod...

Data Scientist Toolkit

Image
The history of technology is the history of the invention of tools and techniques, and is similar in many ways to the history of humanity. And since data scientists are mere mortals, they also need tools to make their work more productive and even enjoyable, but that's just me. In this article we'll be talking about main languages and tools used by data scientists. For ones who have recently entered this field of science, it will be a great overview about mostly used tools. R A great advantage of R is that scientists adopted it as their de facto standard. As a consequence, the latest cutting-edge techniques are first available in R. It also seems to be the preference of most Kaggle competition winners . Most of R practitioners use R Studio , and while they do offer a free community version, enterprise edition is a bit expensive. I use the community version only when I compete in Kaggle, haven't won anything yet :( Commercially I find  Sublime Text  a good alternat...

Modular Design Patterns in JavaScript

Last week we've discussed how to create classes and namespaces in JavaScript. For those who missed it, you can read it here . There is however something else you need to know regarding the topic, which is modules. Modules When we say an application is modular, we generally mean it's composed of a set of highly decoupled, distinct pieces of functionality stored in modules. Module can and are implemented using classes, which we already know how to define. So what is the problem? When you try to build a complex piece of software, you end up with hundreds of classes. All of them somehow interact with one another and since JavaScript is not compiled, your job is to reference and load these classes in a correct order. This is why module loaders specification was invented - the most prominent of which are CommonJS and AMD . CommonJS Currently, CommonJS is a de facto standard. Many third-party vendors are making modules or module-load systems according to the CommonJS...

Big Data Buzz Words Overview

Image
I wanted to start this blog by a quick overview of current state of Big Data playground. There was a lot of noise during this year from everywhere making it nearly impossible for a newcomer to learn this world without being overwhelmed. So let's start. How does Big Data differ from NoSQL? NoSql is a type of database, which provides a mechanism for storage and retrieval of data modelled in means other than the tabular relations used in relational databases. The most prominent representatives are Cassandra ,  MongoDB ,  Neo4j and Redis each taking a different approach in data representation. It is important to notice, that NoSql databases have nothing to do with the amount of stored data, but merely it's representation. On contrary Big Data is commonly referred to technologies used to store and operate on huge amounts of data. Usually it is referred to a Apache Hadoop  ecosystem. In fact Hadoop it's file system based databased, so it's also NoSql database. However if Re...