How to eliminate a parameter boom

Hello folks. Today I want to write about a little trick I learned. If you are working with legacy code and you don’t have the chance to eliminate core design problems, you can use this little pattern to help you out. Problem Problem is that you have a class that has a gazillion collaborators and at some point in time one of the clever devs thought it would be a cool idea to do dependancy injection via the constructor. We all know that doing this makes the class immutable which is very good for a number of reasons. However it doesn’t provide a flexible solution if you want to leave out one or two collabs. For that your would have to create Adapter constructors and chain them upwards which would get very ugly very fast. While using JavaBeans getters and setters can leave your class in a harmful state like not at all or partially initialised. ...

October 9, 2012 · 3 min · hannibal

Coderetreat London

Hello everybody. So yesterday I was on a little gathering called Coderetreat. If you look at the link you can read everything about it. If not, I’ve provided a short description. What it is about? So what is codereatreat about? In short it’s about programmers getting together and honing and practicing there skills in order to become more at what they are doing. It’s a practice run with great people. TDDing one problem the whole day long with constantly applied constraints. ...

September 30, 2012 · 5 min · hannibal

Learning programming with a visual mind

Hi folks. Today I want to write to you about learning something with a visual mind. There are a gazillion posts out there that tell you how to learn something with a visual mind. However, there are only a few actually describing how to learn something as complicated and logical as programming. How do you draw up a function? How do you draw up a cycle or a structure? Actually these are really easy. A cycle? No problem. What’s a circle if not a cycle? Structure? This should be an easy one. You can draw a whole building and then place building blocks into it. ...

September 9, 2012 · 3 min · hannibal

Journey into an unknown system

Aka, what you can do if you are facing and unknown framework / system you have to work with for quite some time. Get intimate You are going to live with this system for a while. The best thing you can do is getting to know it better. You have to get it to know like you would approche a fine lady. You have to ask it questions look after it, how it feels how its day was. Have to listen to what it tells you, you have to read its diary if necessary. ...

June 28, 2012 · 2 min · hannibal

Solution to Wrap Kata

My solution to the String Wrap Kata. The goal is to have it wrap a text on a given column width. It is not the best solution but this is my first try. I did it with TDD so there were tests first, which I’m not going to copy in.. public class WrapKata { public String wrap(String input, int columnSize) { if (input.length() <= columnSize) return input; else { return wrapLines(input, columnSize); } } private String wrapLines(String input, int columnSize) { int breakPoint = getBreakPoint(input, columnSize); String head = createHead(input, breakPoint); String tail = createTail(input, breakPoint); return head += "\n" + wrap(tail, columnSize); } private String createTail(String input, int breakPoint) { return input.substring(breakPoint).trim(); } private String createHead(String input, int breakPoint) { return input.substring(, breakPoint).trim(); } private int getBreakPoint(String input, int columnSize) { if (input.contains(" ")) { return input.lastIndexOf(' ', columnSize); } else { return columnSize; } } }

June 26, 2012 · 1 min · hannibal

Don’t throw Exception

Hi. Today I want to talk about a common problem in many frameworks I encountered over the course of my carrier as a Java dev / automation engineer, whatnot. Throwing Exceptions. That is in your method you have something like this: public void insertMethodNameHere(String param) throws Exception {} This is bad. And I will tell you in short forms why. Hides exceptions This one should be obvious. When a method throws exception you can never be sure what kind of exceptions it handles. It will hide what problems it can encounter. It will hide possible threats and will generally mean nothing to you when it fails. ...

June 13, 2012 · 4 min · hannibal

Making your code understandable

Hi! I’ve seen this many times over and over again. Many people have wrote books about it already. Like Uncle Bob’s Clean Code. Like Pragmatic Programmer by Andrew Hunt and David Thomas. What makes your code understandable to others. Is it Comments? No. It’s not comments. If your code could be read properly you wouldn’t need comments to explain what it does. Like Uncle Bob said. A good code doesn’t contain surprises. It does exactly what you would think it should do on the next line. It doesn’t have curves and misinformation. It doesn’t have plots and turns of events like a good crime book. No. Good code is a like a boring soap opera with predictable plot and boring plain characters who don’t change there behavior based on circumstances. ...

June 13, 2012 · 2 min · hannibal

JMS Connection setup and Framework

Hello chumps. Today I want to write about jms connection testing with a small framework. I wrote a small thing using a factory object model. It’s a lead, a proof of concept. You can use this to go onward. First, let’s begin with the JMS connection it self. JMS Connection First rule of thumb is: “Don’t wait for a response when dealing with JMS queues.” How so? Because, a JMS queue is asynchronous so you wont get back anything. There are however two ways of checking if it was a success or not. ...

March 4, 2012 · 5 min · hannibal

Configuration

When I see something like this: public class Config { public static final string DATABASELINK = "linkhere"; . . . } It sends a small, but chilling shiver down my spine. Just. don’t. There are a lot of possibilities to use configuration in Java. Java property files. Xml. Xml serialization. CSV file. Whatever suits you best, but this? DON’T!

February 27, 2012 · 1 min · hannibal

Testing ‘code’ tag.

Hello. This is just a quick post to test the working of the code tag. Given(/The Action is ([A-z]*)/) do |action| @action = action end Perfect!! The name of the plugin is WP-Syntax. The trick is to edit the page in plain HTML. Because the WordPress word editor screws up the <> tags. But surely you already knew that.

February 26, 2012 · 1 min · hannibal