Low level design

High level design is the boxes: a cache here, a queue there, a database behind it. Low level design is what is inside one box. Which classes exist, what each one is allowed to know, and what happens to the code when the requirement changes next month.

This series teaches that, and it teaches TypeScript on the same pages. Every idea is shown in real TypeScript, and every page ends with a list of the syntax it just used. You do not need to know TypeScript to start. You need to be able to read JavaScript.

How a page works

Every page has the same five parts, so by the third one you know where to look.

  1. Something that went wrong. A bug, an outage, a three week estimate. The idea on the page is the fix for it.
  2. One picture to keep. An ATM, a travel plug, a traffic signal. A definition is gone by the weekend. The picture is still there in the interview.
  3. Before and after code. The version that hurts, then the version that does not, in TypeScript you can paste and run.
  4. The TypeScript you just picked up. Every new piece of syntax on the page, with one line on what it means.
  5. A checkpoint and a 60 second version. Three questions, then what you would say out loud if asked to explain it.
Every snippet is checked

Each code block in this section is compiled with strict on and then run, by a script, before the page ships. The output written next to a console.log is the output it printed. A line marked // Error: is one the compiler really rejects, with that message.

Start here

If TypeScript is new to you, read this first. It is the 20 minutes of the language that everything else stands on.

Object oriented programming

The four pillars, each as an answer to one question about your code. Start with the overview.

SOLID principles

Five rules of thumb for code that has to keep changing. Start with the overview.

Design patterns

The ten you will meet most, in real code and in interviews. Start with the overview.

In what order

Top to bottom. The pages build on each other: SOLID assumes you know what an interface is, and the patterns assume you know why you would depend on one.

At one page a day it is a little over three weeks. If you have an interview sooner, three pages a day gets you through in eight days, and the revision table below is for the night before.

Type the snippets out. Reading TypeScript and writing it are different skills, and only one of them is tested.

Revision: every picture on one screen

Cover the right hand column and see how many you can say.

IdeaThe pictureIn one line
The four pillarsA PIEAbstraction, Polymorphism, Inheritance, Encapsulation.
EncapsulationAn ATMKeep the data private. Every change goes through a method that checks it.
AbstractionA switch on the wallShow what it does. Hide how.
InheritanceA family recipeThe child gets everything, then adds or changes a step.
PolymorphismThe hornSame call, different object, different behaviour.
Single responsibilityThe chef does not do the accountsOne class, one team with a reason to change it.
Open closedAn extension boardAdd behaviour by adding code, not by editing code that works.
Liskov substitutionThe substitute fielderA subclass works anywhere its parent works.
Interface segregationThe TV remoteNobody depends on methods they do not use.
Dependency inversionThe wall socketBusiness logic depends on an interface. The database plugs into it.
SingletonThe stadium scoreboardOne instance, shared by everyone.
FactoryThe restaurant counterAsk by name. One place decides which class to build.
BuilderThe chaat counterNamed steps, then build() gives a finished, valid object.
AdapterThe travel plugMake what you cannot change fit the interface you already have.
DecoratorAdd-ons on a dosaWrap with the same interface and add a little behaviour.
FacadeThe hotel receptionOne simple front door to many classes.
StrategyCar, bike or walk in MapsInterchangeable algorithms behind one interface.
ObserverThe bell iconOne announces. Subscribers are told.
StateThe traffic signalBehaviour depends on the current state, and each state is a class.
CommandThe order slipA request as an object: queue it, log it, undo it.

What is coming

Design questions, worked end to end the way the HLD section does them: a parking lot, a expense splitting app, a movie ticket booking flow, an elevator. Then a few more patterns that earn their place, starting with proxy, chain of responsibility and template method.

IndGeek provides solutions in the software field, and is a hub for ultimate Tech Knowledge.