Skip to content

Rules

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

DRY - Don't repeat yourself

One of the biggest sins of a programmer is duplicating code. How Can I Deal With Repetitions? 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 the repeating code into it, and replace the duplications with a call to it.

Thanks to this, we shorten the source code, make it easier to understand and test, and it remains easier to modify in the future.

KISS - Keep it simple stupid

The code should be as **simple * as possible. Creating a method that does complex logic and works does not mean that it is well written, if only its author is able to understand this 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

Rule YAGNI says that we shouldn't create code that is unused in the current code. If, in turn, we see such code in a given project, we should remove the code. In the era of solutions such as git, we can easily restore it when needed.

Manifesto for Software Craftsmanship

The Software Development Manifesto was developed as an extension of the Agile Manifesto. It states that in working on software development it is important to:

  • not only working software, but also its careful development,
  • not only reacting to changes, but also constantly generating added value,
  • not only people and the interactions between them, but the entire community of professionals,
  • not only cooperation with the client, but also a productive partnership.