Image for post
Image for post
Photo by Karsten Würth on Unsplash

Hey, fellas:) Today we talk about how we can benefit from code generation.

Why

Allows re-using best practices

Every software engineer and every company at some point tries to preserve the knowledge of best practices and know-how-s, in order to prevent making the same mistakes or extra work over and over again.

I was thinking about this problem as well, so during my career, I have tried:

  • writing knowledge base articles,
  • saving snippets of code somewhere (files on a cloud drive, bash aliases or live templates in my favorite IDE),
  • heavily abusing object-oriented paradigm in order to make abstract classes that I could eventually publish as a module, then include them into the application and extend for particular…


Image for post
Image for post
Photo by Samuel Zeller on Unsplash

Personally, I am extremely fascinated with a container-based approach. I try to ship every application as a Docker container because in this case, the application becomes an infrastructure provider agnostic. So this time we will see how to deploy a dockerized application to Heroku — a famous cloud platform.

Step 1: The Code

My application’s code is as simple as 5 cents:

It is written in NodeJS, but it really does not matter, it could be anything else.

⚡ The first important thing: internally Heroku chooses a random port to hang the container on, so your application should look at PORT environment variable.

Let’s create a Dockerfile and put it next to the…


Image for post
Image for post
Photo by Tobias Fischer on Unsplash

Serverless lambda is stateless. It means it does not share any data between two calls of the same function, so now we need to find out how to actually store the data.

When it comes to AWS, we have multiple choices:

  • Aurora — a MySQL/PostgreSQL-compatible service
  • DocumentDB — a MongoDB-compatible service
  • DynamoDB — a special kind of NO-SQL database
  • ElastiCache — in-memory storage (based on Redis or Memcache)
  • Any other data storage running on EC2

Today we will talk about DynamoDB. Facts you should know about DynamoDB before you proceed:

  • It does not support JOIN-s, it is a non-relational database.
  • It is a schema-less database, like MongoDB and unlike MySQL. …

About

Sergei Gannochenko

Business-oriented software dev, in ❤️ with Tech. JS / JS stack, 15+ years in engineering

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store