Semester 1 Test Notes

// REQUEST
{METHOD_NAME} {URL} HTTP/{VERSION}

//RESPONSE
HTTP/{VERSION} {STATUS_CODE} {STATUS_DESCRIPTION}

// HEADERS
{HEADER_NAME}: {HEADER_VALUE}
// EXAMPLE
Set-cookie: {NAME}={VALUE}; Expires={DATE}

{BODY}

Body:

REST:

Identify resources by ID (integer/UUID).

Safe: read-only

Idempotent: calling method multiple times does not affect state

HTTP Method REST Type Safe Idempotent
GET Read Yes Yes
HEAD N/A Yes Yes
PUT Update/override No Yes
DELETE Delete No Yes
POST Create No No
PATCH Partial update No No

e.g. PATCH could request to increment the value of some property

HTTP/REST are stateless: request must include all parameters and response must return entire resource. Underfetching/overfetching increases latency and data transfer.

Naming: no server-side extensions, all lowercase, / /-/g, consistent singular/plural naming

Versioning:

State:

JS:

var variableName = function functionName() {}

// Immediately invoked function expressions
var IIFE = (function() { return val })(); // succeeds
// var IIFE = function() { return val }(); // functions cannot be immediately invoked
// Succeeds: converts it to a statement?

+function() { do_stuff }(); // + undefined equal to NaN
!function() { do_stuff }();

(() => {
  // var x; // Variable is hoisted to top of function
  if (true) {
    var x = 1;
    const y = 1;
  }
  console.log(x); // Succeeds
  console.log(y); // Fails
})();

// Closures: uses variables in-scope at time of the definition

this; // window in browser, global in node

"use strict"; // First statement inside a script or function
// this defaults to undefined
// variables must be declared
// errors thrown instead of tolerating some bad code
// `with` statements and octel notation rejected
// `eval` and other keywords cannot be assigned
// ES6 modules always in strict mode


// Call stack: stack of function calls
// Heap: allocated memory
// Queue: queue of events. One for each of DOM, network, timers
setTimeout(() => console.log(0), 0);
console.log(1);
// 1 prints first
// JS waits for call stack to clear before running the oldest event


// CommonJS; one specification for managing module dependencies. Used by node
// Use ONE OF:
exports.name = val;
module.exports.name = val;

const val = require("val");


// JSON: lightweight data interchange
// No versioning

ACID:

CAP: choose two of:

BASE:

BASE may split an ACID transaction into multiple ‘transactions’; invariants may not be preserved.

KV Databases:

Document Databases:

Graph DB: