What is Elegance in computer coding?

Home » Programming & Design » What is Elegance in computer coding?
Programming & Design No Comments

Other answer:

It is highly subjective. There is not an easy, objective answer. I think that elegance is related to eloquence except eloquence refers to (non-computer) language.

There is a difference between visual elegance and logical elegance. I assume you are asking about logical elegance.

It can be thought of as a simple solution to a complex problem but it is also something that exists in a person's thoughts and varies from individual to individual.

I think that "simple solution to a complex problem" is simpler and more eloquent than "simplicity and direct approach to a need which seemed complex".

Elegance and eloquence can be something that creates a good feeling in your head.

It's probably borrowed from the older idea of mathematical elegance, referring to a proof or demonstration that is both correct and (often surprisingly) simple.

It has nothing to do with neatness or readability, as suggested by one answer. That can be achieved by a single mouse-click in the IDE I use most often. Elegance requires some thought.

Speaking of answers, when Y!A reminds you to pick a best answer, remember that MsBittner gave the first correct answer.

Generally it means a simplicity and direct approach to a need which seemed complex until the programmer developed the algorithm.
Its indexing 4 spaces so you know what code it belongs to:

myFunction this(){
>>>>That = "This lets you know its part of this Code"
>>>>>>>>ThatOne = "Lets you know its part of That"

This = "would not be part of that Function"
Also = "this is on its own"

It makes you code readable and neat

Python is elegant by default as you must index or Tab (4 spaces)