DISCOVERY
November 9th, 2017
Closure & Lexical Scope in JavaScript Modules
In JavaScript there are multiple module patterns for creating APIs and separating concerns in code (as of ES6 there is also official module syntax in the spec). In the following code I created an API using the revealing module pattern. The name 'revealing module pattern' comes from the return statement at the end of the module - it 'reveals' functions to outside code.
This module provides lyrics for Taylor Swift songs (because who doesn't enjoy some T-Swift!) The return
statement is the public API for the module. All interior details, such as the lyric
variable, are hidden. This pattern harnesses the power of closure in JavaScript!
DISCOVERY
November 8th, 2017
Scope & Hoisting in JavaScript
JavaScript has quickly become one of the languages I use the most (probably second behind Java). Many people use JavaScript along with one of its many frontend frameworks (JQuery, AngularJS, etc.) without really knowing how the core language operates. I don't want to be one of those people!
This is my first of many discovery posts on JavaScript. Let's look at one of the basic concepts of the language: how variables interact with scope. Scope describes the area of a program where a variable is accessible (e.g. a variable declared in a function is only accessible within that function). Scope is also the execution environment for each line of a program. It consists of the variables and functions a program line is aware of. In JavaScript, scope can get a bit tricky.
DISCOVERY
November 6th, 2017
Creating a Simple Geographical Map with Neo4j and Cypher
Lately I've read about graph databases and their place in the NoSQL data storage universe. The graph database I've worked with is Neo4j, which is fun and easy to get started with. I found the user interface very enjoyable for viewing graphs and executing queries. I highly recommend it if you need a graph database solution.
Graph databases largest draw is related data storage and the speed at which you can query related data points (or in graph terms, nodes/vertices). Relationships are first class citizens, which allows related data queries to be executed by traversing relationships themselves. This is contrasted with a typical relational database where you have to find relationships through foreign keys or combine two tables with a very slow SQL JOIN
operation1. The same slow query in a RDBMS (Relational DataBase Management System) is extremely quick in a graph database.