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 [...]
Posts Tagged ‘Coding’
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 of doing [...]
- Add Comment
- No Comments
- Permalink
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. [...]
- Add Comment
- No Comments
- Permalink
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? 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 [...]
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 [...]
- Add Comment
- No Comments
- Permalink
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 Populating Audit Columns in Hibernate
Simple [...]
- Add Comment
- No Comments
- Permalink
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 [...]
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 [...]
- Add Comment
- No Comments
- Permalink
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) [...]
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 do [...]
- Add Comment
- No Comments
- Permalink
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 [...]
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.
Using [...]
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 [...]
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 [...]
Code reviews are an important practice for improving the quality of your software and ensuring that it is ready for release. Software engineering research has found that reviews (or inspections) are a powerful QA practice and have many advantages over testing:
A higher percentage of defects are found when using reviews – as high as [...]
To code or not to code, that is the question for senior software developers when they are presented with the opportunity to move into an architect, project manager or team lead position. Rob Walling recently wrote an excellent article titled Why Good Developers Are Promoted Into Unhappiness describing his unsatisfying experiences as a manager and [...]
When are you done writing a piece of code? Is it when you have implemented the necessary functionality? When you have tested it? I believe there is more to professional-quality code than just getting it to function properly. What else is there? Making sure the code is maintainable – well designed and understandable. I use [...]
My previous article discussed the question how much do you code?. After thinking more about this, I realized that a more important question is whether you are doing enough coding. How much is enough versus too little? This depends on the reasons why you code.
For myself, I can think of several reasons why I [...]
- Add Comment
- No Comments
- Permalink
As a software developer, how much time do you actually spend writing code? I recently have discussed this topic with both junior and senior coworkers, from which I have realized that this is a very important question for many developers. The amount of time the average developer actually spends coding can be surprisingly small, and [...]