Posted by Jakub Holý on November 30, 2010
This month has been quite interesting, among others I ‘ve picked up several blogs by Adam Bien. I really like his brief, practical and insightful posts :-)
Java, Jave EE, architecture etc.
- EJB 3.1 + Hessian = (Almost) Perfect Binary Remoting – “With hessian it is very easy to expose existing Java-interfaces with almost no overhead. Hessian is also extremely (better than IIOP and far better than SOAP) fast and scalable.” See also the discussion regarding a “DynamicHessianServlet” (which would be more comfortable then creating a new servlet for each service).
- Binary XML – Fast Infoset performance results – FI is the name of a standard for binary XML encoding and also of its OSS implementation; according to these measurements (with default settings, compared to Xerces 2.7.1), on average: The FI SAX parser is about 5 times faster than the Xerces SAX parser, the FI DOM serializer (using default settings) is 25% to 30% faster than the Xerces DOM XMLSerializer, and FI documents are 40% to 60% smaller than XML documents (i.e. it can provide modest to good compression). And: “The use of external vocabularies can be a very effective way to increase the efficiency of parsing, serializing and size at the expense of the fast infoset documents no longer being self-describing … .”
For the interested ones: FI is built on ASN.1, a standard for describing data structures in a way that is independent of machine architecture and implementation language, it also includes a selection on different binary encoding rules, e.g. DER (triplets tag id – length – value).
- EJB 3.1 And REST – The Lightweight Hybrid – Why to use @Stateless – there have been recently discussion about Spring vs. EJB and whether @Stateless is of any use. According to this article, the added value of EJB (though some are provided also by Spring) include injection capabilities, transactions, single threading model (for why that is good see #2 on Why I like EJB 3.0/3.1), visibility in JMX, concurrency restriction via thread/bean pools.
- Why Service Isn’t A ServiceFacade, But ServiceFacade Is Sometimes A Service…
- Experiences from migrating Hyperic 4.5 from EJB/JBoss to Spring/Tomcat, what good has it brought – simplified unit and integration tests, simplified code thanks to Jdbc/JmsTemplate, … (My comment: EJB 3.1 would certainly bring at least some of the advantages too.)
Performance – large JVM heaps are very much feasible
- Tuning the IBM JVM for large heaps – tuning 64b IBM JVM 6 with 100GB heap to have acceptable GC times (~ 1/2s as opposed to 25s with the default settings)
- BigMemory: Heap Envy – there have been recently a lot of fuss about Terracotta’s new BigMemory, a GC-resistent many GB cache space (using NIO byte buffer). This post discusses it’s disadvantages and compares it with a solution based on ConcurrentHashMap, comming to the conclusion that the old good ConcurrentHashMap outperforms BigMemory considerably.
Posted in j2ee, Languages, Top links of month | Tagged: java, javaEE, jvm, Maven, performance, spring, tdd, xml | Comments Off on Most interesting links of November
Posted by Jakub Holý on November 25, 2010
I had high expectations for Martin Fowler’s Refactoring (1999/2002) but it turned out that both me and the book are too old. It had some interesting parts, but the main one – the refactoring catalog itself – had little new for me because I already know most of the refactorings and the description of steps how to perform them safely is nowadays essentially useless as they’re already automatically and safely performed by our IDEs.
I’ve enjoyed chapter 1 with a nice example of how bad code is turned into a nice one via a series of refactorings and I’d recommend it to any beginning developer. For others than me also chapter 2 may be useful, it explains why and when to refactor, how it impacts your development speed and how to justify it to the manager. I’d skip chapter 3 – bad smells in the code – and read instead of it the Uncle Bob’s lovely Clean Code , which is a great justification and basis for refactoring anyway.
In the catalog I’ve appreciated the description of some refactorings for various reasons, such as 6.4 Replace Temp with Query, 8.14 Replace Type Code with Subclasses, 9.7 Introduce Null Object, 9.8 Introduce Assertion. Of course also the other ones are good but they are just too familiar to me and my IDE to draw my attention anymore.
Chapter 12, Big Refactorings, is quite interesting, especially Tease Apart Inheritance.
Finally there are some good advices in Putting It All Together by Kent Beck, such as that it’s good to know when to stop and to be able to resist the temptation to refactor too much at once.
I’ve also appreciated the “war stories”, especially regarding performance tuning, where once again it’s demonstrated that a guess (however founded) is incomparable to hard evidence.
If you do refactorings daily, perhaps skip the book. If not, read chapter 1, perhaps browse through 2 and 12, check whether anything catches your eye in the refactoring catalog table of content, read Kent’s closing chapter and return the book to the local museum.
Posted in Languages | Tagged: book, java, refactoring, review | Comments Off on Book review: Refactoring by Martin Fowler
Posted by Jakub Holý on November 23, 2010
With Subversive it may happen that it completely ignores some projects while it perfectly works for other ones. If a project seems to have no SVN information in Eclipse (thoug it actually contains all the .svn/ folders) and the Team context manu only contains Apply Patch… (i.e. especially not Share project…) then you have likely mixed up Eclipse metadata about the project (for instance by sharing it previously with Subclipse).
This is a well known problem and the solution is to Delete the project (without deleting its content) and to re-import it into Eclipse. Also make sure that the Subversive back-end version supports the version of Subversion (too many *versions here :)) recorded in the project metadata. If needed, you can use a script to up/down-grade the SVN metadata, as described in a FAQ.
Posted in eclipse, Tools | Tagged: eclipse, subversion, subversive | Comments Off on More Eclipse & svn fun: Can’t share a project (only Team – Apply Patch)
Posted by Jakub Holý on November 23, 2010
Subversion is at times really annoying and difficult to use due to its cryptic and confusing error messages and unnecessary failures. An example is when you have an svn-managed folder (‘svnProject’) where svn -u status and svn info and even commiting individual files work correctly but commit of the complete folder (which is necessary e.g. if you’ve changes some SVN proprties such as svn:ignore) fails:
.../rootFolder/svnProject$ svn commit .
svn: '/path/to/my/rootFolder' has no ancestry information
There is an easy fix.
Read the rest of this entry »
Posted in Tools | Tagged: scm, subversion | 3 Comments »
Posted by Jakub Holý on November 19, 2010
When you migrate an application using Apache Axis 1.2 from Java 4 or 5 to Java 6 (JRE 1.6) you will most likely encounter a handful of strange SOAP/SAAJ/XML errors and ClassCastExceptions. This is due to the fact that Sun’s implementation of SAAJ 1.3 has been integrated directly into the 1.6 JRE. Due to this integration it’s loaded by the bootstrap class loader and thus cannot see various classes that you might be referencing in your old code.
As mentioned on Spring pages:
Java 1.6 ships with SAAJ 1.3, JAXB 2.0, and JAXP 1.4 (a custom version of Xerces and Xalan). Overriding these libraries by putting different version on the classpath will result in various classloading issues, or exceptions in org.apache.xml.serializer.ToXMLSAXHandler. The only option for using more recent versions is to put the newer version in the endorsed directory (see above).
Fortunately, there is a simple solution, at least for Axis 1.2. Read the rest of this entry »
Posted in Languages | Tagged: java, java6, migration, soap, xml | 3 Comments »
Posted by Jakub Holý on November 18, 2010
There is an easy way how to save many man-days and thus also money on a project by adding some work to the key team members. You must be thinking that I’m crazy if I want to add even more work to the already overloaded senior developers and an architect but I’m sure you will agree at the end. The additional work, which will later save you many, many more, are code reviews and pair programming of an inexperienced and a senior developer. Read the rest of this entry »
Posted in General | Tagged: opinion | 1 Comment »
Posted by Jakub Holý on November 17, 2010
I know that I’m not a good programmer and this knowledge makes me actually a very good one. As Kent Beck says: “I’m not an excellent programmer, I’m just a good one with excellent habits.”  I know I’m a bad (read “a little above average”, if you plan to hire me ;-)) programmer and therefore my code will contain bugs. So I like to write unit tests even before the code itself, and I prefer having the test fail first for thus I’m sure that it works (well, at least in a basic way). Being a bad programmer I also know that my design isn’t perfect and no matter how hard I try it’s very likely that it will need to be changed in the future. I therefore don’t try to account for all possible future changes and to make it so flexible that it could deal with all of them because I know I’d be wrong in this. Instead, I prefer simple designs and well isolated parts of code so that it will be easy to reorganize and refactor them as needed. Last but not least, knowing my weaknesses I appreciate very much when somebody else reviews my design and code and I’m very receptive of different points of view and ideas. For the same reason I do not hesitate to ask my collegues for an opinion or an advice when I’m unsure. (Kent Beck yeasterday twittered: “amazing how fast you can finish if you care more about feedback than avoiding criticism”.)
The net result is that I create a simple, well-tested code open to changes (i.e. easy to change in a safe manner), which is easy to read an understand (for I know that somebody will need to modify it many times, often the somebody being an older myself). And because I’m not afraid to ask, I’ve better and more suitable designs than I could create just by myself. Thus I produce a good, clean code as a good programmer would write.
 M. Fowler – Refactoring, page 73 in the Czech translation
 R.C. Martin (ed.) – Clean Code: A Handbook of Agile Software Craftsmanship
Posted in General | Tagged: development, opinion | Comments Off on Knowing I’m Bad Programmer Makes Me Good Programmer
Posted by Jakub Holý on November 2, 2010
The useful Eclipse action Search – Occurrences in File – Identifier has by default the shortcut Control+Shift+U. But under Gnome the shortcut Control+Shift+U is used for Unicode character input, indicated by an underlined u when pressed. Assigning a different shortcut is easy but there are few “traps”:
- In Eclipse, go to Window – Preferences – General – Keys
- Type the filter occurr and click on “Shows the Occurrences in File Quick Menu“. Do not confuse it with “Occurences in File” (binding C+S+A, when Editing in Structured T. Ed.)!
- Make sure that When is “In Windows“, Category is “Search“
- Click [Unbind Command], click into the Binding field and type the keys that you want. Beware that some keys could conflict with existing bindings or global Gnome/system bindings. For me e.g. Control+Shift+S or F8 worked (though I might have to unbind conflicting bindings, I don’t remember anymore).
Environment: Eclipse 3.5, Gnome 2.30.2, Ubuntu 10.04.
Posted in eclipse, Tools | Tagged: eclipse, gnome | Comments Off on Tip: Enable a shortcut for Occurrences in File in Eclipse under Gnome (default C+S+u)