Rust Dependency Management with Cargo

This past week, I started learning Rust. While I have enjoyed learning about Rust’s clever approach to system programming, I have to say that I found its dependency management a bit confusing at first. Today, I will share my new understanding of this with you, whether you are a new, experienced, or aspiring Rustacean.

Continue reading Rust Dependency Management with Cargo

Automate Docker Image Versioning with Jenkins

Versioning your Docker images is a good practice that will make them easier to deal with, whether they are used only privately or are offered to the public. With each iteration of an image, regression is always a possibility. To prevent the disruption of services for yourself and others, it is always a good idea to maintain a stable versioning system. By using semantic versioning, we are able to categorize our iterations clearly and allow the subscriber to choose which they want.

Continue reading Automate Docker Image Versioning with Jenkins

How to Dockerize Node.js

Dockerizing your application makes things like development, deployment, distribution, and continuous integration much simpler. Today, we will look at how to run your Node.js application in a Docker container, using Docker Compose to further facilitate the process. See last week’s post, How to Dockerize Django and Postgres, if you are interested in doing the same for your Django application.

Continue reading How to Dockerize Node.js

How to Dockerize Django and Postgres

Docker is an invaluable tool that makes things like setting up your local development environment, continuous integration, and deployment a breeze. Docker is good to set up early on for any application, but it is never too late. With the help of Docker Compose, we are going to set up a Django application to install and deploy itself on any machine with only one command.

Continue reading How to Dockerize Django and Postgres

Marginal Gain #1: Make Common Tasks Easy

Marginal gains are minor improvements that are relatively easy to make. A single marginal gain does not have a meaningful effect, but several can aggregate into significant progress. I first read about this concept in James Clear’s Atomic Habits, and was inspired to apply this philosophy to software development. For a better understanding of what marginal gains are, read this excerpt from the book.

The most worthwhile marginal gains are the ones that take a little effort to implement and no (or almost no) effort to maintain. I like to think of these as small upfront time investments for guaranteed, long-term returns. This is especially relevant to software development. Marginal gains can be earned by making common tasks easier, altering your workflow, or even simply shifting your mindset.

Continue reading Marginal Gain #1: Make Common Tasks Easy

How to Optimize Your Django REST Viewsets

The combination of Django and the Django REST framework is powerful. With just three classes (a model, a viewset, and a serializer), you can have a basic CRUD endpoint up and running. Although it is easy to get set up, it is also easy to end up with a view that makes hundreds of unnecessary database queries. As database queries are relatively slow, we want to avoid them as much as possible. In order to do this, we will follow Tip #4 from my Django ORM Optimization Tips post:

4. Use select_related() and prefetch_related() when you will need foreign-key/reverse related objects.

Continue reading How to Optimize Your Django REST Viewsets

Write Better Functions

Functions are the building blocks of many applications. Most software developers, current or aspiring, have some experience writing functions. Everyone writes them differently, and there are different approaches to getting the most out of your functions. Bad functions are hard to maintain, more unstable, and lack reusability. Writing better functions will make your application more stable, easier to read and maintain, and make future development easier.

Continue reading Write Better Functions

Django Function-Based Views vs. Class-Based Views

Django views are an essential part of most Django applications. They carry out user requests to perform actions and return different types of data. Django provides two distinct methods for creating a view: function-based and class-based. Many discussions have been had over the benefits of using one over the other. I believe that the benefits of using one or the other is highly circumstantial. In this post, I will outline the guidelines I use to determine which option is better for different circumstances.

Continue reading Django Function-Based Views vs. Class-Based Views

Normalize Your Django REST Serializers

When dealing with models with nested relationships, it may initially make sense to serialize them in a nested format. However, you may soon discover that this has a couple of potential issues.

  1. This structure can result in a lot of duplication in the serialized data, especially for many-to-many relationships.
  2. Since those objects are nested, you don’t have them all in one place for easy referencing or updating. Working around this requires tedious iteration and transformation.

These issues are especially pronounced in Javascript applications that use state methodologies or technologies like Redux. Redux applications work much better when your data is normalized. Normalization facilitates cleaner code, makes updating state simpler, and ensures that the fewest possible UI components are forced to re-render due to such updates.

Continue reading Normalize Your Django REST Serializers

Tracer Bullet Programming

How are houses built? Do you finish the bathroom, with tiled floors, a sink, and even a shower curtain, before you even start on the master bedroom? Of course not. You prepare the site, construct framing for the entire house, finish the exterior, install infrastructure (plumbing, electrical, insulation, etc.), and continue to add detail and flesh out different parts of the house until it is complete.

In this post, I will make the case that this is not only the right way to build a house, but the right way to write software as well. Like a house, software is composed of different parts or components. These components need to come together as soon as possible to facilitate good design, prevent unnecessary rework, and enable a steady, stable progression.

Continue reading Tracer Bullet Programming