The principle of Clarity of style

by Colin Adams (modified: 2008 Jan 17)

Eiffel is based (according to Wikipedia) on a set of principles:

  • Design by contract
  • Command-query separation
  • Uniform access principle
  • Single choice principle
  • Open-closed principle
  • Option-Operand separation

I think there should be an additional principle mentioned, which I call Clarity of style (I am sure this is an implicit principle of the language design). That is, Eiffel syntax and recommended style for English, encourage the creation of a source text which is easy to read, both for the author when coming back to the text after a long period of absence, and to other Eiffel programmers who have never previously seen the code.

Actually, I would go further than that. Programmers who have never even seen Eiffel before should have little difficulty in reading an Eiffel text, even if some of the subtleties escape them. A few months ago, I had the experience of receiving a suggestion for a bug fix to gexslt from a (admittedly very talented and clear-thinking) programmer whose only experince of Eiffel was attempting to compile gexslt on Windows. His suggested patch was spot-on. In contrast, last week I had the unfortunate experience of trying to decipher a Perl script. It was quite well written for Perl, I think, and I have previously coded a very few Perl scripts (many years ago). Nevertheless I found myself continually consulting the Perl documentation and scratching my head a lot. I worked it out in the end, but I didn't enjoy the experience.

What I did enjoy was my first encounter with Eiffel - reading OOSC2. I think the book is written to the same principle. Likewise a Touch of Class. Everything seemed so easy to follow. Likewise when I actually started using Eiffel for the first time. The idea of an obfuscated Eiffel contest sounds like an oxymoron to me. (I just googled for the phrase obfuscated Eiffel, and found only one hit: 'Have you ever heard of an "Obfuscated Eiffel" contest?'.)

I would guess such a principle has not been explicitly named as such before (or maybe it has - any references?) as it might be taken as implicit. Certainly all the listed principles above could be at least partly justified in terms of this principle. But programmers used to languages such as C, with its expression-oriented style, might well find it an alien concept, so I think it deserves mentioning explicitly.

Comments
  • Grant Rettke (13 years ago 19/12/2010)

    It seems more a property than a principle