First rule of coding: DRY (Don't Repeat Yourself )

The principle and practices of software development have always interested me. In this blog, we are going to talk about the first principle of coding that I ever learned about i.e. Don't Repeat Yourself principle.

The DRY principle is stated as “Every piece of knowledge must have a single, unambiguous, authoritative representation within a system” by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. In DRY code, we do functioning to codes that are repetitive and perform the same task multiple times in your code. And there should only ever be one copy of any important piece of information.

Let's say you are programming an application that is a blog reading site and there are 100 articles on the site. If you program 100 different view pages for the article, then it will become very high maintenance and expensive process. So, in this case, you need to write a base template in your code and serve the same base template for every article view.

Starting your DRY code:

P.S. We also have the WET principle:

In contrary to the DRY principle, the WET principle means Write Everything Twice. These two principles seem to be inseperable from each other. The WET principle has widely variant interpretations across the internet. It's not clearly stated that when was this principle formulated. But some articles like this have really nice interpretations of the WET principle.

writes code, mostly backend

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