IntelliJ Hilarity

Note that this is a very lame post. IntelliJ IDEA is the greatest Java IDE in the world, his post does not “diss” it in any way, just pointing out something that was funny to me and only so because I’ve been at it for quite some time now.

I often have IntelliJ generate the equals() and hashCode() methods for me when programming @Entity beans. Here’s what it did for me:

equals

Makes sense, but notice how the last if statement is highlighted? That’s IntelliJ’s way of telling me that it can make things better which is a little weird because IntelliJ’s the guy that generated the code for me. Anyway, I see what the hint has to say:

hint

It’s saying that it can make some of these ifs redundant and sure enough once I take the hint the return clause is joined with last if like so:

first-hint

It’s all good but notice now that it now highlighted the previous if statement and if I accept it, it’ll continue doing the same thing over and over again. I’ll accept all the improvements it wants to make and I’ll finally end up with this method which is logically equivalent to what I showed you in the first picture:

final

The difference isn’t that great in an entity with three properties but you get the point about tertiary statements and IntelliJ”s love for them.

One Comment

  1. Posted March 1, 2009 at 12:05 pm | Permalink

    Just passing by.Btw, your website have great content!

    _________________________________
    Making Money $150 An Hour


Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*