Continue reading: Readable Java system tests with good old JUnit

Readable Java system tests with good old JUnit

This article is the third in a series about system testing:

  1. Dockerized testing vs end-to-end testing
  2. How to setup Dockerized testing
  3. Readable Java system tests with good old JUnit

JUnit is poorly named. Given the name, people tend to think that it should only be used to write Java unit tests. And then people feel a bit hesitant about writing their integration tests with JUnit too. When they start with system tests, they often think they need another driver for their tests. Sure, maybe using another abstraction layer and a custom domain specific language (BDD), you can make the tests more readable for a non-programmer. That often comes at the cost of making the tests less readable for the programmers. And if we are honest, who’s going to read the tests the most? Perhaps just naming test classes and methods well and writing readable code can suffice?

Continue reading

Continue reading: Codekvast soon available as a Heroku add-on

Codekvast soon available as a Heroku add-on

Codekvast is a tool for detecting Truly Dead Code in your Java application. Truly Dead Code is code that is in production, but has not been used for a significant time. Codekvast has been lurking in the spare-time realm for too long. Now the project has eventually been granted some full-time development effort, with the initial

Continue reading
Continue reading: Another builder pattern for Java

Another builder pattern for Java

Whenever you have a domain object, data transfer object, parameter object or any other object that can’t be instantiated with constructor parameters only, you need to create a builder for its class.

The great thing about Java is that it is strongly (statically) typed so a builder can give you compiler errors if you forget to set the compulsory parameters. If you use the builder in this pattern, you also get a very fluent interface that imposes order on the parameters. When using the builder, your IDE will suggest the next parameter to set.

Continue reading

Continue reading: Hur man kan hantera Continuous Delivery med MongoDB

Hur man kan hantera Continuous Delivery med MongoDB

MongoDB är en schemalös, dokumentorienterad databas som har fått stor popularitet i den agila världen bland annat därför att man inte behöver underhålla något databasschema.

MongoDBs schemalöshet gör att många leds att tro att Continuous Delivery blir en promenad i parken, eftersom det ju inte behövs några datamigreringar när man driftsätter en ny version av koden!

Rent teoretiskt är detta sant, men är ett sluttande plan in i Land of Crappy Code™ !

För att slippa onödig komplexitet i form av varierande utseende på lagrade domänobjekt beroende på deras ålder, rekommenderar jag att man utför regelrätta datamigreringar även när man använder MongoDB!

Jag rekommenderar även att datamigreringen är en del av applikationen — till skillnad från skript som skall köras vid sidan av innan applikationsstart — helt enkelt för att eliminera risken för misstag.

Jag har i mitt sidoprojekt utvecklat en kompakt liten lösning som i MongoDB implementerar det som Flyway gör för SQL.

Mönstret bygger på Spring Data for MongoDB och Spring JavaConfig, och migreringarna är skrivna i Java. That’s right folks, no XML here 😀

Läs vidare, så får du se hur man kan göra!

Continue reading

Continue reading: Stop the Line – Build Quality In with Incremental Compilation

Stop the Line – Build Quality In with Incremental Compilation

We in the software industry are still far behind when it comes to automated quality checks. Toyoda Sakichi for example invented the automated loom with stop the line capability almost 100 years ago. I write more about that in my first blog in a three-part series on building the quality in on the SmartBear blog.

Continue reading
Continue reading: Size matters, why and how to measure your heap

Size matters, why and how to measure your heap

I have had to deal with memory problems in Java applications a few times. A lot has been written about this already, but this time I ran into a slightly different issue that surprised some of my colleagues so I decided to write about it here. Contrary to popular belief, a big JVM heap size is not always better when it comes to performance.

The problem

I came to the customer site to help them with their performance problems of a fairly large J2EE-system Web Service/Hibernate/MySQL system. They had several customers running the system, but only the largest was experiencing problems. The application suddenly froze and stopped processing transactions. All sorts of hypotheses were discussed, but no one could really for sure say what the problem was. And there was little data to work on.

Continue reading

Continue reading: Code archeology 101: Custom Exception Hierarchies

Code archeology 101: Custom Exception Hierarchies

After having worked with various legacy codebases one discovers certain recurring traits and patterns. The topic of today is the Custom Exception Hierarchy encountered in Java legacy code. This phenomenon is rather Java-specific because of that language’s checked exceptions.

So what is a Custom Exception Hierarchy? It’s an exception hierarchy, with some strangely named exception at its root, present throughout the entire codebase and used everywhere. The author(s) of such hierarchy obviously felt that exceptions like IllegalStateException or IllegalArgumentException, or the like weren’t sufficient for the sophisticated needs of their application, so they came up with a better suited hierarchy of checked exceptions.

Continue reading

Continue reading: Is your software architecture explicit?

Is your software architecture explicit?

You know, every system has a software architecture and a software design. Whether you think about your system’s architecture or not, it will have one. Here is an example of two methods in a class I recently saw. It is not architecture, it is good old OOD, but it exemplifies what can happen if you

Continue reading
Continue reading: Analog Clock Revisited

Analog Clock Revisited

Screenshot of the analog clockI have been playing around with JavaFX on and off since it came out and I got really inspired by Per’s blog post about the analog clock. So I decided to spend my time at the Crisp Hack Summit trying to improve Per’s design both in code and visually.

Continue reading

Continue reading: Using CloudBees for teaching XP practices

Using CloudBees for teaching XP practices

We are doing a course called “Certified Scrum Developer”.  We are of course proud of being one of the few eligible by the Scrum Alliance to hold such a course. But what matters most to us is teaching some modern development practices. The certificate bit is more of a bonus.

Crisp had recently its fifth installment of a code camp, the “Crisp Hack Summit”. It is an occasion for everyone at Crisp to go bananas on some project of their liking. We took the chance to work on the technical platform for the CSD course.  We know from experience that you can loose a lot of valuable lecture time if  the technical environment decides to hassle. Murphy, will you be there?

Continue reading

Continue reading: Bootstrapping an agile project with continuous deployment using cloudbees

Bootstrapping an agile project with continuous deployment using cloudbees

Starting from scratch, this video demos how to quickly get to a fully agile project setup with continuous deployment. Everything is in the cloud – GIT repo, Jenkins, MongoDB, and the app server. The system deploys automatically with every successful commit. The app itself is minimal, but does have a simple web interface and a

Continue reading
Continue reading: On Unit Testing and Mockito

On Unit Testing and Mockito

This is just a blog post to point to my presentation of the aforementioned subject. Or should I say, “prezi”, because there are no slides, just a big picture with a path through it. That’s is the way of Prezi presentations and as a first timer, I felt liberated. Slides are so dull!

The content of my presentation is aimed at those with some experience of unit testing that would like a dose of philosophy on testing styles. Classical or Mockist? State or Behavior? Also, if you are not that familiar with Mockito, take this prezi for a spin!

Here is the link to the prezi! That’s all for now.

Continue reading

Continue reading: Functional Java

Functional Java

I have just finished reading a neat little book about functional programming for Java developers by Dean Wampler. The book is only sixty pages long so it’s a really fast reading. This is a book for Java programmers and others working in the object oriented paradigm that haven’t read about or done any functional programming before. If that fits you then this book may be a good choice to read. Otherwise, I recommend that you seek more advanced and in-depth books in the subject instead. But this text will not be a review of the book. I will instead comment on the use of the functional structure and its paradigm in languages like Java that is not designed for it.

Continue reading

Continue reading: Mönster för flertrådade enhetstester

Mönster för flertrådade enhetstester

Detta är ett designmönster för hur man skriver ett enhetstest som utför samma test samtidigt i flera trådar.

Genom att utnyttja java.util.concurrent på ett smart sätt säkerställer man maximal samtidighet, vilken kan avslöja trådbuggar.

Kom ihåg: det går inte att bevisa att ett program är fritt från trådbuggar. Det handlar om att göra det sannolikt att det fungerar i en flertrådad miljö.

Nyfiken? Läs på…

Continue reading
Continue reading: Some Gotchas for Java Developers Learning JavaFX

Some Gotchas for Java Developers Learning JavaFX

In an earlier post, I had attached slides from a presentation on JavaFX that contained some code examples. I discovered that at least one of them, the ball game, stopped working when I switched to JavaFX 1.3.

I would say it is a quite subtle difference.

What happened was that the onKeyPressed and onKeyReleased were not called. My immediate reaction was that it was due to some bug in JavaFX but yesterday I realized what had happened.

Continue reading

Continue reading: Technology stressed? Perhaps it is time to panic!

Technology stressed? Perhaps it is time to panic!

Four years ago I spent a few months assembling a rather wide-spread document which I named "State of the art in Server Side Java". It was at the time well researched enough to end up as an entry on The Server Side. Soon thereafter I got sidetracked to follow Ajax for a few years. I

Continue reading
Continue reading: Don’t let Java ruin your JavaFX

Don’t let Java ruin your JavaFX

Me and Oscar is currently working on a small project, just to learn JavaFX.

We stumbled on some nasty crashes which we at first did not understand.

ArrayIndexOutOfBoundsException? Is there a bug in JavaFX?

It turned out to be a callback from Java. Let us see how we got there.

picuture if the application

Continue reading
Continue reading: Java 7 update från Alex Miller

Java 7 update från Alex Miller

Alex Miller har precis bloggat om vad han tycker verkar ske när det gäller Java 7. Vi kan få en preview till JavaOne 2009 (dvs juni) och ett teoretiskt releasedatum på januari 2010, men Miller tycker det är för mycket osäkerheter för att tro på en så pass snabb release. Generellt sett så tror jag

Continue reading
Continue reading: 10 really lousy commandments for Java Developers

10 really lousy commandments for Java Developers

Aleksey Shevchenko have on published 10 commandments for Java Developers, and they are of such lousy quality that I just have to respond (this vaguely resembles a xkcd cartoon :-). His commandments are: Add comments to your code Do not complicate things Keep in Mind – "Less is more" is not always better No

Continue reading
Continue reading: Actors Galore

Actors Galore

När jag började lära mig Scala så stötte jag direkt på Actors, ett koncept snott från (om jag förstått det hela korrekt) Erlang. Actors är ett sätt att få till concurrency genom att skicka meddelanden, till skillnad från det vi alla under ett decennium svettats med i Java, trådbaserad concurrency. Tanken är att det ska

Continue reading
Continue reading: Vad kommer egentligen i Java 7?

Vad kommer egentligen i Java 7?

Alex Miller har haft den intressantaste bloggen för de som intresserat sig för Java 7, och han har en speciell sida där han summerat all information han kommit över. Java har känts lite övergivet på Sun, tycker jag. Det har inte funnits någon kapten på skeppet. Gosling gör lite som han vill, men driver inget

Continue reading
Continue reading: Cascading – MapReduce without the complexity

Cascading – MapReduce without the complexity

Just bumped into Cascading, which is an open source (GPL 3) framework "for defining and executing complex and fault tolerant data processing workflows on a Hadoop cluster". Hadoop is, I’m sure you all know, an implementation of MapReduce which is at the core of how Google does its processing. Anyway, the Cascading API "lets the

Continue reading
Continue reading: What is SpringSource doing with its license?

What is SpringSource doing with its license?

It appears as if SpringSource, the company doing most of the development of Spring, is doing an ExtJS, i.e. changing the license of its product to force users into paying for it, or its support. Lots of people are writing about this, such as Alessandro Santini at JavaLobby. Does anyone have any enlightening comments? Regardless,

Continue reading
Continue reading: Woohoo: Mixed Scala and Java projects in Eclipse

Woohoo: Mixed Scala and Java projects in Eclipse

A few days ago Scala 2.7.2 RC2 was released. One of the new features is mixed Java and Scala support in both the compiler and the Eclipse plugin. I decided to try it out. Installation was very simple. I then set off creating a simplistic Java class side by side with the Scala object, in

Continue reading
Continue reading: Kilim – Actors for Java

Kilim – Actors for Java

Just bumped into Kilim, an actors framework for Java. This could be really important! The most exciting thing I’ve seen in several months!

Continue reading
Continue reading: Steve Yegge om hur språkvalet påverkar kodbasens storlek

Steve Yegge om hur språkvalet påverkar kodbasens storlek

Steve Yegge, som jag bara stött på vid några tillfällen tidigare, skrev strax före jul ett blogginlägg under rubriken Code’s Worst Enemy. Där försöker han, utifrån erfarenheten från ett spel han skrivit på egen hand i Java, argumentera för att det är Javas fel att hans kodbas nu är på 500 000 rader. Vilket han

Continue reading
Continue reading: Terracotta clustering of Scala Actors

Terracotta clustering of Scala Actors

I Scala finns ramverket Actors, som ska vara en nära mappning av Erlangs framgångsrika motsvarighet med samma namn: ett meddelande-baserat ramverk för concurrency. Nu har Jonas Bonér kopplat ihop Scalas Actors med Terracotta, vilket ger oss transparent klustring av dessa Actors! David Pollak, skaparen av webramverket lift för Scala lät hälsa: This is most awesome

Continue reading
Continue reading: Ouch, Howard Lewis Ship dumpar Maven

Ouch, Howard Lewis Ship dumpar Maven

Skaparen av Tapestry, Howard Lewis Ship, dumpar nu Maven, efter att ha använt det väldigt mycket. Citat från hans blog: The Maven team is criminal… … The Maven project site is an embarrassment. The tool supposedly designed for "project comprehension" is itself incomprehensible, due to its scale, the chaos of its documentation, and the extreme

Continue reading
Continue reading: Varför Scala kan vara nästa stora programmeringsspråk

Varför Scala kan vara nästa stora programmeringsspråk

Jag har funderat ganska länge på vad nästa stora språk skulle kunna vara. Jag var tidigt med på resan från C++ till Java. Åkte på den första JavaOne konferensen i San Francisco, och trodde redan då att Java skulle ta över. Så fort det var möjligt lämnade jag C++ bakom mig, trots att jag skrivit

Continue reading
Continue reading: JAX-RS: RESTful Web Services

JAX-RS: RESTful Web Services

Draft specen för JAX-RS: The Java API for RESTful Web Services släpptes för någon vecka sedan. Som oftast brukar jag inte orka granska specarna som kommer, men denna gång tog jag mig en titt. It made me go mmmm… som det heter. Kan denna lilla kodsnutt väcka aptiten: @UriTemplate(“widgets”)‏public class WidgetList{ @HttpMethod @UriTemplate(“offers”)‏ WidgetList getDiscounted()

Continue reading