Docker Compose in Production

Docker Compose facilitates the deployment of Dockerized applications. A series of Docker commands and arguments to start your application become a single command; docker-compose up. Such an invaluable tool makes deploying in both development and production environments a breeze. However, applications are generally run and configured much differently in production than in development. In this post, we will explore ways to separate your development and production configurations while keeping things DRY and maintaining the simplicity of Docker Compose commands.

Continue reading Docker Compose in Production

Write Better Unit Tests

Writing unit tests is not just a formality. Unit tests are as important to an application as the code that runs it. Without them, code is fragile. A twentieth parameter is added to a common function, with yet another conditional added to the end, as backwards compatibility must be maintained and regressions must be avoided. The same bug is fixed for the fifth time this month. The codebase devolves into a house of cards, where even senior developers can’t make significant changes with confidence. To avoid this dystopian future, start writing unit tests for your code with diligence. In this post, we will outline a basic set of guidelines for writing them that will allow you to improve the stability, reliability, and maintainability of your application.

Continue reading Write Better Unit Tests

Tips for Testing Django Views

Views are probably the most essential part of a Django application. They provide an interface to your application for users or other external applications. It only makes sense that these need to be well-tested. At first, it can seem difficult and/or tedious to write unit tests for them. However, by decoupling your business logic from your views, testing business logic and view logic separately, and tracking code coverage, you can be confident in the reliability and accuracy of your application’s views.

Continue reading Tips for Testing Django Views

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

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

Django ORM Optimization Tips

When it comes to optimizing an ORM, your greatest weapon is your understanding of how your ORM works under the hood (at least at a high level). This makes understanding all of the rules and guidelines for creating a speedy application much easier. Therefore, I highly recommend reading through the Django docs on the subject at least once. My goal for this post is to condense these tips and tricks into an easily-referenceable compilation, as well as adding some of my own. Also check out my Django ORM Optimization cheat sheet for an even more condensed version.

Continue reading Django ORM Optimization Tips

Methodic Debugging


Shockingly, code that you or someone else wrote has been deemed imperfect and you are now responsible for fixing it. Your first instinct may be to panic. You may have a testy customer or an impatient superior who has made sure to impress upon you the importance of your swiftness. You may just not like fixing bugs. In any case, don’t be so hasty. Rushing a bug fix is a good way to create several more.

Bug fixing is a true test of your problem-solving skills. Bugs are not typically random or due to chance. They each have a logical explanation. If you approach the bug fixing process in an organized and logical manner, you will be able to find solutions in a more reasonable and predictable amount of time.

Continue reading Methodic Debugging