Comparison of Java Code Quality Tools

With a growing code base, it is good to have tools which can automatically find weaknesses in it, be it duplicate code, bad patterns, possible bugs, bad formatting, or bad design. Here are some of the tools that can analyze Java Code.

Continue

Java Timing Code: Compare Execution Times of Methods

Often times, you will have two Java functions, and you will want to know which one performs better. You can use this Java class to time multiple methods to find out which one is faster.

Example Usage: Java Timing Code

Let’s say you have these two functions and want to know which one is faster:

    public static String function1(String i) {
        return i + i;
    }

    public static String function2(String i) {
        StringBuilder sb = new StringBuilder();
        sb.append(i);
        sb.append(i);
        return sb.toString();
    }

Here is how you would use my timing class:

    public static void simpleTimingTest() throws Exception {
        Timing t = new Timing();

        /*
        The timing function will run the tests in chunks.
        For each chunk, the same input will be used.

        Input will be gathered via the passed IntFunction. The timing method will
        pass the current index (going from 0 to amountRunsPerChunk) to it and will expect
        any return of the defined type.
        */

        IntFunction<string> inputProvider = i -> String.valueOf(i);

        /*
        The add method expects two functions: the above mentioned input provider,
        as well as a function which accepts the output from the input provider as input
        and applies it to the function which will be timed.
        */

        t.add((String s) -> function1(s), inputProvider, "function1 ");
        t.add((String s) -> function2(s), inputProvider, "function2 ");

        t.time(true); // true: force test (otherwise, time might throw an exception
                      // if it suspects that there isn't enough memory)
        t.output(s -> System.out.println(s), Timing.Sort.ASC);
    }

You can also do more complex things with it:

    public static void predefinedInputTimingTest() throws Exception {
        Timing t = new Timing();
        /*
        The input doesn't have to be generated using the passed index, you could
        also use predefined input to time your functions:
        */

        String[] input = new String[]{"input1", "another input", "more input"};
        IntFunction</string><string> inputProvider = i -> input[i % input.length];
        t.add((String s) -> function1(s), inputProvider, "function1 ");
        t.add((String s) -> function2(s), inputProvider, "function2 ");

        /*
        You can decide what should be reported when timing finished:
        */

        t.setReport(EnumSet.of(Timing.Report.NAME, Timing.Report.MEAN));
        t.setAmountChunks(1_500);
        t.setAmountRunsPerChunk(2_500);
        t.time(true, s -> System.out.println(s)); // pass String -> String function to report debug information
        t.output(s -> System.out.println(s), Timing.Sort.ASC);
    }
Continue

Comparison of Free UML Tools

There is a lot of different UML modelling software to choose from. Here, I will create a short overview over the most common free uml tools. This list is not meant as an exaustive review, but more to give you an idea what each of the tools can to so you have an easier time choosing the uml tool that is best for you.

Continue

Installing QGIS on LMDE (Linux Mint Debian Edition)

The solution that I found for installing qgis (Quantum GIS) on LMDE (Linux Mint Debian Edition) is not optimal, but the only one that worked for me.

I am getting QGIS directly from the QGIS Debian repository and I am temporarily adding the main debian repository to my sources, because QGIS depends on some packages that are not included in LMDE.

LMDE: Install QGIS

1. Add QGIS to your sources.lst:

sudo vim /etc/apt/sources.list
# add:
deb http://qgis.org/debian/ jessie main
deb http://ftp.us.debian.org/debian/ jessie main

After this, do not call apt-get upgrade until you removed these lines.

2. Now you can install QGIS:

sudo apt-get update
sudo apt-get install qgis

3. And at last remove the added lines from your sources.lst.

sudo vim /etc/apt/sources.list
# remove:
deb http://qgis.org/debian/ jessie main
deb http://ftp.us.debian.org/debian/ jessie main

sudo apt-get update

This step is important, as otherwise a call to apt-get upgrade could break your system.

That’s it, now QGIS should run on your installation of LMDE.

Domain Name Tools: Name suggestions, Price comparison and more

Here are a couple of tools that will help you choose and register a domain name:

domain naming tipps: A list of things to consider when choosing a domain name.

domain name suggestions generator: In case you need a good domain name idea this tool will generate a list of possible domain names on the basis of keywords provided by you and check if they are available.

compare domain name prices: Compare the prices of the top domain name registrars and filter it by price, top level domain, available payment methods and by whether or not anonymous domain name registration is possible. This will help you find the best domain name registrar for you.

domain name availability check: Test if your desired domain name is available.

If for some reason you do not like my domain name tools, check out this tool list or this one. Of course, (productive) criticism in the comments is always appreciated.