Posts Tagged ‘Java’

« Older Posts   

Faster Builds via Concurrency

Recently I have been looking for ways to make a Java build run faster. This is something I seem to do at least once a year, typically as a result of the application’s production code base and automated test suite both growing in size over time. The build had previously already been split into multiple […]

Visualizing Java Package Dependencies

I have recently been examining the overall package structure of a Java enterprise application. I discovered an easy way to visualize the dependencies between packages using two open source tools JDepend and Graphviz and a little glue code. JDepend analyzes compiled Java bytecode and determines dependencies and metrics between Java packages. These analysis results can […]

Avoiding Caching To Improve Hibernate Performance

I was recently doing some performance tuning and made the surprising discovery that doing less caching in Hibernate actually improved performance in a particular scenario. When I discovered the problem this seemed very counter-intuitive. In fact, my original design maximized the use of caching in order to improve performance, but the opposite happened in practice. […]

Java Code Examples Available

I have added a new project called Java Examples to my Software page. This project contains the source code used as examples in the following articles: Working with Java 5 Annotations Parsing and Generating XML with Java Advanced Uses of Java 5 Enums A Tale of Bad Exception Handling in Finally Blocks in Java Automatically […]

Java-Based Configuration of Spring Dependency Injection

At the heart of the Spring Framework is its dependency injection capabilities provided by its inversion-of-control container. Traditionally the configuration of dependencies has been done in one or more separate XML files. In these files you need to specify code-specific constructs such as the concrete classes to use as implementations of interfaces. It has always […]

Why You Should Be Using FindBugs

Build automation has been the theme of my recent learning activities, so when I came across multiple positive references to a tool called FindBugs I decided to give it a try. My conclusion: FindBugs is worth using on all Java projects. Read below for the details. FindBugs is a Java static analysis tool that scans […]

Java Unit Testing Tutorial

This tutorial explains how to set up and write automated unit tests in Java using JUnit 4, a widely used java unit testing framework, Eclipse 3, an open source integrated development environment (IDE), and Java SE 5 or later. This tutorial is intended to be an introduction to unit testing aimed at developers who have […]

Resume Calculator

I have added a new software utility called Resume Calculator to my Software page. Resume Calculator reads resumes in XML format and calculates the total months and years of experience across specified resume entries. This is useful for responding to formal requests for proposal that require named resources to specify years of experience across various […]

Simple XML Parsing using JAXB

I recently needed to parse a XML file using Java for a utility I was writing. A couple of years ago I used dom4j to parse XML (and wrote an article about it). I figured there had to be a more modern approach, similar to how Hibernate 3.0 can map POJOs (plain old Java objects) […]

Exposing Mutable Objects as Public Properties

I recently had an interesting design discussion with a coworker in which we discussed the pros and cons of exposing mutable objects as public properties of a class. This article provides my thoughts on the subject. An immutable class (or object) is one whose state cannot be changed once the instance is constructed. Mutable objects […]

Working with Java 5 Annotations

Annotations are a new language feature introduced in Java 5 that allows Java code elements such as classes or methods to be annotated with structured metadata. This metadata can then be used at compile-time or at run-time by other code. Annotations are commonly used to provide configuration information for infrastructure frameworks to provide cross-cutting functionality. […]

Creating Custom Tags Using JSP

Java Server Pages (JSP) is a Java technology for rendering dynamic web pages. Unlike servlets written directly in Java, JSP files contain special markup to identify java or JSP code. The normal (non-markup) text is interpreted as HTML. Early in JSP’s evolution, custom tags were introduced as a way of providing reusable functionality, particularly reusable […]

Automatically Populating Audit Columns in Hibernate

Audit columns are a common design pattern used to record data creation and modification information for database tables. A typical implementation of this pattern is to add four columns to every non-static database table: CREATE_USER, CREATE_TIMESTAMP, UPDATE_USER, and UPDATE_TIMESTAMP. The create columns are populated only when a record is initially populated, while the update columns […]

Improving Performance via Eager Fetching in Hibernate

My previous article started discussing Hibernate relationships, focusing on lazy versus non-lazy relationships. This article continues the theme by discussing how to improve performance when dealing with relationships in Hibernate through a feature called eager fetching. Hibernate’s abstraction of database access behind getter and setter methods on domain objects hides potentially inefficient database access. Mindlessly […]

Avoid Non-Lazy Relationships in Hibernate

Support for entity relationships is a great time-saving feature in Hibernate, but it can also be a trap for the unsuspecting developer. Handling relationships between entities can be a complex business, and I for one am glad for all the support that Hibernate provides. Hibernate’s assistance, however, can do more harm than good when it […]

Hibernate and Logging

Hibernate tries to hide the details of dealing with relational databases, but it is at best a leaky abstraction. At its most basic level, Hibernate is a framework that issues SQL commands to the database. Sometimes it does not do what you would expect or want (more on that in future articles). Therefore it is […]

Hibernate Tips and Tricks

Hibernate is a de facto standard for object-relational mapping. One of my recent projects involved the use of the latest version of Hibernate (3.2). Since I had not used Hibernate since its version 2 days, I picked up the authoritative reference Java Persistence with Hibernate which is co-authored by Gavin King, the founder of Hibernate. […]

How to Handle Null Values in Code

One fairly common coding style I have seen from more experienced developers is what I will call highly-aggressive null checking. Such developers have most likely been burned by null pointer exceptions in the past and hence have evolved a style of coding which confirms that parameters or fields are non-null before using them. The code […]

Java Developers and Database Administrators Needed

The CGI Edmonton office (in Alberta, Canada) where I work is looking for Java developers and database administrators. CGI Edmonton primarily provides software development and maintenance services to various Government of Alberta ministries such as Alberta Health and Wellness. If you are good at what you do, like a challenging yet supportive work environment, and […]

A Tale of Bad Exception Handling in Finally Blocks in Java

There is always something more to learn. That was the lesson for me last week when I learned something new about the Java programming language, despite having used professionally it for almost 10 years. I was upgrading a Java web application to WebSphere server version 6.1 and as the first step I switched the development […]

« Older Posts