Typically object caching in Java is managed by the container or framework in use. Occasionally however there is a need to manually cache domain-specific objects, whereby a java.util.Map implementation will not suffice.
Using the popular ehcache framework as an example, the following pattern is typically observed:
public class SomeClass {
private final Cache cache = …
[...]
Posted in Java | Also tagged caching, patterns |
Application logging always seems to become one of those code smells, typically regarding duplication of code, or conversely, non-uniform log messages.
There are many different ways to log a message in Java, but variations on the following pattern are common:
public class SomeClass {
private static final Log LOG = LogFactory.getLog(SomeClass.class);
…
public [...]
Posted in Java | Also tagged logging, patterns |