This is my first article written in English, so please bear with me and provide your feedback.
When I mention "The Art of DRY," I am referring to the concept of Don't Repeat Yourself, which I first encountered in Robert C. Martin's book, Clean Code.
At first glance, this concept seems obvious and easy to implement. However, I have come to realize that it is not only challenging to achieve but also difficult to identify when duplication occurs beyond just code repetition.
Many times, you may find blocks of code repeated throughout your software. Identifying what can be made reusable and applying techniques such as object-oriented programming and design patterns can help eliminate these duplications.
Duplication doesn't only exist in explicit code but can also be found in terminal commands, deployment processes, or routine test runs.
Once you grasp that DRY encompasses more than just eliminating code duplication, you enter a different realm.
To fully benefit from the art of DRY, you need to explore other techniques and technologies that can eliminate all the redundant actions you repeatedly perform.
Here are some practices that have delivered significant automation results for me:
-
Continuous Integration (CI):
- Whenever I commit and push my code, the CI tool (such as Azure DevOps and GitLab) automatically runs my test suite and provides feedback on whether my changes work well with the existing codebase.
-
Continuous Deployment (CD):
- After the CI pipelines complete, we automatically deploy new artifacts to staging environments and, in some cases, even to production. This is incredibly useful as it ensures that I don't forget to update staging areas for product owners and stakeholders to validate changes or refresh production environments and create git tags.
-
Bash:
- The power to automate tasks that you no longer wish to perform manually. This speaks for itself.
-
Docker:
- Apart from other benefits, Docker allows me to skip the installation process from scratch. Being able to spin up my development environment with a single command or even when I boot my PC feels like a dream come true.
-
Aliases:
- Creating aliases for frequently used git commands, test runs, or any other repetitive terminal tasks is a fantastic way to save time and boost productivity.
I hope you now understand that DRY extends beyond removing code duplication.
Eliminating everything that can be automated using appropriate tools is also a part of DRY.
Please share your comments, and thank you for reading.
Top comments (0)