Michael Zuskin

Elegant Code

Quickly Developed. Clearly Understandable. Easily Maintainable. And Efficient!





Golden rules for self-improvers and code reviewers


These articles are written for programmers who want to improve their coding habits. While dealing with tons of code written by others (as a software developer working in teams and as a designated code inspector), I noticed that programmers usually make same typical mistakes, and the list of those mistakes is quite short. So, I have a good news: changing of coding style (to dramatically decrease code complexity and increase the work enjoyment) requires pretty small efforts!


Code elegancy... It sounds nice, but is it really so important? Does it simplify the developer's work? Can it define a project's success? Can a lack of it contribute to a project's failure? All these questions have a same answer - yes. Being a creator of business programs, I believe that the most important component of my work is understanding of the business, data storage organization, GUI events flow... but code writing style? Yes, it is critically important too! So, all the sides of developer's work play a critical role - including the code writing professionalism. The following articles are about it.


I have seen programmers which came to development from the business sector. Usually they wrote code in a very straightforward way, without too much thinking (or even knowing?) about good coding practices. Unfortunately, I've also seen many coders of that kind who came from the Computer Science. And it isn’t so surprising: for example, I myself never heard about elegant coding style in the nice days of studying Software Engineering in the college. But later, dealing with complicated software forced me to think how to write and organize code...


Only 3.5 developers were occupied in one of the most large-scale project in my career (the PM, one other developer and me + sometimes fourth guy joined us to help before deadlines). The main reason of so high effectiveness was using a good framework library (so we thought mostly about "what" to develop - not "how", in other words - wrote minimum of technical code concentrating on business issues). And the second reason - the application was written using many rules described here (so don't think I am their author). All applications in that company had elegant code, controlled by very strict and even ruthless code reviewers. And oppositely - I took part in development of much simpler applications (I mean simpler from the user's perspective) with much more people involved - whole IT departments were struggling with tons of hopelessly knotted code... In fact, these projects help to keep unemployment low have given life to my articles!


Code reviewers can find these articles useful too, but they should remember that many tips are only a recommendation for self-improvers, so not following these rules cannot be considered as an official error during code inspection. The articles are also addressed to project managers, wishing to decrease development and maintenance expences. PMs don't have to read the articles - they only need to send them to the team's leading programmer(s) or code inspectors and recommend to use the tips to change (or create, if it doesn't exist) the corporate standards of coding document.


The ideas are illustrated with multiple code examples in C# and PowerBuilder (abbreviated as PB), sometimes in PL/SQL - those are the languages I have most experience with :-):


C# Code examples in C#. Also addressed to users of other languages of C-syntax family: C, C++, Java, Objective-C.
PB Code examples in PowerBuilder. More exactly, in PowerScipt - a programming language, used to code in PowerBuilder IDE. Syntactically, it is a dialect of the Basic language, so these examples will be easily understood by developers working in Visual Basic.


Didn't you anticipate a code review?




Contents (click on a topic for quick jump):

  1. The Art of Naming


  2. Code Writing Style

  3. Managing Functions


  4. Intriguing World of Logic


  5. Ocean of Databases


  6. For PowerBuilder Programmers Only




If you have taken an interest in the craft of Code Inspection then I would recommend to read the following pretty interesting books - they are very cheap on Amazon:


Tom Glib, Dorothy Graham. SOFTWARE INSPECTION.


Robert Ebenau, Susan Strauss. SOFTWARE INSPECTION PROCESS.


Ronald Radice. HIGH QUALITY LOW COST SOFTWARE INSPECTIONS.



Professional code inspectors at work:




blog comments powered by Disqus



<< prev CONTENTS next >>

Copyright © zuskin.com Canada 2007-2011




Join me in LinkedIn!






Locations of visitors to this page