small medium large xlarge

Back to: All Forums  PragPub
Nev_pragsmall
15 Jun 2010, 01:53
Neville Ridley-Smith (6 posts)

Interesting article Brian.

Re interns I’m a big fan of pair programming. One reason I like it relates to the first half of the article - that naming things is hugely important. Naming things and coming up with metaphors can be incredibly hard and having two people work on names together is more likely to produce something that’s more understandable to others.

Re analyzing code for readability, I think that deserves a full article by itself. It’s like you’ve presented the kernel of an idea and I’d like to see the idea developed further.

IntelliJ has the beginnings of what you suggest. If you have the statement int height = someComponent.getWidth(); it will flag this line with a warning that it’s probably not what you intended. They could probably extend this inspection to add a lot more smarts to it.

Thanks again for the article, Nev

Headshot_pragsmall
21 Jun 2010, 12:33
Brian Tarbox (41 posts)

I’m glad you liked the article, I think that thinking about how to make code more readable is my life’s mission (undergraduate degree: linguistic philosophy, gradudate degree: cognitive psychology with dolphins).

The IntelliJ feature you describe sounds facinating, I wonder how they implemented it?

I agree with you about how pair programming helps naming. As soon as you say “what this variable holds is” or “what this method really does is” you know the name of the item is wrong.

I’ve also wanted to write an article Titled “And is a Four Letter Word” to state the principal that if you use the word “and” to describe what something is or does then you should likely decompose it into two or more subthings.

Nev_pragsmall
06 Jul 2010, 02:55
Neville Ridley-Smith (6 posts)

BTW Here are some screenshots showing it in action: http://benzilla.galbraiths.org/2007/01/18/i-love-intelligent-tools/ http://benzilla.galbraiths.org/2007/04/20/more-on-the-amazing-intellij-idea/

It’s under Settings->Inspections->Probable bugs->Suspicious variable/parameter name combination You can edit the names it looks for.

For example, it has one group of words “x,width,left,right” and another group “y,height,top,bottom”. In the case of parameters, it will check if the parameter declaration contains one of the words in the list and then checks if the variable name you’re passing in contains a word from the other group.

So in that second post, he’s passing in BAR_HEIGHT_DLU to a parameter named dluX. It sees the substrings x and height and complains.

Really quite simple. I can imagine scenarios where it might give a false positive but it’s probably sufficient in 99% of cases.

Nev_pragsmall
06 Jul 2010, 02:57
Neville Ridley-Smith (6 posts)

Oh and being able to colour the scope in IntelliJ is great. I can instantly know if a call is to a spring method, junit, our own server code, etc. I love this kind of readability/infovis stuff.

Headshot_pragsmall
08 Jul 2010, 13:23
Brian Tarbox (41 posts)

Nev, Thanks for the pointers, I’m starting to use IntelliJ on a particular project and while its pretty different from my be-loved Eclipse it has a lot of very cool features. I’m starting to look at custom introspections. Since both platforms support checkstyle I might focus on adding the name-analysis piece to checkstyle so I can use it anywhere. I really like the on-the-fly hints IntelliJ gives…because its unobtrusive and automatic.

You must be logged in to comment