Super Boring Topic
Author
Marcus HeldHi,
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