Archive

Posts Tagged ‘readability’

Information content of expressions

December 11th, 2009 Derek-Jones No comments

Software developers read source code to obtain information. How might the information content of source code be quantified?

Both of the following functions assign the same value to x and if that is the only information a reader of that code is interested in, then the information content of both assignment statements could be said to be the same.

int foo(void)
{
x = 5;
...
}
 
int bar(void)
{
x = 2 + 3;
...

A reader seeking deeper understanding of the above code would ask why the value 5 is built from two values in bar. One reason might be that the author of the function wanted to explicitly call out background information about how the value 5 was derived (this is often done using symbolic names, but the use of literals themselves is sometimes encountered). Perhaps the author of foo did not see the need to expose this information or perhaps the shared value is purely coincidental.

If the two representations denote the same quantity doesn’t the second have a greater information content for a reader seeking deeper understanding?

In the following example:

... x + y & z ...
 
...
 
... num_red + num_white & lower_bits ...

an experienced developer with a knowledge of English is likely to interpret the expression as adding the number of occurrences of two quantities and using bit-wise AND to extract the lower bits. For some readers the second expression has a higher information content. Would use of the names number_of_red further increase the information content?

In the following example the first expression has not added any information that was not already present in the first expression above (except perhaps that the author was not certain of the precedence or perhaps did not expect subsequent readers to be certain).

... ( x + y ) & z ...
 
...
 
... x + ( y & z ) ...

The second expression uses parenthesis to achieve an operand/operator binding that is different from the default. Has this changed the information content of the expression?

There is experimental evidence that developers extract information from the names of variables to help them make decisions about operator precedence. To me the name all_32_bits_one suggests a sequence of bits and I would expect such a representation to be associated with the bit-wise AND operator, not binary plus. With no knowledge of the relative precedence of the two operators in the following expression the name of the middle operand would cause me to misinterpret the code. Does this change the information content of the expression? Does knowledge of the experimental evidence and the correct operator precedence change the information content (i.e., there is a potential fault in the code because the author may have assumed the incorrect precedence)?

... num_red + all_32_bits_one & sign_bit ...

There is experimental evidence that people use the amount of whitespace appearing between operands and their operators to visually highlight operator precedence

The relative quantities of whitespace used in the following two expressions appear to tell very different stories. Do the two expressions have a different information content?

... x  +  y & z ...
 
...
 
... x + y  &  z ...

The idea of measuring the information content of source code is very enticing. However, an accurate measure requires knowledge of the kind of information a reader is trying to obtain and of information that already exists in their brain.

Another question is the easy with which information can be extracted from code. Something that might be labeled as readability, except that readability has connotations of there being an abundant supply of information to extract.

Readability, an experimental view

January 20th, 2009 Derek-Jones No comments

Readability is an attribute that source code is often claimed to have, but what is it? While people are happy to use the term they have great difficulty in defining exactly what it is (I will eventually get around discussing my own own views in post). Ray Buse took a very simply approach to answering this question, he asked lots of people (to be exact 120 students) to rate short snippets of code and analysed the results. Like all good researchers he made his data available to others. This posting discusses my thoughts on the expected results and some analysis of the results.

The subjects were first, second, third year undergraduates and postgraduates. I would not expect first year students to know anything and for their results to be essentially random. Over the years, as they gain more experience, I would expect individual views on what constitutes readability to stabilize. The input from friends, teachers, books and web pages might be expected to create some degree of agreement between different students’ view of what constitutes readability. I’m not saying that this common view is correct or bears any relationship to views held by other groups of people, only that there might be some degree of convergence within a group of people studying together.

Readability is not something that students can be expected to have explicitly studied (I’m assuming that it plays an insignificant part in any course marks), so their knowledge of it is implicit. Some students will enjoy writing code and spends lots of time doing it while (many) others will not.

Separating out the data by year the results for first year students look like a normal distribution with a slight bulge on one side (created using plot(density(1_to_5_rating_data)) in R).

First year

year by year this bulge turns (second year):

Second year

into a hillock (final year):

Final year

It is tempting to interpret these results as the majority of students assigning an essentially random rating, with a slight positive bias, for the readability of each snippet, with a growing number of more experienced students assigning less than average rating to some snippets.

Do the student’s view converge to a common opinion on readability? The answers appears to be No. An analysis of the final year data using Fleiss’s Kappa shows that there is virtually no agreement between students ratings. In fact every Interrater Reliability and Agreement function I tried said the same thing. Some cluster analysis might enable me to locate students holding similar views.

In an email exchange with Ray Buse I learned that the postgraduate students had a relatively wide range of computing expertise, so I did not analyse their results.

I wish I had thought of this approach to measuring readability. Its simplicity makes it amenable for use in a wide range of experimental situations. The one change I would make is that I would explicitly create the snippets to have certain properties, rather than randomly extracting them from existing source.

www.wenn.com
FireStats icon Powered by FireStatswww.tinynibbles.com cialis 5 mg

buy propecia canada

low cost canadian viagra

cialis profesional

once a day viagra

cialis quick shipment

online ordering propecia

online generic cialis 100 mg

lowest propecia prices in canada

order cheap propecia

cheap canadian viagra

genuine cialis pills

canadian viagra india

ordering propecia online

levitra for sale

bestellen levitra online

cialis alternative

cialis 100 mg generic

can i get viagra in mexico

cheap propecia online

generic viagra india

buy 5 mg cialis

canada levitra

order cheapest propecia online

get cialis online

canada cheap propecia

levitra sales uk

generic levitra online

cialis and canada custom

canada online pharmacy levitra

cialis cheap us pharmacy

canada viagra generic

buy propecia prescriptions online

cialis en mexico

buy viagra on line

buy viagra online cheap us

levitra online prescription

info levitra

buy propecia generic

levitra in canada

cialis overnight delivery

buy propecia now

online propecia uk

buy levitra uk

buy cialis once daily

gele viagra

cialis 5 mg italia

buy cialis for daily use

cialis to buy

mexico pharmacy cialis

low cost levitra

generic cialis next day shipping

how much does cialis cost

low cost propecia

healthcare canadian pharmacy

buy now propecia

buy cheap generic levitra

buy levitra overnight

buy can from i propecia who

cialis on women

cialis by mail

generic propecia 5mg

discount levitra rx

cialis discounts

cheap viagra from uk

cialis tablets

buy cialis usa

5 mg daily cialis

cheap viagra canada or india

discount levitra purchase

cialis 100 mg

brand name cialis overnight

cialis one a day

generic levitra canada

name brand cialis

how much to buy viagra in pounds

generic propecia sale

cheap propecia 5mg

canadian online pharmacy cialis

buy levitra online viagra

generic levitra overnight delivery

online propecia prescriptions

ordering cialis gel

levitra discount

best price levitra

cialis daily dosage pharmacy

levitra viagra cialis

online levitra

best price cialis

discount drug propecia

cialis fast delivery

order prescription propecia

cialis woman

buy levitra online no prescription

best price propecia

cialis uk

cheapest propecia prescription

buy propecia in the uk

discount propecia propecia

combine cialis and levitra

buy cheap generic propecia

levitra low price

hydrochlorothiazide cialis

buy generic levitra

buy cialis cannada

discount cialis india

buy propecia online pharmacy

lowest price for propecia

discount us propecia

generic levitra purchase

canada generic propecia

levitra online overnight delivery

get propecia online pharmacy

canada online pharmacy propecia

cialis price 100 mg

generic propecia online pharmacy

best price generic propecia

levitra viagra online

cheapest propecia uk

buy propecia where

generic levitra vardenafil

buy viagra mexico

cheap levitra prescription

cialis refractory

levitra online

buy real viagra online

cheapest viagra online

buy generic cialis

cheapest viagra

cheap propecia online prescription

canadian pharmacy cialis

discount levitra online

cialis overnight

generic viagra made in india

best price for generic cialis

cialis purchase

canadian healthcare viagra

generic levitra cheap

generic viagra made in usa

cialis 50 mg

cialis transdermal

cheapest price propecia cheap

canadian pharmacy viagra

cialis vs levitra

levitra mg

cost of propecia

generic viagra 100 mg

buy dosages levitra

buying levitra online

generic propecia finasteride

cheap levitra without prescription

buy real cialis

canadian drugs propecia

brand name cialis

cheap viagra online

buy propecia on line

buy generic propecia

generic cialis from india

cialis professional no prescription

lowest priced propecia

how to get cialis in canada

cheapest overnight cialis

generic propecia alternative

buying generic cialis mexico rx

buy cialis canada

mail order levitra

cialis dosage mg

female viagra pills

cheap prescription propecia

indian cialis

online cialis

lowest price propecia best

levitra cost

canadian pharmacy discount code viagra

buy cialis online canada

cialis soft pills

cialis professional 100 mg

levitra canadian

buy online prescription propecia

buying cialis

discount propecia rx

cost of daily cialis

cialis prescription

cheap levitra tablets

get levitra online

get cialis

buying online propecia

cheapest prices for viagra

for sale levitra

cialis strenght mg

levitra in india

canada meds viagra

cialis 20 mg

lowest cost levitra

how to buy cialis in canada

cialis generic 100 mg

levitra cheap fast

cialis in mexico

canada viagra pharmacies scam

levitra online no prescription

buying viagra in canada

levitra next day delivery

fda levitra

levitra 10mg

lowest price on non generic levitra

cost of viagra

canadian viagra

cialis buy overnight

buy cheapest propecia

lowest price propecia

cialis next day

lowest propecia 1 mg

overnight delivery cialis

buy propecia cheap

buy viagra without prescription

cheap levitra uk

canadian viagra and healthcare

generic propecia effective

buy cheap levitra online

buying cialis soft tabs 100 mg

best viagra

indian generic levitra

natural viagra

cost levitra low

levitra now online

buy propecia online prescription

brand cialis for sale

cheap order prescription propecia

cialis price in canada

levitra buy online

how much cialis

drug generic propecia

canadian pharmacy

bio viagra herbal

i need to buy propecia

buying propecia

cialis 5 mg buy

buy cialis online uk

buy generic viagra india rx

buy fast propecia

generic viagra canadian

mexico levitra

does generic cialis work

generic cialis soft tabs

cheapest propecia sale uk

cialis no prescription

cialis next day delivery

buy cialis in usa

cialis delivered overnight

discount generic propecia

internet pharmacy propecia

online cheap viagra

herbal propecia

levitra tabs

buy cheap levitra

cheap propecia no prescription

cialis from mexico

cialis professional 20 mg

online pharmacy propecia viagra

how to get viagra

order viagra or levitra

online propecia prescription

indian cialis generic

get levitra

cialis and diarrhea

generic cialis sale

cialis for woman

buy viagra online

brand viagra over the net

cheap cialis

next day viagra

daily dosage cialis

cheap discount levitra

buy levitra online from canada

cialis daily in canada

once daily cialis

levitra from canadian pharmacy

buy viagra

cialis fast delivery usa

levitra order prescription

overnight delivery viagra

cheap cialis soft

how strong is 5 mg of cialis

cialis from canada

levitra mail order

obtain viagra without prescription

buy viagra china

buying cialis next day delivery

buy levitra us

mail online order propecia

best price for propecia

canada propecia prescription

buy levitra vardenafil

buy canada levitra

canadian viagra 50mg

levitra pill

cialis cheap

cheap levitra

china viagra

levitra online sales