Why Java Reflection is Pure Evil and Why I Love It

One of the essential properties of object oriented programming is the encapsulation of an object state. The most important side effect of this encapsulation is that an objects' state is exposed through its methods. These methods allows for various guarantees, such as class invariants and method invariants. ...

October 24, 2012 · 6 min · Pal Hargitai

Generics Revisited

In an earlier post about generics I described the limited impact of type erasure. Trying to describe that type erasure was more of a developer issue and less of a platform. Although I still agree with that statement, I want to show a case that adds some nuance to that statement. ...

April 8, 2012 · 2 min · Pal Hargitai

Generics in Java

There seem to be a significant amount of Java developers who have certain criticisms to the Java approach of implementing Generics. Though type information is sometimes well hidden, it's almost always available. This is because of the approach that Sun took when defining it. Sun decided that it was not appropriate to compile new types just because the type information itself changed. This approach differs from the C++ template approach which requires the original sources of the generic class you're using, this makes it very hard to provide a generic class in a library. ...

October 12, 2011 · 3 min · Pal Hargitai