Skip to content

Principles

When writing code, we should try to eliminate frequent mistakes that programmers make. We can do it by keeping in mind a few rules described below.

DRY - Don't repeat yourself

One of the biggest sins of a programmer is duplicate code. How can I deal with duplications? The best solution is almost always a new method or class (combined with the use of certain patterns). For example, we can create a new method and move duplicate code to it, and replace the duplications with a call to it.

Thanks to this, we shorten the source code. It is easier to understand and test. It also remains easier to modify in the future.

KISS - Keep it simple stupid

The code should be as simple as possible. Creating a method that performs complex logic and works does not mean that it is well written as long as only the author is able to understand the logic. A good programmer is able to write a complicated algorithm in such a way that it does not contain unnecessary, redundant elements and a person looking at such a solution for the first time is able to understand it.

YAGNI - You Aren’t Gonna Need It

The YAGNI rule says that we should not create code that is unused in the current code. If we see such code in a given project, we should remove the code. In the age of solutions such as git, we can easily restore it when needed.

Manifesto for Software Craftsmanship

Manifesto for Software Craftsmanship was developed as an extension of the Agile Manifesto. It states that in software development there are important rules such as:

  • Not only working software, but also well-crafted software
  • Not only responding to change, but also steadily adding value
  • Not only individuals and interactions, but also a community of professionals
  • Not only customer collaboration, but also productive partnerships