Archive for the 'Programming' Category

Using Sections in Java Classes

In last month’s discussion started by Martin Fowler’s article on humane interfaces, some people mentioned Smalltalk’s method categories. These categories supposedly serve to bring order to classes containing large number of methods. I wonder if something like that would work for Java. (Personally, I wouldn’t call them ‘categories’, as categories imply that you can assign multiple categories to a method as well as multiple methods to a category.) For example, you could have:

public class String {

    section getters {
        public char charAt(int index) {
            // ...
        }
        // ...
    }

    section testers {
        public int compareTo(String anotherString) {
            // ...
        }
        // ...
    }

    section mutators {
        public String replace(char oldChar, char newChar) {
            // ...
        }
        // ...
    }

    section finders {
        public int indexOf(String str) {
            // ...
        }
        // ...
    }

    // ...

}

The section names would not be used anywhere else in the code, so you don’t use "text".finders.indexOf("e"). Their use would be limited to sorting method names in IDEs, JavaDoc etc. So it would make sense to add JavaDoc to the sections, like this:

public class String {

    /**
     * Groups methods retrieving parts of the String object
     * or its attributes.
     */
    section getters {
        public char charAt(int index) {
            // ...
        }
        // ...
    }

One possible functional use for sections would be to allow access modifiers to sections, so you could have a public section businessMethods and a private section privateMethods.

There would have to be additional rules about inheriting sections in subclasses, using sections in interfaces, having methods outside sections, naming standards for recurring types of sections and such things.

The question is: does Java need something like this? The String class isn’t that huge, doesn’t have hundreds of methods like Smalltalk classes seem to have (note to self: read Smalltalk primer). I was triggered, actually, by a comment earlier on this blog, about the DefaultOWLIndividual class. It’s an example of a Java class that does have 300+ methods. A class like that would certainly benefit from (inherited!) class sections. I’m sure there are many more examples of large classes like this one.

But even if a class is not that humongous, even if it only has 10 or 20 methods; wouldn’t it still make the interface design more clear and structured if it had sections? It could also show better the intended use of the methods in the class (business methods vs. private methods). So I think sections could be a useful addition to the Java syntax.

2006-01-02. 3 responses.

BEA WebLogic Ready for Ruby?

BEA’s Bill Roth (vp of the BEA Workshop Business Unit) hinted at JavaPolis and later in his blog and a LogicCMG blog at the possibility of WebLogic server supporting other languages than Java, like PHP or Ruby. I think this is an interesting idea. If, for instance, Ruby or Rails applications could be deployed to a WebLogic server, maybe you could use data sources or JMS queues from within Ruby code, or even call EJBs. You could profit from WebLogic’s scalability. Another advantage I see is that with BEA ‘supporting’ Ruby, it would be much easier to use Ruby in a corporate environment (that is, if they use BEA in the first place). BEA, bring it on!

(Note that I’m silently ignoring the mention of PHP here. Mentioning PHP and Ruby together does not do justice to Ruby; too many people I speak already think Ruby is just another PHP variant. I think BEA would actually lose credibility if they were to support PHP.)

2005-12-20. No responses.

Final Thoughts on JavaPolis 2005, Part 2: Is JavaPolis the European JavaOne?

In Thursday’s keynote, JavaPolis founder Stephan Janssen asked whether JavaPolis should grow even bigger, and because of that, move to a bigger location. According to the official site this year over 2100 people attended the conference. I don’t think there’s a clear answer to Stephan’s question. JavaPolis had a very friendly, cosy atmosphere; I never had the feeling there were 2100 people around. All the stands were well accessible, there was always a seat left even in the most popular sessions. Maybe 2100 is just right. On the other hand, if JavaPolis really wants to be ‘the European JavaOne’ (as I’ve heard people say more than once) I think it’s not nearly big enough. I would expect much more sessions, high-quality sessions even on Friday (see below), more big names in the speakers department and a bigger exposition room with more companies and bigger stands. I wouldn’t mind paying a little more either if it were that big.
Continue Reading »

2005-12-20. No responses.

Final Thoughts on JavaPolis 2005, Part 1

Not being able to blog live during JavaPolis 2005 leaves me with several pages filled with scribbled notes on the various presentations. I’m glad that JavaPolis 2006 is said to feature free on-site WiFi access (you read it here first!). But even so, I’m not sure how easy it is to blog live on the spot. My laptop is rather big and heavy to carry around, it always finds a way to play the Windows welcome jingle when it boots up, no matter what settings I tweak, and it’s actually difficult to focus on the presentation and write a cohesive, intelligible blog entry.
So, about these notes. Thursday I saw…
Continue Reading »

2005-12-19. No responses.

On the Rails Again

Back from JavaPolis, and seeing the Rails book lying where I’ve left it last Tuesday, made me pick it up and continue reading — instead of looking into GlassFish, the new persistency API, JSF and all the other new stuff I’ve seen in Antwerpen. It’s all alpha, beta, preview releases; and even if it isn’t it’s still so far away: Jeroen (colleague also attending JavaPolis) and I figured we’re lucky if we’ll be able to use Java SE 5 in our daily work (read: in BEA WebLogic) by the end of 2006 (when Mustang, Java 6 is already out), and Java EE 5 by the end of 2007 (when Dolphin, Java 7 is out). Two years and two more Java versions before we can use the technology we’ve been presented this week! So I’ve more or less lost interest momentarily and gone back on track with Rails.

There was very little mention of Ruby at JavaPolis. None of the people I spoke with had actually done anything with Ruby. What I did see:
Continue Reading »

2005-12-17. 8 responses.

« Prev - Next »