Last week Javablogs.com top 10


Most read last week

  1. Stupid Command Prompt Tricks (289): These Stupid (Windows) Command Prompt Tricks actually look rather useful. [read]

  2. The truth about Tudu Lists!! (260): I've now been working on Tudu Lists for more than one year, and I'm releasing today version 1.1. With this latest release, it is now time for me to tell the truth about Tudu Lists.… [read]

  3. Toplink vs hibernate (258): I still remember the excitement I felt when I started working on Toplink. It was early 2000. Before that, I was working mainly in visual c++.… [read]

  4. Why RedHat bought JBoss (249): RedHat has a market cap of roughly 20x revenues, which quite frankly is unheard of; most companies would kill to have a P/E ratio that high, let alone a price-to-sales ratio!… [read]

  5. Red Hat Acquires JBoss (214): It is official. Now the corp office is in my back yard!… [read]

  6. Google Calendar is now live (212): The subject says it all... Go ahead: log in, play around and post your suggestions and impressions as long as it's not "It doesn't work on Safari" (usually the... [read]

  7. Why is Tomcat called Tomcat (208): Every now and again the topic of why Tomcat is called Tomcat pops up and I don't know anyone who actually knew Anyway I thought I would look it up so if anyone else asked me I could tell them the… [read]

  8. RANT: Eclipse Sucks (186): Eclipse has an AI engine that realizes when I haven't used it often enough for it to have burned me recently to kick in and do something really painful to me.… [read]

  9. Top ten use case mistakes (170): Top ten use case mistakes -Tyner Blain: We’re reiterating the top five use case mistakes from Top five use case blunders and adding five more. For details on the first five, go back to that post.… [read]


Most read last week-end

  1. Top ten use case mistakes (170): Top ten use case mistakes -Tyner Blain: We’re reiterating the top five use case mistakes from Top five use case blunders and adding five more. For details on the first five, go back to that post.… [read]

  2. Netbeans versus Eclipse (155): Eclipse has been the leader of the pack for the last five years but with Netbeans becoming free, is Eclipse's title of most popular IDE coming to an end.… [read]

  3. MacBook vs. Athlon XP Java benchmark (150): So i finally made a first mini benchmark regarding my new hardware. Of course i was curious how the macBook performs against my old (somewhat outdated) PC platform.… [read]

  4. Eclipse 3.2 RC1 Released (143): Eclipse 3.2 RC1 is out and is available for download. Other Callisto release projects are releasing over the next two weeks. 39 words.… [read]

  5. 7 Hour Daily Commute (139): This person does an astonishing 7 hour commute to get to work. Everyday. And he's been doing it since 1989. I'm too astonished to criticize. Also, it's just too easy..... [read]

  6. Google Calendar - Oh so close! (135): It took me a few years to switch from Yahoo!… [read]

  7. MacBook Pro Update (121): I’m loving my new MacBook Pro, but… it’s definitely far from perfect.… [read]

  8. Next Generation Frameworks are only superficially competitors (117): There's an interesting thread over on the Grails mailing list.… [read]

  9. Is Memory Management in Java Garbage? (117): A friend of mine who was learning C# commented he felt C# was a more powerful because you had to memory manage yourself and it took more effort to create and destroy objects.… [read]


Web Services No Better Than CORBA?

Richard Monson-Haefel (RMH), author of the famous Enterprise Java Beans (O'Reilly) and of a Web Services book is making an alarming claim about JAX-WS, the new Java web services standard:
JAX-WS still sucks!
 
In an effort to write a client to real world web services (for Google, Amazon, Ebay), he mostly failed. Errors seem to be largely related to WSDL to Java conversion. Jason Green, a JBoss developer, managed to get quickly a web service working for Ebay, but analysis by RMH suggest that hundreds of classes were generated for this simple one method web service.
 
Recently I had to try to do CORBA client classes by hand in Java since the rmic tool was not working that well to generate classes that could be run on a client JVM of different version than the server JVM. It proved to be a no-go in the end, because of the complexity involved not only in coding, but more on maintaining those modified generated classes. This would have required coding a tool dedicated for that purpose. We chose to pass simpler objects, differently, which looks just like a hack to avoid having CORBA issues. I am amazed that after that many years of CORBA, there are still simple cases where it does not work properly automatically.
 
Seeing that there is the same kind of problem with Web Services (IDL to Java translation) makes me wonder about Web Services "improvement" over CORBA. And WSDL is definitely less readable than CORBA IDL.
 

Is your UML Composition French or American?

The French Way
In many French books/lessons (a lesson here, another from caen university , one from UQAM), UML composition does not seem to mean the same as their English counterparts. They write:
Si l'agrégat est détruit (ou copié), ses composants le sont aussi.
or
les composants (en tant qu'ils sont composants) ont une durée de vie incluse dans celle de leur composé.

translated to English:
If the aggregate is destroyed (or copied), its components are destroyed (or copied) as well.
or
components (while they are components) lifetime is included in the one of their aggregate

But then what does it mean to have a cardinality of 0 on the aggregate side?
Few French lessons give an answer (UQAM does, maybe because it's half French only). The component can be created before the aggregate but must be destroyed when the aggregate is.

The American Way

Most English books/lessons describe composition more accurately. Ootips definition is simple and clear:
Composition [...] is exactly like Aggregation except that the lifetime of the 'part' is controlled by the 'whole'. This control may be direct or transitive. That is, the 'whole' may take direct responsibility for creating or destroying the 'part', or it may accept an already created part, and later pass it on to some other whole that assumes responsibility for it.

However Martin Fowler in UML distilled explicitly writes:
The "no sharing" rule is the key to composition . Another assumption is that if you delete the polygon, it should automatically ensure that any owned Points also are deleted .

By using the word "assumption" he is avoiding a clear meaning. So I looked up in the UML specifications from uml.org. The specs are actually very near ootips definition and even more explicit:
An association may represent a composite aggregation (i.e., a whole/part relationship). Only binary associations can be aggregations. Composite aggregation is a strong form of aggregation that requires a part instance be included in at most one composite at a time. If a composite is deleted, all of its parts are normally deleted with it. Note that a part can (where allowed) be removed from a composite before the composite is deleted, and thus not be deleted as part of the composite. Compositions define transitive asymmetric relationships—their links form a directed, acyclic graph.

So it turns out that some French definitions were not wrong, but imprecise. Their true meaning becomes only clear after reading the English UML specs.

Ootips has also a good example of difference between aggregation and association. If you have an aggregation relation between two Node entities, it means you represent a tree of Nodes, not a graph of Nodes. See the link for more details.

Are UML Aggregation and Composition Good Concepts?

Yesterday a work collegue made the remark that the notions of aggregation and composition were not very clear. I was a bit surprised at first. But I actually almost always use just associations relations, sometimes composition, I was not sure anymore about the difference between aggregation and association and the one between composition and aggregation. I had to look up in a book to remember what it was all about.

The French book we looked at was really bad. In the end we did not understand fully the differences except a notion of "stronger coupling", some kind of "asymetry"!?! The difference between aggregation and composition was more explicit since in a composition, the "child" can only have one parent.

The UML Distilled book is much more explicit and I recommend that book to anybody doing UML:
  • Aggregation is strictly meaningless ; as a result, I recommend that you ignore it in your own diagrams .If you see it in other people's diagrams, you'll need to dig deeper to find out what they mean by it . Different authors and teams use it for very different purposes.
  • Composition is a good way of showing properties that own by value, properties to value objects (page 73), or properties that have a strong and somewhat exclusive ownership of particular other components.

Bertrand Meyer prefers to describe relationships using only two concepts, client and heir, basically UML association and specialization and therefore avoids the distinction between aggregation and composition and association:
  • B is a client of A if every object of type B may contain information about one or more objects of type A.
  • B is an heir of A if B denotes a specialized version of A.
He then uses "class invariants" to specify the nature of the client relationship.

SOA and B. Meyer

While rereading parts of Object Oriented Software Construction from B. Meyer, I still find valuable information I overlooked. In the part about functional decomposition where he argues pro and cons of top-down / bottom-up approaches, he has the intuition of the current SOA hype. By showing that

Real systems have no top.

He suggests that the only way to build complex software is through a service oriented architecture. Of course SOA is a very old concept. Meyer example of Operating Systems is a fine one.

Another interesting remark is his object motto to design an object oriented system:

Ask not first what the system does Ask what it does it to!

Bilinear Gaussian Lanczos? Downsampling!

Not easy to choose a downsampling algorithm. Some links:
  • mplayer: advises bilinear for quality and describes artifacts for each algo
  • a blogger: advises lanczos. This links shows pictures produced by each algo.
  • digital image interpolation: seems to have a preference for bicubic, what photoshop uses.
  • videohelp: tested various algorithms and think Bicubic spline is the best.
People don't seem to agree. If you want to check the theory:


Getting Started With DOM, XOM, DOM4J by Parsing an RSS Feed - An Experience Review

Recently, I looked for a way to get info from some particular blog entries of mine on blogger.com. Blogger used to offer an XML-RPC API . They even designed a version 2 of the XML-RPC API that does not seem to have ever been put in production. Or maybe I did not manage to make it work. I had no problem to make v1 work, however. I used apache XMLRPC v2, it was very simple to use. Unfortunately information accessible through XML-RPC Blogger API was incomplete for me. Furthermore, it is very likely that this API will disappear soon as it is deprecated since 2002.

Blogger wants you to use their Atom API. It is not XML RPC anymore, you have to do the parsing by hand.

The DOM Experience

I thought "no big deal, I will use DOM for it". I don't need performance and wanted a quick way to solve my problem, plus DOM does not require X number of libraries. It was easy to use regular DOM until I was frustrated by not being able to get the <content> element full text easily as it is sometimes XML. I did not want to hand code a method to do that as I thought it should be done by the XML library.

The XOM Experience

I heard previously of a simple XML parser, efficient, with an API that had been well designed, XOM. I looked at the API, there was a toXML () method to return the node content as XML (children included), sounded good. I saw there was even XPath support, and thought, great, it will simplify my code a bit. I will get the blog entries by just querying for " /feed/entry". No luck, it did not work, it returned 0 results. So I looked for mistakes in my code, did not find obvious ones. I tried other queries like " //feed/entry" or "//entry", same thing, not the right results. There must have been something wrong in my code, or maybe the XPath engine in XOM has particular settings to deal with RSS feeds (they contain various xmlns declarations). The point is that I got frustrated, it was supposed to be very simple, and in reality, not so!

The DOM4J Experience

I had experience with Dom4j before, just once, to build XML, not to parse it. I had relatively good memories of my Dom4j experience for that so I decided to try it out on my problem. At first I found Dom4j API a bit confusing as there are so many methods on most used classes. This is because Dom4j is DOM compatible. But I quickly understand the logic of it and found some very useful methods, namely Element.elements(name) to get all children elements by name. Of course, they have an asXML() method like XOM. There is also XPath support.
I tried the XPath on Blogger RSS without success again. There really must be a trick to get it to recognize RSS. But with the elements("entry") method, I very quickly got the same with not much more code, and it worked.

so DOM vs. XOM vs. DOM4J = 0 - 0 - 1

Example Code:

SAXReader reader = new SAXReader();
Document doc = reader.read(response);
Collection posts = new ArrayList();
List entries = doc.getRootElement().elements("entry");
if (LOG.isDebugEnabled())
{
LOG.debug("found "+entries.size()+" entries");
}
for (int i = 0; i <entries.size();i++)
{
Element entry = (Element) entries.get(i);
Map m = new HashMap();
for (Iterator it = entry.elementIterator();it.hasNext();)
{
Element detail = (Element) it.next();
String name = detail.getName();
if (name.equals("link"))
{
m.put("link",detail.attribute("href").getValue());
}
else if (name.equals("content"))
{
m.put("content",detail.asXML());
}
else
{
m.put(name,detail.getTextTrim());
}
}

posts.add(m);
if (LOG.isDebugEnabled())
{
LOG.debug("found="+m.get("title")+", url="+m.get("link"));
}
}

Bad JDK Design Example

Have you ever used the Authenticator class? It is standard since JDK 1.2. This allows you to establish authenticated HTTP requests. OnJava has an in-depth article presenting it. Now here is my story about it.

The other day I just wanted to do that a simple authenticated HTTP request. You would expect it to be very simple to do in the modern internet world.

It is actually not very difficult to do, by hand, a JavaWorld article presents this way. Unfortunately it uses internal JDK sun classes for Digest and I am uncomfortable to use that since it is not guaranteed to work on any JVM. So I have to download jakarta commons-codec to just do a simple authenticated HTTP request. I really wonder why some of those codecs are not in the JDK (not as sun.* classes but as java.* classes).

When I read that it was possible to do it a standard way in JDK 1.2, I was excited. I was wrong. Not only you have to extend a class (ok, implementation is faily simple) that adds in my mind unnecessary clutter, but you are forced to have only 1 Authenticator at a given time (and this Authenticator scope seems much wider than just securing HTTP connection). What about server programs dealing with different credentials?

So I am left downloading jarkata httpclient library that is more powerful and easier to use than hand coded digest authentication (that anyway needs common codecs) just to have HTTP authentication the way it should be done.

Current Popular Subjects In Java Blogs

Based on my blogs entries and success of other blog entries, I present the current trendy subjects and the not trendy ones:

In:

  • Design Patterns
  • Ruby on Rails
  • EJB (bashing)
  • RSS
  • Spring
  • Hibernate
  • Javascript and AJAX
  • Java Virtual Machine

Out:

  • RMI
  • Portal
  • Jini

Neutral

  • JDK 5 features

As you can see most of the popular stuff is fairly common, not that new. I will do a finer, less common, analysis later if I have time.

Previous

Next