Monthly Archives: December 2013

Paid per line programming code? – Why I love refactoring

Earlier this month I’ve started to read a new book called “Effective Java“. Jesse Gallagher mentioned this book as a “must read”. After my positive journey with reading “Design Pattern” (The head first edition) was it no question that I definitely read the sample of “Effective Java”. And yes, after reading the sample, I bought it. (To my colleges at WebGate: Yes be afraid – I have now a new book – Ho Ho Ho).

But reading a book without bring the new knowledge into the daily work is only the half of fun. So where to start? One of the first thing that has attracted me while reading “Effective Java” was the initialization of a Singleton.

A Singleton is an object, which exist only one time in specific context like a jvm, plugin or a XPages Application. The “normal” code to initialize a singleton is the following construct:

public class DocumentProcessor {
private static DocumentProcessor m_Processor;
private DocumentProcessor() {

public static DocumentProcessor getInstance() {
if (m_Processor == null) {
m_Processor = new DocumentProcessor();
return m_Processor;

One of the disadvantage of this code is, that this code is not “safe” if you try to create an instance of DocumentProcessor with Java Reflection and modifying the constructor. The other thing that I’m not loving is the amount of code, that I always have to write. But Joshua Bloch explains a simple way with enums to have a singleton look at this code:

public enum DocumentProcessor {

How smart is this! And not much code. I’m not paid per line of code I write, so it’s not touching my income :). Now you can access with DocumentProcessor.INSTANCE the singleton. It’s very cool, but what, if I have already a lots of Singleton? How can I make that my code will not break the code of other clients (classes which calls my API).

Remember all client classes call the current code (before refactoring) with WordProcessor.getInstance(). I can easy change this in my classes, but external clients which calls my WordProcessor will fail, when the do not have the WordProcessor.getInstance().

The following code is a “defensive” approach which makes this safe to all the other clients:

public enum DocumentProcessor {

* gets the Instance of the DocumentProcessor.
* @deprecated -> Use DocumentProcessor.INSTANCE instead
* @return Instance of the DocumentProcessor
public static DocumentProcessor getInstance() {
return DocumentProcessor.INSTANCE;

This code is not only safe, it gives the other developer also an instruction, how to adapt the new API.

Will I now go to all my code (and it’s a lot of code I wrote each year) and change this all? And what about all the other cools stuff that I will learn while reading the book?

No, that’s not my approach. But I will challenge my code, myself and later the WebGate Development Team with the knowledge. Each code that I’ve to touch will also be reviewed with my new knowledge.

Have fun


1 Comment

Posted by on December 21, 2013 in Design Pattern, Domino, Java, XPages


Replay: A Deep Dive into OpenNTF Essentials

Leave a comment

Posted by on December 18, 2013 in Domino, IBM, Java, OpenNTF, XPages, XPT


Ready for todays webinar about OpenNTF Essentials?

I hope that you have already dowloaded OpenNTF Essentials and at least installed on your development computer. If not, it’s a 5 minute job as you can see in this youtube video (starting 12:00).

In Todays webinar, Mark will cover some cool stuff about debugging and Nathan takes a deep dive into the OpenNTF Domino API. My part will be about some cool @nnotations. Imagine this:

Your are writing a call center application and you have designed the “Call” object as a java object according the java bean specification. With the ObjectData Source from the ExtLib are you know ready to edit each field of this java object, but now you have to save….. and read …. and delete ….. the object from the database.

I will show you in todays webinar how you can do this with writing only “3 or 4” lines of code 🙂

I hope you will join us, today 10:30 EST, register now!

Leave a comment

Posted by on December 12, 2013 in Architektur, Design Pattern, Domino, Java, OpenNTF, XPT


OpenNTF Essentials deployed in a production enviroment!

Today has the WebGate Development Team done the first rollout of OpenNTF Essentials into a production environment. It’s very cool to see this fast adoption in the own company. And to be honest, I was really surprised by this high pace. The funniest thing was that the information, that OpenNTF Essentials will be installed, came accidentally to me. A short dive into the code shows to me that our team was first using the things that comes from WebGate, but I see on the development stream also the usage of Bootstrap4XPages and first steps into the OpenNTF Domino API.

This shows me, that it is time for a deep dive into OpenNTF Essentials and I’m glad that I can invite you to join us this Thursday, December 12th, at 10:30 A.M. to 12:00 (U.S. Eastern time) on a Webinar held by TLCC and Teamstudio.

The last time, we showed you why, now it’s time for the how.

Comments Off on OpenNTF Essentials deployed in a production enviroment!

Posted by on December 10, 2013 in Uncategorized