5

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)

Tom Squires
  • 17,695
  • 11
  • 67
  • 88
  • Put your code to the test: [Code Review Stack Exchange](http://codereview.stackexchange.com/) – yannis Nov 25 '11 at 00:47

4 Answers4

5

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 ?

Oded
  • 53,326
  • 19
  • 166
  • 181
ralf.w.
  • 151
  • 1
  • 4
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.

Oded
  • 53,326
  • 19
  • 166
  • 181
2

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).

talabes
  • 566
  • 3
  • 11
0

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.

Mark
  • 111
  • 2