Stop the Rot, the Rules of Refactoring

Stop the Rot, the Rules of Refactoring

A lot of times you hear experienced programmers talking about ‘smelly’ code. These ‘code smells’ are things that just look or feel wrong. Often programmers don’t immediately have a clear idea on how to fix it, but it ‘smells’! These smells often happen when the code ‘rots’.

Let’s do a quick check:

  • Are there pieces of code you’d rather not change?
  • Are (parts of) the application sometimes scrapped and rebuild from scratch (over and over)?
  • Do pieces of code exist that turned out much more complex than you had initially imagined?
  • Do you have pieces of code that feel out of place?
  • Is it hard to break up some large classes and/or methods?
  • Do you have a hard time coming up with names for certain classes?

Read more...


Programming, testing, documentation

Programming, testing, documentation

This week I’ve started work on a new project. This project has strict rules regarding documentation and testing. First of all, everything needs to be modelled in EA (Enterprise Architect), from use cases to the REST API fields. Next we need to perform the actual programming, and the testers write down their tests.

Realization

What is in the documentation?
- A description of who inputs what and what the results should be

What is in the code?
- A description of who inputs what and what the results should be

What is in the test?
-...

Read more...


Devoxx BE 2014: Aftermovie

Devoxx BE 2014: Aftermovie

A couple of weeks ago was Devoxx in Antwerp again, the largest annual European Java conference. As always I was there, with my camera, to capture the amazing atmosphere:

We (me and my colleagues) had a great time, and learned some new things. But most of all, we met great people and received a lot of inspiration. This year I´ve done a short 5 minute Ignite talk on Mutation testing. This was my first ´Ignite´ session and it is hard! The format of an Ignite session is, 20 slides, 5 minutes,...

Read more...


The Java 9 'Kulla' REPL

The Java 9 'Kulla' REPL

Maybe it’ll be part of JDK 9, maybe it won’t… but people are working hard on creating a REPL tool/environment for the Java Development Kit (JDK). More information on the code and the project is available as part of OpenJDK: project Kulla.

Some of you might not be familiar with the terminology ‘REPL’, it is short for Read Evaluate Print Loop. It is hard to explain exactly what it does, but very easy to demonstrate:

|  Welcome to the Java REPL mock-up -- Version 0.23
|  Type /help for help

-> System.out.println("Hello World!");
Hello World!

->

Read more...


Kill all mutants

Kill all mutants

The post below is the content from my 2014 J-Fall and Devoxx Ignite presentations. You can check you the slides here:
http://www.slideshare.net/royvanrijn/kill-the-mutants-a-better-way-to-test-your-tests

We all do testing

In this day and age you aren’t considered a real Java developer if you are not writing proper unit tests.
We all know why this is important:

  • Instant verification our code works.
  • Automatic future regressions tests.

But how do we know we are writing proper tests? Well most people use code coverage to measure this. If the percentage of coverage is high enough you are doing a...

Read more...



Finding an image in a mosaic

Finding an image in a mosaic

Browsing the Ludum Dare (see previous post) website I found this post from a friend Will. He made the following mosaic:

mosaic

Pretty interesting to see, I’ve already worked with him on improving the algorithm to generate these mosaics in the past. But next he set me a challenge: Find your own game thumbnail, it is in there somewhere!

This is the screenshot of my game, used as thumbnail:

target

So I went though the thumbnails, one time.. and a second time… then I decided to solve it...

Read more...


Ludum Dare #30: A (dis-)connected world...

Ludum Dare #30: A (dis-)connected world...

Last weekend the 30th Ludum Dare competition took place. For those us you unknown with Ludum Dare, this is a very short international game programming contest. You are allowed to use any tool or language but there are strict rules:

  1. The theme is revealed at the start (and the game must match this theme).
  2. You get 48 hours, nothing more or less.
  3. Every image, sprite, song and/or sound effect in the game should be made within these 48 hour.
  4. The result is open source (but you pick the license).
  5. You work alone.

(There is also a ‘Jam’ version where you...

Read more...


I won't enter a teleportation device, ever.

I won't enter a teleportation device, ever.

In the future somebody will inevitably invent a teleport, no doubt about that.

But how will it work?

Digital teleportation

The most likely way to teleport would be to digitalise yourself. Some yet undiscovered very high resolution MRI/CT scanner will scan every atom in your body and send this over to the receiver. This atom printer will build up your entire body again.

However, during a work lunch discussion, I came up with some scary fundamental problems with teleportation.

TransactionsTeleporter

What would happen if, during transmission, we get a failure? We don’t want to...

Read more...


Devoxx4Kids UK 2014: the video

Devoxx4Kids UK 2014: the video

The other thing I did while I was in London was volunteer and film at the first UK-based Devoxx4Kids.

Here is my video that sums it all up:

It was awesome being there, watching the kids play and learn at the same time. The volunteers were absolutely amazing (a lot of them!) and the atmosphere was very relaxed.


Devoxx UK 2014: the video

Devoxx UK 2014: the video

I’ve been filming again at Devoxx UK, here is the final cut:

Brings back so many great memories.

Including the night in the pub when ‘we’ won against Spain, 5-1


Review: Devoxx UK 2014

Review: Devoxx UK 2014

A year ago Devoxx crossed an ocean for the first time. After all the events in Belgium (Antwerp) and France (Paris) a new satellite event was launched in the UK (London). And here I am again, in a London hotel room, after two days of Devoxx UK.

Day 1: Getting started

With a silly one hour jetlag (which shouldn’t be a thing, but is…) I was awake and at the venue very early. Slowly but surely people started flooding in on the exhibition floor. It quickly became clear there were more visitors than last year. On the exhibition floor...

Read more...


Raspberry Pi emulation on OS X

Raspberry Pi emulation on OS X

Disclaimer/spoiler:

Building for a Raspberry Pi in an emulator is just as slow as on the actual Pi. There is a slightly faster method involving chroot. But if you really want speed you’ll have to set up a cross compiler environment or try this other cross compiler setup.

Also: Links in the article below seem to be broken and it might not work anymore.

Original (outdated) article:

Today a colleague and I wanted to install gnuradio on a Raspberry Pi. This can than be combined with the amazing RTL-SDR dongle. This dongle this is...

Read more...


Alternative for Constructors

Alternative for Constructors

If you want to create an object in Java there is only one way: use a constructor.

Constructors

Constructors in Java are different from all other methods. They don’t have a return type and can’t be invoked, only using the new keyword. Other tasks performed by constructors are:

  1. Initialisation of class variables
  2. Call the default contructor of the superclass if no constructor is present
  3. Initialisation of instance variables
  4. Execution of constructor body

Read more...


Solving a 18-year-old Core War mystery

Solving a 18-year-old Core War mystery

As some readers might know, I sometimes play a programming game called Core War. This afternoon I was browsing through some old ‘Core Warrior’ newsletters which John Metcalf has collected here. When reading an article about an old successful warrior called ‘Thermite II’ I came across this tiny unsolved mystery:

-- Bug?

John K.W. mailed me with a tiny, suicidal warrior which managed to beat
Thermite once in two hundred times. All I can imagine is that, that one
time, I somehow scanned his code within its few cycles of life, and that
then I crashed as a result. But how?

Program "Thermite II" (length 100) by "Robert Macrae"
;strategy Same old strategy, but nastier...
Killing Hazy Shade Of Winter III wins: 1
Thermite II wins: 199
Ties: 0

How did I get a win against Thermite?!?!
Here is an EXACT copy of what I sent to Pizza...
Thermite would've had to die within 3 cycles! ... :/

;redcode-94
;name Killing Hazy Shade Of Winter III
;kill Hazy Shade Of Winter III
;author John K W

p: ldp.b #0, #0
jmp <-1

Any ideas, anyone :-?

Source: http://corewar.co.uk/cw/cw024.txt

Read more...