Beautiful Code Principles

Last updated 94 days ago by Pavle Pesic

swift

Writing beautiful code is often underestimated, especially by inexperienced developers. The main reasons are that writing beautiful code takes more time, and you won’t see its benefits right away.

What is beautiful code?

Beautiful code is clean, well-organized, and simple to upgrade. It is easy to read, understand, and navigate. To create and maintain such code, I follow eight simple principles.

1. Have coding standards

Coding standards are a set of coding rules. There is no universal coding standard, every product team might have its own written and unwritten rules. Among important ones, I would mention guidelines for

  • naming variables & naming methods,
  • how to group methods & how to group classes,
  • the order of writing methods,
  • how to import dependencies,
  • how to store data, so you would have a uniform code in every class.

You know to have good coding standards when you look at the code of other developers from your team and can’t recognize who wrote it.

This kind of code is more comfortable to understand. Coding standards give you consistency in all the projects you are working. If you are looking at some project from your company for the first time, you’ll know where to search the content you need. In the long term, coding standards save you a lot of time — from reviewing the code to upgrading features you haven’t worked on before, because you know what to expect.

Read full Article