Posts tagged with "clean code"

Apr 11th, 2013

JUnit – the Difference between Practice and @Theory

Lately a colleague showed me how to improve JUnit tests written for a distance calculator. Speaking with other developers I found out that the majority wasn’t aware of the undocumented @Theories Runner which can be found in an experimental package in JUnit, so I decided to share this valuable “experiment”. In contrast to the parameterized [...]

1 Comment
Feb 21st, 2013

API Tools revisited

image01

Defining API’s is crucial to maintaining modularity. OSGi defines the concepts necessary for API definition such as a service concept and package visibility. However, pure OSGi is not enough to really maintain an API and its potential usages. There are several cases in an API definition where it is required to do more than restrict [...]

1 Comment
Oct 8th, 2012

How to deal with whitespaces in the Eclipse IDE

spaces2e

Whatever your project’s specific policy on whitespaces is (tabs vs. spaces, etc), the most important rule should always be consistency. Not just to make your code look nice, but also to avoid issues with patches and your version control system. Changes to whitespaces may be more or less invisible to the naked eye, but Git [...]

1 Comment
Sep 3rd, 2012

Why should we always program in English?

Want to be a developer, but your English is really, really bad? Are you learning some other language and want to practice while doing your job? Or do you just want drive your colleagues insane with code that only you can read – because you happen to know Hindi? If you are a Javascript developer, [...]

2 Comments
Aug 11th, 2012

How to create blueprints for your OSGi building blocks

Blueprint of the bundle importing javax.sql.DataSource

With OSGi we are able to implement building blocks for modular applications. Dependency injection frameworks support us in writing flexible, testable and clean code. The “Blueprint Container Specification” defines a dependency injection framework to build applications that run in an OSGi framework. The specification was added in version 4.2 to the OSGi compendium Specification[1]. This [...]

Leave a Comment
Aug 8th, 2012

To catch or not to catch… Throwable

Many developers still catch Throwable in their try/catch statements. Is this a good idea? I don’t think so. As all of you know, Throwable is a generic superclass for all exception and errors in Java. As exceptions are meant to be caught, errors in more cases are not. If we take a look at the [...]

Leave a Comment
Jul 26th, 2012

Having fun with Guava’s String Helpers

During my life so far with Java I found myself often using separated Strings, such as a comma separated String. The reason is simple. Separated Strings are useful in many situations, like persistence prototyping, where you don’t want to add a full blown persistence solution but a small, lightweight file based store to save some [...]

7 Comments
Jul 24th, 2012

Google Guava Quickie: Clean toString methods

Screen Shot 2012-07-23 at 8.56.08 AM

I’m not very good at debugging code. This is the result of a test infection . When you do test driven development you don’t need to debug very often. But there are rare cases when I need to start the Debugger. For this task, I love to be able to see speakable representations of the [...]

4 Comments
Jul 17th, 2012

Clean compareTo methods with Google Guava

A common task in object oriented programming is comparing two objects for the purpose of sorting. In Java the useful Comparable<T> Interface exists. I’ve found myself implementing the compareTo method from this Interface plenty of times. But there is something that bothers me everytime: the complexity of the code this implementation creates. Let me explain. [...]

2 Comments