Quantcast Reading Code Aloud
Search by tag or site Login to my blog ? Start my own blog














TheMoneyBlogs
Home
About
Create your own blog
Contact us
Vote for this blog!

Jon Aquino's Mental Garden

Technologies that make life wonderful

Reading Code Aloud

Posted on 03/13/2007 06:21 AM | Link | Post Comment
When reading a programming book, it can be tempting to skim the code examples. But they likely have some nuggets that are worth learning. The problem is that we don't like to read code written by other people - or at least it doesn't come naturally to us. What we need is a technique for rapid understanding of new code.

I propose reading the code aloud. Now, to make sure we don't get distracted by syntactic details, we can probably come up with some rules for what to omit. Consider this example from Martin's Agile Software Development:

ifndef GEOMETRY_RAY_H
define GEOMETRY_RAY_H

class Ray : public LinearObject
{
public:
Ray(const Point& p1, const Point& p2);
virtual bool IsOn(const Point&) const;
};
endif

I would read this aloud as follows:

class Ray, extends LinearObject
Ray p1, p2
IsOn Point, returns bool

So we have a first cut at a rule of thumb for things to skip:
  • start and end matter (e.g. ifndef, define, endif)
  • access modifiers (public, protected, private)
  • parameter types
We also see a couple of transliterations (text transformations):
  • in C++, read ":" as "extends"
  • in function declarations, read "[type] ..." as "... returns [type]"
A more enterprising reader of code could expand or revise these rules and we could have, say, 10 tips for reading code aloud, for maximum comprehension.
Stock Quote or
Examples
ATM Wallstreet - Mon Oct 06, 2008 03:39PM
Made several great trades today. Traded the QID, QQ [read more]
ATM Wallstreet - Sat Oct 04, 2008 10:41PM
When I first started Day Trading I traded anything that [read more]
Morpheus Trading - Thu Oct 02, 2008 08:58AM
NOTE: Please click on the charts below to enlarge them if [read more]

PREMIER SPONSORED LINKS

Most Visited Blogs | Most Popular Blogs | Most Recent Blogs | Contact Us | Terms and conditions | Privacy Policy

The columns, articles, message board posts and any other features provided on TheMoneyBlogs.com are provided for personal finance, education and investment information and are not to be construed as investment advice. Under no circumstances does the information in this content represent a recommendation to buy, sell or hold any security. The views and opinions expressed in an article or column are the author's own and not necessarily those of TheMoneyBlogs.com and there is no implied endorsement by TheMoneyBlogs.com of any advice or trading strategy. The analysts and employees or affiliates of TheMoneyBlogs.com may hold positions in the stocks or industries discussed here. Your use of this and all information contained on TheMoneyBlogs.com is governed by the Terms and Conditions of Use. Please click the link to view those terms. Follow this link to read our Editorial Policy.

Copyright © 2008 The Connors Group, Inc.