The beauty of code

From “97 things every programmer should know.”

There is one quote that I think every software developer should know and keep close to their heart:

The beauty of style, harmony, grace and good rhythm depends on simplicity. – Plato

I believe this one sentence sums up the values ​​we as software developers should strive for.

There are a number of things we strive for in our code:

  • Readability

  • Controllability

  • Development speed

  • The elusive quality of beauty

Plato tells us that the stimulating factor for all these qualities is simplicity.

What is beautiful code? This is potentially a very subjective question. The perception of beauty largely depends on the individual, just as our perception depends on ourselves. People of art have a different perception of beauty (or at least approach to it) than people associated with science. The former approach beauty in software, comparing programming with art, while the latter prefer to talk about symmetry, the golden proportion, trying to reduce everything to numbers. In my experience, simplicity is the basis for most arguments on both sides.

Think about the source code that you studied. If you haven't spent time studying other people's code, then stop reading now – find open source code to read. Seriously! I really mean it! Go search the web for code in any language of your choice, written by some well known expert.

Are you back? Fine. Where did we leave off? Oh yeah… I've found that the code that resonates with me and that I think is beautiful has a number of common properties. The main one is simplicity. I believe that no matter how complex an application or system is, the individual parts should be simple. Simple objects with a single responsibility, containing equally simple, focused methods with descriptive names. Some people think that the idea of ​​code with short methods of five to ten lines is overkill, and in some languages ​​such methods are difficult to write, but I think such brevity is nevertheless a desirable goal.

The bottom line is that beautiful code is simple code. Each individual part is simple, thanks to a single responsibility and simple relationships with other parts of the system. This is how we can keep our systems easy to maintain over time, with clean, simple, testable code, while maintaining a high development rate over the life of the system.

Beauty is born and based on simplicity.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *