Turn On/Off Word Wrap in Notepad++

One thing I always forget is how to enable word wrap in Notepad++. Some time ago I needed that option and as usual I forgot how to enable it. After some google research I found how to do it (it is actually pretty simple). Continue reading →


Are we becoming cyborgs without knowing it?

I recently watched a TED talk done by Ray Kurzweil (check out his current book) about future inventoins that will be possible because of the advanced technology we have today and we will have in about 5 to 10 years. I had a very strange feeling especially during the end of the talk. The things he mentions sounded too futuristic. For example, according to Kurzweil it will be possible in about 2020 to produce nano-robots that are about the size of a red blood cell. These robots can then travel through our veins and search for viruses or bakteria. Also we may be able to replace our red blood cells with improved but artificial ones to improve our oxygen supply. With these improvement we could sprint for 15 minutes without taking a breath. We maybe even have reverse-engineered our brain.
Continue reading →

Prevent Google+ users from emailing you

Two days ago I received an email from google that informed me that any Google+ user can now send me emails. Although this might be a handy thing, especially if someone that you’ve circled but doesn’t know you email address wants to send you an email, I’m not quiet sure if I like it that basically anybody can send me an email.

Google+ LogoIf you don’t want anybody to be able to send you emails you can change that by following these three steps:

  1. Open Gmail in your browser and click on the Settings button.
  2. On the popup menu that appears under the Settings button click “Settings” again.
  3. On the general tab of the Settings page search for “Email via Google+” and select the option you want.

Singleton – Design Pattern or Antipattern

The Singleton pattern divides the minds of Software Developers / Architects around the world. One part says it is a design pattern that should be used. The other part says it is an anti pattern that only makes code worse.

The Singleton pattern is one of the patterns that is known and used by a lot of people. This is because it is really easy to understand and implement. Because it is so easy to implement and therefore to share data between every part of the application, a lot of people don’t think about it if they really need it. Additionally the rise of Dependency Injection tools made this pattern kind of obsolete.

But is so bad about Singletons at all? There are three main reasons why you should not use this pattern:

  1. It is difficult to test
    Since there is only one instance of each singleton after each test the singletons data was changed. This makes it a lot harder to test.
  2. It produces concurrecy problems
    Since there is only one instance of the singleton, concurrency problems might occur. Therefore you need to watch out for possible concurrency problems.
  3. You cannot control the instantiation and destruction
    The singleton is created when it is used for the first time. After that the instance is held in a static field. In Java this instance will only be released when the class is unloaded which happens when the class is unloaded (which happens very sparely most of the time when the application is closed).

But there is one situation where I think it is ok to use the singleton pattern. When you need one single place to store some data globally, so that it can be access the whole application, as a global cache or something like this. If it is possible to use dependency injection, use it!

As a conclustion I would say you can use the singleton pattern when you think about it if your think it is appropriate.

How to add Code to a Word document

It sometimes occur that you need to add code to a document. First of all, if you have the choice I would recommend to use Latex because I think it is just better than Microsoft Word (at least for larger documents).

I recently had to use Word and wanted to add a small code snippet. After some short googeling I found a really nice solution how to accomplish that (see http://stackoverflow.com/q/387453/1140338). There are four simple steps that need to be done to add code to your document (without ruining your entire formatting).

  1. Go to the “Insert” tab and click on the “Object” button on the right.
  2. Search and select “OpenDocument Text” and click ok. This will open a new document.
  3. Copy and paste your code from Eclipse/Visual Studio.
  4. Save and close the document.

That’s it, you’ve added your code snippet to your document without the risk of ruining the entire formatting of your document.

The Singleton Pattern and the concurrent way of life

In a previous post I’ve described how to implement the Singleton pattern. I also explained there that you should make the static getInstance method synchronized to make the Singleton work for a concurrent system.
I recently was told about a better version of making Singletons ready for multiple thread systems. It was developed by Bill Pugh and works with a static inner class that holds an instance of the actual Singleton. Here is the code:

public class Singleton {
    protected Singleton() {
        // make the constructor protected if you
        // want to derive from this class

    private static class SingletonInstanceHolder {
        public static final Singleton INSTANCE = new Singleton();

    public static Singleton getInstance() {
        return SingletonInstanceHolder.INSTANCE;

I really like this method because it is much faster than the synchronized getInstance method, it is thread safe and it is also lazy loaded without producing that much overhead. So think about this method when you need to make a class a Singleton the next time!