I read this thread on programmers today and thought that looked like a really elegant way of coding. I would like to discover more neat methods of coding.

What are the best ways of discovering new elegant ways of coding? (Im already aware of the standard design patterns)


4 Answers 4


If you want to learn about elegant code, read code and lots of it.

Look at popular open source applications and frameworks - not all code would be good or elegant, but the more code of other people you are exposed to the more you will learn. Some of the code you will see will be very elegant, some horrible - both will teach you.


I do always equate elegant code with readable code and code which is really easy to understand.

In my opinion you don't have to follow many patterns and practices.

Just lean back and think :

would a coworker or reviewer understand this immediately ?

  • +1 I modify the last line to say Would an average programmer or reviewer understand this immediately. Nov 24, 2011 at 13:56
  • @Sardathrion: pardon for my bad english
    – ralf.w.
    Nov 24, 2011 at 14:14
  • Not at all. Coworker is perfectly fine. I was just saying that I tend to lower the bar on your statement to average programmers and not just to coworkers. I apologies if my statement caused offence. It was not meant to. Nov 24, 2011 at 14:47
  • +1. I would add that this coworker is maybe yourself in three months, i.e. yourself without the short-term memory you have right now when writting the code. Would you want to do changes to this code?
    – Clement J.
    Nov 24, 2011 at 15:58

I would definitly recommend to read Clean Code: A Handbook of Agile Software Craftsmanship.

1 of the 10 top books for programmers, easy and pragmatic guide to clean code (design patterns are not treated in this book).


Elegance is a subjective quality, in my opinion. It is a bit like beauty in that it is in the eye of the beholder. Different people like different things. I don't know of any objective list of characteristics that equate to elegance. Elegant code is hard to write.

That being said, it is very easy to spot unelegant code and design when faced with it. Therefore I agree with the other contributor here who recommended reading lots of code. Good design is often the result of analysis of a design's bad characteristics and smells. It seems logical that good, clean, elegant code is the result of analysis of a block of code's bad characteristics and smells.

Always write code for those coming after you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.