Java game library

I am a senior in high school and I created a game library in java in approximately 2 months time. I created this library solely for the purpose of testing to see what I could do/learn. This question is directed at other Java programmers, what do you think of the library?

The library can be found here on GitHub.

After a 3-second look here’s your first problem: use a build system. Gradle is my build system of choice as well as many others’.

You do have a few performance/some non-standard formatting, like method generics next to the return type is a no-no, add whitespace. Also the javadoc comments, they start after the /* not one line after it. The performance issues I see are relatively minor, however, I found these:

    public static int newObject(Object object) {
        objectMap.put(object.hashCode(), object);
        return object.hashCode();

In this case, you want to have the hash code in a local variable and use that instead of calculating twice. In the same class (, you have initialization in a static block. Personally, I think it is more preferable to eager initialize it, and turn into a constant instead of static load init.

In your EventDispatcher class, the same thing with initialization. You want to finalize the field and initialize with the declaration, but while inlined initialization is optional, finalizing fields is good practice.

Also, since EventDispatcher is a performance critical class, you may want to move as much of the heavy lifting away from the dispatch method as possible, which I am looking at the getMethods(…) method. You should place the ArrayList with the event type instead of by listener, which would allow you to get the whole list immediately instead of copying over to a new one based of listener instances.

You also happen to use a load of reflection, while not necessarily bad, it’s… Not preferable.

1 Like