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.

FireStats icon Powered by FireStatscialis dose

buy cialis in usa

cialis refractory

cheap levitra tablets

buy levitra by mail

levitra without prescription

levitra in canada

cialis 5 mg buy

cheap levitra

brand viagra

generic cialis sale

buy viagra online

buy propecia uk

cheap levitra tablets

canadian women viagra

cheap propecia canada

buying real viagra without prescription

lowest priced propecia

buy cialis usa

generic viagra propecia

5 mg cialis

china viagra

discount propecia rx

buy drug propecia

cialis endurance

canadian viagra 50mg

50 mg cialis dose

buy mg propecia

levitra sale

brand cialis for sale

cialis uk

once a day viagra

discount propecia propecia

buy cialis cannada

buy propecia without prescription

levitra price

levitra

cost of cialis

how much cialis

buy levitra by mail

cialis in canada

buy propecia canada

levitra discount

bestellen levitra online

buy levitra american pharmacy

buy propecia where

cialis headaches

buy cialis without a prescription

cialis daily availability

i need to buy propecia

canadian healthcare

canadian viagra india

cialis blood thinner

canadian generic cialis

cialis india

generic propecia india

buy propecia in canada

levitra low price

buy levitra in europe

indian cialis

cialis levitra sales

buy levitra lowest prices

buy now propecia

buy levitra vardenafil

cialis at real low prices

how can i get some cialis

about cialis

canadian pharmacy viagra

buy viagra in canada no prescription

cialis arterial fibrillation

cost of viagra

cheap viagra pills

cialis professional 100 mg

levitra vs viagra

best price on propecia

canada online pharmacy levitra

generic prescriptions propecia

cheapest propecia uk

combine cialis and levitra

cialis professional

buy cialis

cialis canadian

buy cheap online propecia

buy propecia online usa

non pescription cialis

cialis cheap

online propecia prescriptions

natural levitra

buying cialis in canada

buying cialis

cialis quick shipment

cialis express delivery

buying generic cialis mexico rx

overnight delivery viagra

buy propecia now

obtain viagra without prescription

buy viagra pills

buying generic propecia

levitra presciptions online

cialis canadian

cialis 50 mg dose

buy viagra in canada

express viagra delivery

cheap propecia online

canadian healthcare cialis

online levitra

best price generic propecia

bestellen levitra

cialis kanada

buy cialis

cialis trazodone

canadian pharmacies cialis

cialis 100 mg

cialis dosagem

cialis canada online pharmacy

buy xenical propecia

buy online prescription propecia

cialis buy overnight

order levitra online

buy propecia cheap

levitra paypal

cialis buy

cheap online levitra

brand name cialis

bio viagra herbal

buy canada levitra

cheap fast levitra

5 mg original brand cialis

buy cialis 5 mg

discount levitra pharmacy purchase

buy propecia now

canadian healthcare viagra sales

buy levitra online us

levitra viagra cialis

online pharmacy propecia

canada pharmacy propecia

cialis and diarrhea

gerenic cialis

buy generic propecia

lowest price for levitra

buying viagra with no prescription

buy viagra china

how does viagra work

buy generic cialis

order usa viagra online

cheap propecia online

generic cialis soft tabs

cheapest viagra online

cialis dose

brand viagra professional

effect of cialis on women

best price for generic cialis

cheapest prices on viagra

buy levitra now

buy propecia online cheap pharmacy

bruising on cialis

buy generic propecia online

cialis daily dosage pharmacy

buying viagra in the us

buy cialis in canada

canadian online pharmacy cialis

generic propecia online pharmacy

buy cheap propecia online

buy cheap generic propecia

cialis buy

brand viagra over the net

cialis on line pricing in canada

cialis c 50

best way to use cialis

generic propecia finasteride

cialis cheap us pharmacy

cialis pharmacy

can i get viagra in mexico

generic viagra from china

buy real viagra online without prescription

levitra canada prescription

bying viagra online cheap us

discount levitra rx

buy levitra with no prescription

ordering propecia

buy propecia online prescription

canada viagra pharmacies scam

buy cheapest cialis

cheap propecia order online

cheap propecia 5mg

indian generic levitra

levitra 20mg

buy can from i propecia who

cialis and ketoconazole

buying real viagra without prescription

one day delivery cialis

healthcare canadian pharmacy

cheap order prescription propecia

generic propecia for sale

best viagra

cialis levitra

buy propecia online pharmacy

buy cialis without a prescription

info levitra

buy propecia pills

cheepest cialis

cheap discount levitra

buy levitra now

buy viagra online

buy cialis on line

cialis soft tabs

buying viagra

cialis okay for women

cheapest propecia in uk

fast propecia

generic propecia mastercard

cialis low price

cialis tablets foreign

buy cheapest cialis

buy propecia canada

best price levitra online

cheap viagra online

levitra sex pill

lowest propecia 1 mg

cialis daily

cialis vs levitra

low cost levitra

generic cialis canadian

generic propecia uk

levitra in uk

cialis generic

discount real viagra

levitra online order

best viagra

buy branded viagra online

cialis pfizer

buy propecia in the uk

cialis canadian pharmacy

cialis price in canada

buy propecia pills

levitra cheap

canadain viagra india

mail online order propecia

generic online propecia

generic levitra usa

buy cialis for daily use

buy cheapest propecia

cialis delivered overnight

original levitra

discount cialis india

cheap viagra on line

online prescription propecia

generic viagra canada

levitra from canadian pharmacy

cialis transdermal