Posts Tagged ‘coding’

« Older Posts   

Most Disturbing Code

One question I often ask when giving job interviews is “What do you find most disturbing when reviewing code?” The answers I receive are especially interesting when compared to the interviewee’s results doing an actual code review: it is rare for them to identify the problems they consider the most disturbing. This lack of congruence […]

Streaming Data to Reduce Memory Usage

I recently performed a series of optimizations to reduce an application’s memory usage. After completing several of these I noticed that there was a common theme to many of my optimizations that I could explicitly apply to help identify further opportunities for improvement. As a reoccuring solution, this qualifies as a design pattern which I […]

Exploring Mental Processes behind Developing Software

How do you go about designing and coding software? More specifically, what is your mental process for accomplishing this? Becoming more aware of the approach you use allows you to deliberately control and improve it. Mental thought processes are, however, very intangible and difficult to put into words. In the software development literature much has […]

Why Coding is not Enough

If the goal of software development is to produce working software then developers need to know more than just how to code – they need to know how to prevent or eliminate functional and non-functional defects. Too many developers think their job is complete once a feature has been coded. Sometimes they think that it […]

Using To Do Comments in Code

I am a big proponent of using to do comments – comments prefixed by a specific identifier such as “TODO” – in a code base to indicate outstanding tasks or issues with the code. I have encountered developers who are either unfamiliar with the practice or who do not follow it as deliberately as I […]

Use Understood Methods Rule

Over the years I have refined the approach I use to write code. Recently I codified a key aspect of this approach as a practice I call the Use Understood Methods Rule. The basic formulation of the rule is quite simple: when coding a method only invoke other methods whose behavior you clearly understand and […]

Test Driven Development – Benefits, Limitations, and Techniques

I wrote previously about the process I went through in adopting test driven development (TDD). In this article I discuss my experience with TDD: the benefits, the limitations, and the techniques I use when doing TDD. Benefits This section covers the benefits, as I see them, of doing TDD. This does not include the benefits […]

Adopting Test Driven Development

I have always been keen on using automated unit tests since I first heard about them almost a decade ago. I have known about test driven development (TDD) for almost as long but the practice of writing tests first before writing production code never really clicked for me when I first tried it years ago. […]

My Definition of Done

I recently wrote about why you need a definition of done, and it only seems logical to follow this up by presenting what I use for a definition of done for developing software. I use two guiding principles as the basis for constructing my definition. Potentially releasable: Ideally the software can be released (or shipped) […]

Would You Trust Your Life To Your Code?

Would you trust your life to your code? It is a simple question that you might find extreme. But is it really? You might argue that the answer to this question depends on the criticality of the software you are producing. Software like the control software for the space shuttle or software to control medical […]

The Five Commandments of Version Control

Effective use of version control is a fundamental development practice, especially if there is more than one person working on the same code base. Below are the standard rules I use for the proper use of version control in the style of biblical old testament commandments. I like imagining an authoritative voice booming these commandments […]

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 […]

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 […]

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 […]

The Source Code is the Design

I first came across the thought-provoking article What Is Software Design? by Jack Reeves as an appendix titled “The Source Code Is the Design” in the book Agile Software Development: Principles, Patterns, and Practices The article was written in 1992 so ignore the references to C++ (I mentally translated them to Java) and instead focus […]

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. […]

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 […]

« Older Posts