Ary Borenszweig

Ary Borenszweig

Ary is a software craftsman, he is our guru in all code-related problems. Always teaching how to develop the best code with simplicity in mind, he makes everything seem easy no matter how difficult, to the point that nothing seems impossible with him on the team. Very optimistic (sometimes too much), he has the ability to put any idea into code in almost no time.

Eclipse Plugin to sort proposals by hierarchy

Again, Sergio, a friend of mine, came up with a need: to sort Eclipse Java proposals by hierarchy. What that means is that if you have a type C < B < A (where < means subclass of), first C‘s methods will be shown, then B‘s methods and finally A‘s methods.

This is specially useful when writing GUI code with libraries like Swing or SWT, because when you request a ComboBox‘s members you’d normally want to set or change the items to show, what to do when you select an item, maybe less often what’s the size of the component, etc. You’d almost never use methods in bottom-level classes like Object.

So I made a plugin that does exactly that. And better: the proposals are first sort by hierarchy and then by relevance (JDT‘s default order which takes into account, for example, the type of the expected expression).

You can download a copy for free that comes with the source code. To active it first copy the JAR into your plugins directory. Then open Eclipse and go to Windows -> Preferences -> Java -> Editor -> Content Assist and select “by hierarchy” in the combo “Sort proposals”.

Enjoy!

Black theme for Eclipse

A friend of mine just asked me if I had a black theme for Eclipse similar to this one. I didn’t, so I made one. Here’s the result (click to enlarge):

A screenshot of the Black Theme for Eclipse

You can download a copy of it. To start using it you must extract the zip file in

$workspace.metadata.pluginsorg.eclipse.core.runtime.settings

where $workspace is your workspace location.

Enjoy!

Neyun: an awesome way to visualize your content

As you might already read here and here, the beta release of Neyun is finally with us!

In a nutshell: it’s a web application that allows you to extract your emails, contacts, photos, videos and more from services like Gmail, Facebook, YouTube and Twitter and see them all at once.

So… why use Neyun when you already have access to all these services in their websites? Well, Neyun allows you do do some things you can’t do otherwise, for example:

  • Since all your information is accessible in a single place you can search over all your content at once and find results in your emails, photos, videos, etc.
  • Even wanted to search photos in Facebook? Just connect your Facebook account to Neyun and search!
  • Want to see your friends’ birthdays in a nice way? Turn on the timeline and drag the “Contact” icon to the left.
  • Want to see some photos in a cool way? First search or filter your content as you wish and then turn on Cool Iris. For me, that’s one of the coolest features in Neyun.
  • See a tag cloud of all your content.
  • Explore all your stuff in a timeline so you can quickly see, for example, which mails and twitters your receieved, and which photos you uploaded when you graduated.

I must say I’m pretty excited about this new application. I think you’ll love it, specially if you are into all this cool applications.

There are sure a lot of other nice things you can do with Neyun. If you find something cool you can do with it please send me a comment!

Indentation also means something else…

Some days ago I read this in the Digital Mars D programming language newsgroup.

bearophile says:

From:
http://jeremymanson.blogspot.com/2009/02/small-language-changes-for-jdk7.html

Automated Resource Blocks, to be able to say things like:

try (BufferedReader br = new BufferedReader(new FileReader(path)) {
    return br.readLine();
}

instead of:

BufferedReader br = new BufferedReader(new FileReader(path));
try {
    return br.readLine();
} finally {
    br.close();
}

and Andrei Alexandrescu (one of the designers behind the language) replies:

They keep on missing the point that the blessed code on the normal path must not take the hit of an extra indentation level.

And he’s so right!

In D you’d write it like this:

Disposable disp = new Disposable();
scope(exit) disp.dispose(); // you can use braces too: scope(exit) { }

disp.doSomething();
disp.doSomethingElse();

I think this concept is really important. You want the important logic of your method to be always at the same indentation level. The things that, well, you need to do to cleanup things, catch errors, etc., should be on a separate indentation level so that the reader of the code (and that can be you, later!) understands it better.

That’s why I prefer this:

void process(Foo someObject) {
  if (isNotValidForThisFunctionBecauseOfBar(someObject))
    return;

  if (isNotValidForThisFunctionBecauseOfBaz(someObject))
    return;

  // do something else with someObject
}

instead of this:

void process(Foo someObject) {
  if (isValidForThisFunctionBecauseOfBar(someObject)) {
    if (isValidForThisFunctionBecauseOfBaz(someObject)) {
      // do something with someObject
    }
  }
}

Those last indentation levels are distracting. They are forcing you to read on cascade. The first example clearly marks which are the invalid values for the function, or the exceptional values to be handled, while the second one mixes those conditions with the main logic.