“you should rarely use an optional in any other capacity than as a return value”. “you should declare a method to return Optional<T> if it might not be able to return a result AND clients will have to perform special processing if no result is returned”. From Effective Java by Joshua Bloch (Third Edition), pages…… Continue reading When to use Optional in Java?
If the code is so simple, then it will be simple to test it. And at some point, it’s likely the feature will be enhanced. If there is an existing test then it should be simple to enhance it. If there isn’t an existing test then things can quickly get messy. The more complex the…… Continue reading Testing myth: “The code is so simple – it doesn’t need a test”
Firstly, domain classes and DAOs are two separate issues. With Hibernate, for example, you can use POJOs or maps, and you can have multiple DAOs or one generic one. So why do i prefer POJOs… 1. They are type safe Your IDE will flag a problem as soon as you type it. 2. Code is…… Continue reading Why i prefer POJOs to maps for domain objects
So you want an executable jar. It’s got lots of dependent jars. What’s a geek to do? There is the uberjar plugin for maven. But it doesn’t seem to be supported any more, it’s not in maven central, and some people report classloader issues (it works some classloader magic). There is the Shade plugin for…… Continue reading Avoid the pain of uberjar/shade
I recently got an Maven error something like “Missing indirectly referenced artifact javax.transaction:jta:jar:1.0.1B:compile”. I fixed it by adding an extra repository in my pom.xml … </build> <repositories> <repository> <!– For jta jar –> <id>maven2-repository.dev.java.net</id> <name>Java.net Repository for Maven</name> <url>http://download.java.net/maven/2/</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> <dependencies> …
Tech highlights from Javapolis 2007: Java Content Repository now supported by many vendors slick demo of a Jackrabbit-based commercial product from day.com JCR 2.0 is in the pipeline Glassfish open source application server is now the reference implementation of the Servlet API v3 (currently in beta) is more modular. The demo had a fast startup…… Continue reading Javapolis 2007 Technology Highlights