clean code Tag

[caption id="attachment_19508" align="alignright" width="160"] Copyright (c) Pivotal Labs[/caption]I recently started using Jasmine to write my JavaScript tests. I really like it - it made writing tests actually kind of fun. I especially love that you can write tests with mocks in a similar manner as you would using Mockito in the Java world. A mock is basically a lightweight object that imitates the API and (to...

Read More

As you might have noticed, Java 8 was released last week ;). Most programers consider Java 8 the biggest change to the Java programming language ever made. This is mostly because of lambda expressions, default methods and streams. As an SWT/RAP/Tabris coder, the first thing that came to my mind was: "How can this make my SWT code better?". This blog will show you how to...

Read More

As I started in the programming industry almost a decade ago, writing tests at all was still a fairly new thing for many developers. Having been one of the early TDD advocates in my social environment, I had to recommend many best practices and books to students and colleagues. Kent Beck, Robert Martin and many other more or less public figures provided invaluable advice and...

Read More

I've been programming JavaScript for a few years now, and the one thing that definitely bothered me from the beginning was the lack of built-in support for private object members. The feeling that anyone using your code (including yourself) could by accident or intent mess with the internals of your objects isn't great. Not just can anyone change the value of any property at...

Read More

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 JUnit test, the Theories-runner will try out all possible combinations of...

Read More

Defining APIs 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 the accessibility to packages. As an example, a public package...

Read More

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 and co. register them anyway. Here are some simple ways to...

Read More

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, this internationalization tool fixes all these problems. Instead of writing...

Read More

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 specification is derived from the Spring Dynamic Modules project[2] which...

Read More

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 most cases are not. If we take a look at the Error class JavaDoc we will read the following: An Error is...

Read More