Skip to content

SOLID demonstration using TypeScript

Notifications You must be signed in to change notification settings

mikaelvesavuori/solid-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOLID demonstration using TypeScript

This repo demonstrates the SOLID principles with the example of a basic imaginary email service, in which we need to validate the address, send a message, and log the transaction. We'll start with a basic "dirty implementation" and introduce the SOLID concepts one by one.

In the SILOD ("siloed") order:

  1. Start
  2. SRP: Begin to break up functionality and make it semantic and clean.
  3. ISP: Working towards interfaces, not concretions.
  4. LSP: Making subclasses without breaking superclasses.
  5. OCP: Extending behavior of superclass methods without breaking them.
  6. DIP: Creating flexibility by decoupling dependencies and injecting them where needed.

Running the code

You can install the things with npm install. For running the starting code, run npm start. Then, for each respective letter of the SOLID principles you want to run, use npm run s|o|l|i|d.

Or, if you're lazy, you can also copy the individual TS file's contents into the TypeScript playground if you want to avoid cloning and installing anything at all.


More resources

The SOLID Principles

The principles in their mnemonic order:

Five Minutes or Less