Archive

Posts Tagged ‘API-Design’

Functional Java – partial function application, the LOD and structure agnostic access

March 21, 2016 Leave a comment

It’s been a while since I last wrote something about programming on my private blog and since a lot has been said about Java 8 lambdas, I did not feel to add a lot more. But I recently saw a colleague’s blog on Intel’s Inside Blue about Lambdas and why a functional programming style matters. That motivated me to write something again, and tackle this topic, putting an emphasis on a specific problem and how Lambdas helped me solve it.

Read more…

Advertisements

Reflection without Strings

August 9, 2010 4 comments

Sometimes reflection is very handy, but using reflection often involves referencing methods by Strings, which can get you into major trouble when you are refactoring your code. If a method belongs to an interface though, there is salvation. But let me first tell you how it started and what I did about it. Read more…

Minimizing ripple effects

April 6, 2010 1 comment

In the good old times when racing was dangerous and sex was safe and real programmers coded machine language we were used to use jumps and branches to addresses or labels if you had more than just a ML-monitor. BASIC just took this paradigm to a higher language level and the art of programming involved tracing all the jumps and conditions at the same time until Edsger Dijkstra spoiled it all – and rightly so! There are better ways to waste your testosterone and show you’re a real man than working successfully with untraceable spaghetti-code no one else understands – including yourself some months later. Sadly you can still create a tangled mess if you’re programming in Java and other OOP languages alike. Often you find yourself in a situation where you have to change something which would break a lot of code, because that small change you need to make ripples through several classes. The higher the fan-in-complexity of your code is, the worse it gets. This is why some code analysis tools punish a high fan-in-complexity, which may be misleading if you take the DRY-principle seriously. Especially if you work on frameworks you need to take countermeasures to avoid ripple-effects so you can continue to develop your framework while it’s being used. Let me introduce you to a coding style that helps to reduce ripple effects.

Read more…

Using annotations for validation

March 20, 2010 2 comments

There is one common case I often come across and that’s validation of parameters. There are different situations in which you like to validate parameters, the most common case is validation of method parameters, usually performed with guard-clauses and assertions. This is not what I’d like to write about in this blog. I may come across this later. This time it’s all about annotation driven validation on fields. Read more…

Dealing with immutability and long constructors in a fluent way.

March 10, 2010 9 comments

I use to state that the best thing to do is to keep your code simple and clean. But if your task is to design an easy-to-understand and easy-to-change API, this may be a bad advice. There simply is no silver bullet in programming and simplicity ain’t one either.

There is a common case you may have encountered more than once, which is long constructors with repeating types. You’re likely to see them in immutable classes. I’m not going to discuss why immutable classes are desirable, I’m going to talk about easing the pain to construct them. Read more…

Boolean parameters considered harmful – almost

February 24, 2010 4 comments

I have to admit this blog’s title is a bit exaggerated, but since I have lately seen some bad examples of using booleans as parameters, I just felt the urge to write about it.

Read more…