Skip to content

January 2012

Impact of proxy on equals and hashCode

A lot of frameworks create proxies  to apply aspect oriented programming or the lazy loading pattern. Hibernate for example uses cglib or javasissit to create lazy loading proxies. The famous springframework mainly uses java proxyies created via java.lang.reflect.Proxy.newProxyInstance(ClassLoader, Class<?>[], InvocationHandler) or cglib as well. Therefore it is important to know exactly how proxies work and the impact of proxies on your implementations. Especially when implementing basic methods like equals() and hashCode(). How proxies work A proxy is (like the name implies) not the real object. It is another object with the same interface as the real object. Since it has the same interface it can either delegate all calls to… Read More »Impact of proxy on equals and hashCode

Pros and cons of service layer designs

A service layer is a common approach in enterprise applications to encapsulage application specific use cases. So when I talk about service layers I mean the service layer pattern as described in the “pattern of enterprise application architecture” book by Martin Fowler. While the pattern describes the responsibility of a service layer from a high level architectural perspective, this blog is about to take a closer look at the most used service layer designs. Definition of a service A service provides methods for it’s clients. These methods are typically on a coarse-grained level and normally encapsulate use cases. Therefore the service layer methods are often the transaction boundary of an… Read More »Pros and cons of service layer designs

Handling complex object state with design

Some APIs that implement a complex object state management often violate the single responsibility principle and make the usage very difficult. When you do all aspects of the complex state management in one inferface the interface’s methods must be invoked in the chronological correct order. Such APIs are hard to understand and to integrate. What we really want are APIs that guide the client code programmers in such situations. Lets take a look at an API that breaks the single responsibility principle and let us think about the consequences for the client code programmer. If you take a look at the FTPClient API of apache commons you can see that all… Read More »Handling complex object state with design

GDPR Cookie Consent with Real Cookie Banner