The Artima Developer Community
Sponsored Link

Java Buzz Forum
Open Letter to Geertjan Wielenga

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Wilfred Springer

Posts: 176
Nickname: springerw
Registered: Sep, 2006

Wilfred Springer is a Software Architect at Xebia
Open Letter to Geertjan Wielenga Posted: Jun 26, 2009 3:05 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Wilfred Springer.
Original Post: Open Letter to Geertjan Wielenga
Feed Title: Xebia Blog » Wilfred Springer
Feed URL: http://blog.xebia.com/author/wspringer/feed/?category=java
Feed Description: Crazy ideas. Read this blog at your own risk.
Latest Java Buzz Posts
Latest Java Buzz Posts by Wilfred Springer
Latest Posts From Xebia Blog » Wilfred Springer

Advertisement

Geertjan Wielenga has been trying to pull me back into the NetBeans community for a couple of years in a row now. I admire his perseverance; if this is typical for the whole NetBeans team, then Eclipse is going out of the window some day soon.

There is one thing - really, just one thing - that would make me drop Eclipse immediately in favor of NetBeans. That's having better support for fluent interfaces in the way the IDE formats source code.

Now, I've been working on a couple of fluent interfaces over the last couple of years, and it's just awesome. It will always result in code that is easier to read, and it doesn't cost you a dime; you get the benefits of Java 5 type safety , without sacrificing readability.

Let's take this Pecia example:

doc
    .section("Introduction")
        .para()
            .text("This is a document. Make sure you also check out the ")
            .emphasis("next").text(" section.")
        .end()
    .end()
    .section("Conclusion")
        .para("That's all folks.")
    .end()
.end();

Now, IMHO, this is pretty easy to read and understand. The layout of your code clearly reflects the structure of the underlying document model. However, if you press Command-Shift-F to format your code, this is what you get:

doc.section("Introduction").para().text("This is a document. Make sure you also check out the ").emphasis("next").text(" section.").end().end().section("Conclusion").para("That's all folks.").end().end();

Not quite as good as what we had before.

Now, I would love to have a solution that basically prevented this. I was thinking about this for a while, and I could imagine introducing a couple of annotations for it. Annotations for fluent interfaces. Annotations that basically tell your IDE how to treat different components in your fluent interfaces for formatting.

Maybe annotations on the type of object produced by the section() operation, informing the compiler to treat this object as a "code block", in terms of the indentation. And perhaps an annotation on the .end() method telling the IDE to consider it the end of the "code block".

test1

So, this is to you Geertjan: I solemnly swear to erase Eclipse from my hard disk, as soon as something like this gets implemented in NetBeans. Maybe an annotation based approach is what is needed, maybe it isn't; I don't really care, as long as something gets done about this.

(If anyone else has some thoughts on this, I'd be happy to hear about it.)

Bookmark

Read: Open Letter to Geertjan Wielenga

Topic: James Gosling Hosts the Toy Show Previous Topic   Next Topic Topic: Top 10 ways to Speed Up and Boot your PC faster

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use