Super Boring Topic
Find the English version below
Hi ,
Gestern habe ich einen Artikel über die Assert Klasse von Spring veröffentlicht. Und im Mai, beim Developer Meetup in Essen habe ich auch über die Klasse gesprochen.
Aber eigentlich ist sie super langweilig.
Für alle, die sie nicht kennen:
Sie bietet eine Reihe an simplen “assert” Methoden. Zum Beispiel statt
if (someVariable == null) {
throw new IllegalArgumentException(”someVariable must not be null”);
}
können wir schreiben:
Assert.isNotNull(someVariable, “someVariable must not be null”);
Wahnsinn.
Das verändert alles.
Naja. Eigentlich nicht.
Aber wieso schreibe ich dann überhaupt darüber?
Dieses Feature alleine wird keine Codebase besser machen.
Es wird nicht der entscheidenden Unterschied darüber sein, ob eine Codebase “gut” ist, oder nicht.
Es ist eine Kleinigkeit.
Aber die Summe an Kleinigkeiten macht einen Unterschied.
- Wenn ich überall kleine Funktionen schreibe.
- Wenn meine Methoden gut benannt sind.
- Wenn ich Code so schreibe, wie ich spreche.
- Und wenn ich zwei Zeilen spare, weil ich Spring Assert statt eines if-statements nutze.
Wenn ich all das berücksichtige, dann ist unser Code besser zu lesen, als wenn ich es nicht täte.
Es ist die Summe an Dingen, die dafür sorgen, dass wir leicht zu wartenden Code schreiben.
Und deshalb mache ich das zum Thema. Deshalb schreibe ich auch mal einen Blog über so eine Kleinigkeit. Und deshalb bekommt das Thema eine Slide in meinem Talk.
Mach deinen Code immer ein Stückchen besser und du wirst den Effekt merken.
Rule the Backend,
~ Marcus
Hi ,
Yesterday, I published an article about the Assert class from Spring. And in May, at the Developer Meetup in Essen, I also talked about the class.
But actually, it's super boring.
For those who don't know:
It offers a series of simple "assert" methods. For example, instead of
if (someVariable == null) {
throw new IllegalArgumentException("someVariable must not be null");
}
we can write:
Assert.isNotNull(someVariable, "someVariable must not be null");
Incredible.
This changes everything.
Well, not really.
But why am I writing about it at all?
This feature alone won't make any codebase better.
It won't make the decisive difference as to whether a codebase is "good" or not.
It's a small thing.
But the sum of small things makes a difference.
- When I write small functions everywhere.
- When my methods are well-named.
- When I write code the way I speak.
- And when I save two lines because I use Spring's Assert instead of an if-statement.
When I take all this into account, then our code is easier to read than if I didn't.
It's the sum of these things that ensure we write easily maintainable code.
And that's why I'm making it a topic. That's why I'm also writing a blog about such a small thing. And that's why the topic gets a slide in my talk.
Always make your code a little better and you'll feel the effect.
Rule the Backend,
~ Marcus