People (a script) ==> Macros (automated scripts) ==> Unit Testing (starting 1990's)
Sequelize is a powerful library in Javascript that makes it easy to manage a SQL database. Sequelize can layer over different protocols, but here we'll use PostgreSQL. At its core, Sequelize is an Object-Relational Mapper – meaning that it maps an object syntax onto our database schemas. Sequelize uses Node.JS and Javascript's object syntax to accomplish its mapping.
Under the hood, Sequelize used with PostgreSQL is several layers removed from our actual database:
- First, we write our Sequelize, using Javascript objects to mimic the structure of our database tables.
- Sequelize creates a SQL string and passes it to a lower-level library called
pg
(PostgreSQL). pg
connects to your PostgreSQL database and queries it or transforms its data.pg
passes the data back to Sequelize, which parses and returns that data as a Javascript object.
Faults in computer problems were theorized as far back as 1843, when Ada Lovelace noted of Babbage's Analytical Engine, "Granted that the actual mechanism is unerring in its processes, the cards may give it wrong orders." Almost 160 years later, NIST reported that software errors cost the US $59 billion annually. Clearly, some of the cards are wrong. However, unlike Grace Hopper's famous moth, most of the time the culprit is ourselves.
Debugging is a sanitization procedure consisting of:
- Preventing bugs in the first place, through good practices and assistive tooling.
- Detecting bugs when they first arise, through proper error handling and testing.
Zach Caceres
Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.
The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.
Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.
FSA 1702 – March 22, 2017
AJAX helps us make requests from the client-side.
Each time we do a URL bar query we re-render the HTML completely. The same is true with a POST request using a form.
>AJAX allows us to move HTTP requests to the background and replace only part of the DOM.
FSA 1702, March 24, 2017
Objects that can emit specific events with a payload to any number of registered listeners.
Event Emitters look a bit like event handlers. We're familiar with listening for events, but emitters take this one step further.
Event Emitters come with two functions. .on
and .emit
.