Integration Watch: Better code through reading



Email    print   
September 15, 2009 —  (Page 1 of 2)
The programming section of Reddit occasionally receives posts from comp-sci majors and early entrants into professional programming who want to know about best practices for becoming a great developer. One of the consistent answers from experienced commentators is to read a lot of code. This is excellent advice because it’s the best way for novices to see what experts do and to become autodidacts in the techniques.

In the old days, this was difficult to do because there was not a lot of code available, and what was available was not a useful model. Neither TeX’s literate programming nor gcc’s twisted innards are likely to be what an earnest student is looking for. But with the profusion of well-written codebases today, code reading as an efficient means of knowledge transfer is now distinctly possible.

Two codebases I sometimes pore over are Tomcat (especially the Catalina container) and Cruise Control. Both demonstrate clean architecture, design and code implementation. I am sure if I looked at other code, such as JUnit, I’d find additional examples.

The benefit of this reading, beyond the mere qualitative appreciation, is that I have become aware of programming techniques—especially Java techniques, in my case—for rarely discussed problems.

For example, at startup, Cruise Control reads through certain directories and makes a list of all JAR files it encounters. It then adds those JARs to its existing classpath, so that it can incorporate any and all user plug-ins without imposing on the user to do more than put the plug-in into one of the searched directories. This approach is elegant and perhaps not the one I would have come up with by myself. I appreciate the good user orientation of its design; I know where to find the implementation. In the process, I also learned a lot about how classloaders interact with each other. Not bad for 200 lines of code, huh?

For prospective readers of code whose base language is C, I can heartily recommend Diomidis Spinellis’ excellent book “Code Reading,” which delves deeply into OSS C codebases, and serves as a very effective guide to reading code and knowing what to look for. It is, to my knowledge, the only book written on the topic.



Related Search Term(s): programming techniques

Pages 1 2 


Share this link: http://sdt.bz/33767
 
Most Read Latest News Blog Resources


Comments


09/16/2009 12:52:28 AM EST

Learn the Hungarian Notation. Having programmed in many languages, from Assembly for different processors to extensive C++ programming, I can say the Hungarian notation is a must for writing reliable code. The Hungarian notation makes it easier for team members to communicate and read each other's code. In a nutshell, the Hungarian naming convention is one technique among many that helps programmers produce better code faster. I personally extended the original Hungarian notation for classes, interfaces, methods, member variables, static variables, global variables, objects, arrays, bitwise operations, memory allocation cycles, error handling, exception handling, and data flow to name a few. There are many other benefits of using the Hungarian notation such as finding bugs at compile time and finding bugs during code reviews. People rejecting the usefulness of the Hungarian notation never grasped the idea of using the compiler as a debugger.

CanadaDaniel


09/16/2009 02:28:55 AM EST

Great article and great suggestion. From now on i will also read my code!

South AfricaMuzi


09/16/2009 02:37:22 AM EST

Carefully reading your own code is an interesting piece of advice that hadn't occurred to me. It can indeed be enlightening, especially if you read your code a few years after you wrote it. It can be a humbling experience. If on the other hand you still find it perfect, it means that your skills are not progressing: a worrying sign.

GreeceDiomidis Spinellis


09/16/2009 08:48:08 AM EST

I would recommend reading a copy of "The Elements of Programming Style", maybe a bit dated but good solid information.

United StatesRichard Moore


09/17/2009 01:40:19 AM EST

I have gone through "Code Complete" by Steve McConnell. It is a fine book. My suggestion is, after going through that book, if we are doing this code reading, it would help in improving the code to greater extent.

IndiaAmar@acmet


09/22/2009 10:30:17 AM EST

Good article, writing readable code we might rule the world!

MexicoJavier Torres


09/23/2009 11:30:17 AM EST

Concerning the tools used for printing code listings, the "trueprint" application on Unix is something I've used for many years. It facilitates printing listings of multiple files, with file and function indexes, indent levels, and other features. For the nearsighted (like me), it has an intelligent 4-pages-per-page mode, which gives me an even wider view in less space.

United StatesDavid Karr


Add comment


Name*
Email*  
Country     


  • Comment
Loading




close
NEXT ARTICLE
Code Watch: Here comes functional programming
C#'s popularity means functional programming is here to stay and poised to overcome its roadblocks Read More...
 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 

Download Current Issue
FEBRUARY 2012 PDF ISSUE

Need Back Issues?
DOWNLOAD HERE

Want to subscribe?


 
blogs tab
GitHire: Use Headhunters to Find Your Perfect Programmer
Are you a hiring manager tired of scouring the job boards? Check out this new service that will find 5 people interested in your jobs.
02/03/2012 12:17 PM EST

Facebook claims hacker cred
Facebook's SEC S-1 filing form includes a short essay on the Hacker Way by Mark Zuckerberg himself.
02/02/2012 08:26 AM EST

Ryan Dahl steps down
Ryan Dahl, creator of Node.js, steps back from his position as gatekeeper for the project.
02/01/2012 04:58 PM EST

Bloomberg opens its API
Bloomberg's APIs could lead to a future standard for accessing market data.
02/01/2012 04:41 PM EST

The case for piracy
In the aftermath of SOPA and PIPA, some copyright holders have begun to embrace piracy as inevitable...and even beneficial.
01/30/2012 02:39 PM EST

Tablet sales boom, but applications lag
The installed base of tablet computers and e-book readers is growing rapidly, but no killer app has yet emerged -- hint, hint.
01/28/2012 05:48 PM EST

 
Events calendar tab
2/13/2012 to 2/16/2012
Santa Clara
TechWeb

2/26/2012 to 2/29/2012
San Francisco
BZ Media

2/27/2012 to 3/2/2012
San Francisco
RSA

3/4/2012 to 3/7/2012
Las Vegas
IBM Tivoli

3/5/2012 to 3/9/2012
San Francisco
TechWeb