Richard Clayton

Writing Better Apps: Dependency Injection

Dependency Injection (DI) is a pattern where the "things" a component (function, class) depend on are passed into the component instead of the component trying to instantiate (or resolve it) itself. This practice tends to make code a lot more robust by reducing a component's scope. The DI pattern also simplifies the testing . . .

Read More

April 24, 2021

Writing Better Apps: Implementing Configuration

"Configuration" is the settings your application uses to change its behavior at runtime. Configuration might include simple values that adjust timeouts on requests to more complicated settings that swap out database or cloud service providers.

The process of collecting and validating configuration is critical to a stable . . .

Read More

September 30, 2020

Writing Better Apps: Initialization

Whether you are writing a script, a multicommand CLI utility, or a networked server, applications should follow the same initialization pattern:

  • Get configuration
  • Build dependencies
  • Resolve and execute the entry-point function

Get configuration

Using the environment, and possibly command line . . .

Read More

Posted in: nodejstypescript

September 19, 2020

Avoid Synchronous Functions in Node.js

Sync Functions can dramatically slow down your app and they are almost never necessary.

tl;dr

Most synchronous methods in Node.js (statSync, readFileSync, etc.) have asynchronous alternatives (via callback). Using util.promisify can easily make these methods async/await compatible. Using the Promise-based equivalents can greatly speed up your application. In fact, I'd argue there's never a need for the . . .

Read More

Posted in: nodejstypescript

February 29, 2020

WebSequenceDiagrams.com TypeScript Client

https://gist.github.com/rclayton-the-terrible/493cd0811542ff9693ac02746517ba71

TL;DR - TypeScript Client Gist: https://gist.github.com/rclayton-the-terrible/493cd0811542ff9693ac02746517ba71


If you are not familiar with WebSequenceDiagrams, it's an excellent tool for creating sequence diagrams for planning software flows. If you are not familiar with sequence diagrams, a quick Google search will . . .

Read More

June 22, 2019

Archive

This update link alerts you to new Silvrback admin blog posts. A green bubble beside the link indicates a new post. Click the link to the admin blog and the bubble disappears.

Got It!