I often spend time researching and implementing algorithms in multiple languages as a way to keep my programming skillset sharp, learn a new language and its syntactical sugar, and to have the algorithms at my disposal when and if I need them. ISO 6346 is an international standard that describes the identification of a shipping container. The standard is maintained by the BIC (International Container Bureau) and covers the serial number, owner, country code, and size of any given shipping container.
AWS CDK Static Web + API Multiple Branches in One Account
Namespace based deployment Estimated Reading Time: 20 minutesDifficulty: Intermediate This post is purely illustrative and is to be considered a deployment option that may suit an organization's CICD workflow and feedback loop for Website and API resource deployment. With one development team working on a single project in multiple branches, it may be advantageous to …
Continue reading "AWS CDK Static Web + API Multiple Branches in One Account"
Preload dotenv, don’t require it
Oh my dotenv! If you work with NodeJS at some point you will use and implement dotenv. It loads environment variables from a .env file (configurable name btw), into process.env, following the 12 Factor App methodology of separating environment from code. Pure awesomeness, and makes development configuration loading a breeze mimicking your higher environments.
Avoid using ts-node when performance testing
Often times when performance testing, or comparing resource utilization (ex NodeJS vs Java), I have seen developers load testing, performance testing, and even one-off testing, with ts-node. ts-node is an awesome piece of kit, but it is for rapid prototyping, watching, and development only, it is not a production runtime.
Double vs Triple Equals
A very common point of confusion in JS/TS programming is what double equals and triple equals actually do. While this is base JS functionality, the method by how it works is quite simple (maybe) : Type Coercion
Enum Flags … are … awesome!
An often overlooked feature of most if not all languages is the concept of Enum Flags. In a nutshell, Enum Flags are an efficient way of storing and representing a collection of boolean values with one value 😎. This applies to all SQL languages, C#, Java, Python, Rust, GoLang, the list goes on, and illustrated here in TypeScript.
Literal Types / Type Guards
When using TypeScript, we often (and hopefully as a manner of practice, always) declare the type of a variable or property. TypeScript allows the possibility of a variable or property to be of one or more types. This means that a variable or property can be either a number, string, or custom type by declaring it like so...
Use for..of in lieu of traditional incremental for loops when appropriate
For loops are for loops, sure. There is absolutely nothing wrong with the traditional incremental iterator approach. However, this recommendation is about readability, maintenance, decreasing code smells, as well as best practice when using loops in TypeScript (and in this case ES6+ as well). Often during code review, one will find references to an item via its parent array and index numerous times (think myArray[i].firstName and guess how lastName is accessed? 😞). It is a best practice in most if not all languages to create a variable out of this value accessed by index once.
JS Array Functions Instead of Lodash
Lodash is an amazing library and is often used to minimize the hassle of working with arrays, numbers, objects, strings, etc. However, it is often seen that one of its primary uses is array manipulation, and accessing elements within. TypeScript (and ES6) have the majority this functionality built in!
Template Literals
In many TS code-reviews one may find string concatenation (with the addition operator) used to assemble a message, query, multi-line comments, or other manners of literals. While this gets the job done, it is often prone to error, difficult to read, and in many cases tedious to refactor and or implement.
