Elegant Code Club

Forum | Like this site in Facebook! | by Michael Zuskin

Wanna improve your coding habits to make life easier?

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 the same set of typical mistakes. The good news: the list of those mistakes is quite short, so changing of coding style (to dramatically decrease code complexity) requires pretty small efforts. The ideas, described here, will make your code clearer and more understandable, and that means quicker development and easier maintenance.

Code elegance... 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. I believe that the most important component of business applications creators' work is understanding of the business, organization of data storage and processing, GUI events. But code writing style is important too because each aspect of the programmer's work (including code writing professionalism) plays a critical role. Even though coding style mistakes are looking insignificant, they are accumulating over time and, finally, quantity turns into quality. Even a small needle can blow up a big balloon!

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 Computer Science background and it isnít so surprising. I myself never heard about elegant coding style in the nice days of studying Software Engineering in college. But later, dealing with complicated software forced me to think about how to write and organize code...

Only 3.5 developers were occupied in one of the most large-scale projects in my career (the PM, one other developer and me + sometimes fourth guy joined us to help before deadlines). The main reason for our high effectiveness was the use of 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. All applications in that company had elegant code, controlled by very strict and even ruthless code reviewers. And on the other hand, I took part in development of much simpler (from the user's perspective) applications with much more people involved. Whole IT departments were struggling with tons of hopelessly knotted code... In fact, these projects helped to keep developers unemployment low have given life to this site.

The ideas are illustrated with multiple code examples in C# and PowerBuilder (abbreviated as PB), sometimes in PL/SQL and T-SQL. Code examples in C# are also addressed to C, C++, Java, and Objective-C programmers. PowerBuilder code examples are in fact written in PowerScipt - the programming language used to code in PowerBuilder IDE. PowerScipt is a dialect of Basic, so those examples will be clear to VB developers.

The Art of Naming:

Code Writing Style:

Managing Functions:

Intriguing World of Logic:

Ocean of Databases:

Next stuff is only for PowerBuider developers:

Elegant Code:

Tips and Tricks:

Professional code inspectors at work:

Copyright © PowerBuilder.us * Michael Zuskin

Since Feb 17, 2013

free counters

eXTReMe Tracker