Monthly Archives: June 2010

Java Tip #5: Shorter singleton calls

If you are using the Singleton pattern, you often have code like this:

Object myValue = MySingleton.getInstance().getSomeValue();

Can this be shortened? Yes! Like in Java Tip #3, we can use public static methods and static import. But then, we do not see at a glance what getInstance() is actually returning, and if we use multiple Singletons within our class, we would have a naming problem. The easy solution: rename the getInstance() method to the (camelCase) name of its class. Now we can write:

Object myValue = mySingleton().getSomeValue();

Welcome, developers!

The last days I have replaced the old, quite complex Ant build script by a much simpler configuration file written in Java, that is based on Xenoage Build, a quick & dirty extension to Ant. I did this, because I really had problems in Ant when having multiple subprojects with different dependencies on each other. I think, the lines 34 to 58 in the new config file describe this dependencies much nicer than the old Ant script.

Additionally, I have added a tiny tutorial how to set up Zong! in Eclipse. Following these three steps, you can run and debug Zong! within two minutes on any operating system.

Developers are welcome! If there are other things we can do for you, please don’t hesitate to tell us what you need.

Iteration 51 is out

After many weeks of work, Zong! p0.4.51 is finally out. Although there are no new features which are interesting from a user’s perspective, there are two important changes which are essential for the future development of the project:

  • The core has been completely replaced. While it was based on mutable Java classes and operations using many side effects before, the core is now completely functional. It is now much easier to test and maintain, and undo/redo is now a trivial task. The new core wouldn’t be possible without the excellent work of the pcollections project, which I can really recommend for Java projects of any kind.
  • The musicxml project replaces proxymusic. While this is also a great library which I can recommend to all Java+MusicXML projects, we had problems with the Reflection techniques it is using (applets must be signed then), JAXB’s not-so-optimal XML-to-Java conversion and its speed (on my machine proxymusic needs about 2 minutes to load all official MusicXML 1.1 and MusicXML 2.0 samples, while our new musicxml library needs about 5 seconds). The two projects do basically the same, but proxymusic is automatically generated from the MusicXML schema, while our library is written by hand, which is really a very boring task, but finally it was worthwhile.

The goal for the next iterations is to rewrite the layout engine so that it fits to the functional core. Then, we can continue to improve the layout engine and support more music notation features. We also plan to offer a web service that converts MusicXML to PDF (and possibly other formats).