Cognitive therapy

The featured image on this post is from Cycologygear. I love their shirts and have several of them. Highly recommended products. If you need some new jerseys, go check their shop!

Some days ago, Simon Maple asked the following question on Twitter:

Let me tell you a story. I’m an avid cyclist and run this site for quit a while now. I’m commuting about 20 to 30 kilometers a day now for more than years by bike. Before I had kids, I was into mountain biking. Nowadays more road race. In short: I always considered myself “fit”. Seldom out of breath when going up some stairs etc.

The following picture has been taken in the summer of 2016 and though it was a marvelous moment with my kids on an old boat, I thought: Wow, is that really you? Age 36 back than…



I still felt fine though some shirts and a couple of trousers became a bit small. I ended 2016 with about 85kg (I’m 1.86m tall). In 2017 I did a lot of conferences and user groups, drank a lot of beer and spend my whole spare time in front of a computer writing on my second book and by summer of 2017, it really did show and wasn’t feeling fine at all.

Not only I reached around 88kg, I was perceived ill the whole spring, usually tired and in short: Did not feel good.

I have a history of overdoing things. Being it work, sports, eating and drinking, so I was a bit anxious if buying a Garmin vívosmart® HR+ and a one year subscription of myfitnesspal was a good idea. Especially the later triggered some long forgotten memories with me.

I bought both nevertheless and the result is great. Actually eating more conscious and getting back a feeling what food contains a certain amount of calories was the main win of using myfitnesspal. I configured the app with a target weight of 80kg and a pretty though number of maximum daily calorie intake. I’m a bit stubborn on these kinda things and I wouldn’t recommend it for everybody. Anyway: I reached my goal – starting in July 2017 – by the end of October 2017 and since then, I’m around 79kg, given or take.

The other important aspect for me was doing some stuff I didn’t usually do:



The first running activity in 2017 did hurt. My muscles and my mind: Am I that slow? That soon of of breath? Holy cow… I tracked it with the vívosmart mentioned above. About 4km with a pace of 7:49 min/km. Oh boy.

I kept running and by the end of September I managed reach paces around 6:10 min/km consistently. That’s when things started to hurt less and actually became fun. What doesn’t work for me and probably never will is sports in a gym. Essential for me is actually being outside. Running is considerably easier in autumn and winter than cycling: Not much equipment you have to take care for, just throw everything in to the washing machine and be done with it.

No sports without a battle of equipment and materials. I sold the vívosmart to my friend André and gave myself a nice birthday present, a Garmin fēnix® 5S, a device I could wear the whole day:



You can read about the fēnix 5S for example at DC Rainmaker. For me, it stood up to all it’s promises, especially a battery life for about 7 days with 3 or 4 trainings. I never really wanted a Smart Watch, quit the contrary, I’m a fan of analog watches, but I do like having some notifications on the watch, like text messages from my “favorite” contacts. I do like however the fitness tracker and it’s reminder to get up once in an hour. I’m the kind of person who – when in the flow or really deep done into a problem – doesn’t get up from the chair until problem solved or the bladder ultimately demands its rights, so that improved daily life (work).

I tried to use the sleep tracker, but I don’t like having something around my wrist in my sleep, but I did set the reminder to get into bed before midnight.

I both like Garmin Connect and Garmin Connect Mobile a lot. You’ll need the later on your smartphone to configure your device. Both works as expected. Sometimes the bluetooth connection gets lost but force quitting the app and restarting it helped always on iOS. Both apps offer some good insights. Not sure if they are physically viable but I do like the relative measures. Also, after using the device now for a year, I’m pretty happy with the running result of 725km:

   

What really baffled me is the step counter, though: I walked nearly 4000km in a year.

I managed to ran 3 half marathons since December 2017, two of them under 2 hours, the third was at the beach and that was… pain 🙂



I’m quite often late to the party. This time for Strava. Many friends tried to convince me to join there but I just did this month. While I keep my Garmin data by myself, I opened my Strava profile and also added some images for my preferred routes. The Garmin Fenix 5S supports Strava live segments and that’s actually a fun way to battle oneself with other athletes for the fastest pace etc.

Anyway. Those numbers aren’t actually that important. I appreciate the measurements because it motivates me to get up and do something, but they are not something that defines me. And the same holds true for (our) passion for work. Reading this post on my IT blog probably means you’re yourself into computer science, programming etc. For whatever reason many of us kinda get sucked into this whole thing and spend more time than it’s healthy with IT. Myself: Not an exception. Shifting some habits did help me a lot, not only being fitter, but focussing more on work in the end.

While being outside and working out helps on clearing ones mind (at least with me), it also helps learning and reading about other things not in our profession. At the moment I am reading the German version of Ken Wilbers Integral Meditation: Mindfulness as a Way to Grow Up, Wake Up, and Show Up in Your Life and it gives me a nice mental shift. Last year I was occupied with the Black Swan by Nassim Taleb for some time.

In the end, it’s a bit of cognitive therapy: After realizing that I have to change habits to change my perception on a lot of things, one thing came to another and nearly 2 years after the first picture in this post has been taken, I feel a lot better and also happier. Not always, but often.

And if that all doesn’t change a bit, maybe just go outside and play ball:



Did you like this article? You can invite me on a coffee ☕️ if you like.

| Comments (1) »

28-Jun-18


biking2: Four years later

I have written a book about Spring Boot 2, taught Spring Boot 2 at customer but haven’t had time yet to update biking.michael-simons.eu to use Spring Boot 2.

That project is – in it’s current Spring based incarnation – with me since the first early access releases of Java 8 and the first betas and release candidates of Spring Boot (for example, see that post).

I started the migration in a separate branch in the public repository while I was tracking the massive amount of changes in Boot in the last quarter of 2017 for my book.

Today, I finished it. The branch has been deleted, but I kept the most relevant commits and prefixed those that I think are important with Boot2. I rearranged and squashed a lot of the commits, I don’t expect the single commits to compile. The latest commit however does.

I personally found the changes in security a bit though to tackle but worth the effort. Also, if one relies on the Actuator Metrics endpoint, there’ll be some tasks ahead. The migration was in over-all quit smooth and pleasant.

The one thing that bit me though was the fact that I start the application with -Dspring.config.location=conf/application.properties. In Spring Boot prior to 2 this adds the given location to the configuration. With Spring Boot 2 this replaces config location. I have this in my book, so I really think I’m getting old. The correct way in Spring Boot 2 to add additional config location is -Dspring.config.additional-location=conf/application.properties.

In the process of upgrading I also upgraded and tested my wro4j-spring-boot-starter. Since 0.4.x it’s fully supported on Boot 2. I will not maintain the older branches until necessary. At the moment, wro4j seems a bit dormant anyway.

Anyway: A big thank you to all the people in the Spring Team and other contributors for answering my questions, discussion issues with me, providing great software and in general for being really kind and welcoming.

| Comments (0) »

27-Jun-18


Use different Git usernames and emails for work and play

A bit hidden away in the release notes of Git 2.13 but found by my friend Michael Vitz from INNOQ is the not so new anymore feature of conditional configuration respectively conditional includes.

Git has several levels of configuration: System wide, per user, per repository and finally, on each individual command invocation. If a values is defined on several levels, the most specific counts.

Configuration files can include other files with include and includeIf. The included files behave as if the configuration they contain had been written in the including file.

includeIf includes files conditionally. Right now, it only supports one attribute, gitdir: “The data that follows the keyword gitdir: is used as a glob pattern. If the location of the .git directory matches the pattern, the include condition is met.”

Depending on the directory your repo is in, you can pull in different configuration files. That comes in very handy to configure different a different username and email address, for example to differentiate between work and play (taken directly from the release notes):

Put this into your user specific .gitconfig:

[includeIf "gitdir:~/work/"]
  path = .gitconfig-work
[includeIf "gitdir:~/play/"]
  path = .gitconfig-play

And create additional .gitconfig-work and .gitconfig-play (the files can reside wherever you want, you can use a full path as well:

[user]
name = Serious Q. Programmer
email = serious.programmer@business.example.com
[user]
name = Random J. Hacker
email = rmsfan1979@example.com

Read more about git-config includes and fine more usage examples in the official documentation. I curate a list of some more or less useful git snippets here.

Did you like this article? You can invite me on a coffee ☕️ if you like.

| Comments (0) »

25-Jun-18


Maven: Use JUnit 5 with Spring Boot for unit and integration tests

Last weekend, a new version of the Apache Maven Surefire-Plugin has been released:

The Failsafe-Plugin has been updated as well. Both support JUnit 5 natively.

To make use of JUnit 5 in a Spring Boot 2 application, there’s not much todo. Here’s a gist of a POM that brings everything. See comments in the code. Basically all you have to do is overwrite the managed versions of the Surefire- and Failsafe-Plugins and then exclude the JUnit 4 dependency from Spring Boots Starter Test (and all other test related starters, i.e. security-starter-test). You’ll than declare both the JUnit 5 Jupiter Api and Engine, both in scope test. You could put the engine into the plugins dependency, but I couldn’t think of an aspect that’s improved by more cruft. Then, write unit and integration tests as shown (the later with annotated with @ExtendWith(SpringExtension.class)).

You’ll notice that only the Failsafe-Plugin has been declared. Spring Boots parent POM already takes care of the Surefire-Plugin.

And that’s all you need for Spring Boot 2 with JUnit 5.

Did you like this article? You can invite me on a coffee ☕️ if you like.

| Comments (5) »

18-Jun-18


Some thoughts about Effective Java, Third Edition and general musings

Lately, German publisher dpunkt.verlag reached out to me wether I’d think it’s a good idea translating Joshua Blochs Effective Java 3rd edition (Partnerlink) to German. Effective Java has been on my Good reads list for a while now and I read the first edition in 2003 or 2004, don’t remember exactly when. I hopefully learned a thing or two in that time and sadly seen some things better left unseen and my initial thought was: Go for it! If a translated version helps spreading best practices and especially things one should not do, it’s worth the effort.

To my surprise, dpunkt than asked if I could review the translation. And so it happened that I read the third edition in its total, mostly parallel in German and English:

My friend Thorben has reviewed the book already very concise at his Thoughts on Java blog. I fully agree with him.

One thing I have to quote is Joshua Bloch himself:

If you have ever studied a second language yourself and then tried to use it outside the classroom, you know that there are three things you must master: how the language is structured (grammar), how to name things you want to talk about (vocabulary), and the customary and effective ways to say everyday things (usage). Too often only the first two are covered in the classroom, and you find native speakers constantly suppressing their laughter as you try to make yourself understood.

This is from the foreword itself and is basically the essence of the book.

If one gets the idea on how to start a Java program, the weird notion of the main-method and have an idea about objects, Java does not have a step learning curve. One can solve many problems without going deeper into the specifications or fully understanding what’s happening behind the scenes.

Most of the time, stuff works out, some times not. Usually those times happen to be late in the evening, on a weekend duty etc. Performance optimizations that should not have been done. Cloneable or serializable classes that violates their invariants. And many more.

Effective Java does address all these and more.

It also is written from an API creators point of view as one clearly sees on how Joshua stresses good documentation at the API level.

One does wonder if qualities being important for an API are equally important for a product or a software that has it’s value in the business it powers? I’d say yes. There’s always a team that has to maintain code or hast to fix bugs. Add new features. I don’t believe in a permanent rewrite of (micro)services. By all probability, the Netflixes, Amazons and Googles of this world do this, but at least I have not yet been in a project where that was a legitimate thing.

Given that premise, I’d rather build my stuff on a solid fundament and that starts with some best practices and at least the ambition to learn a language a bit deeper than just on the surface.

Funny enough, my tweet about Lombok did gain some traction:

I like the project but use it very selectively, most of the time @Getter, @Setter, @EqualsAndHashCode (that one only with the of-attribute) and sometimes @Builder. I use it to create immutable, small values classes with not more than 4 or 5 fields and @RequiredArgsContructor. I’m probably even the last person who learned yesterday, that there is @Synchronized, but at least I can explain what and why the stuff that @Synchronized does, is actually a good idea. If one has a library like Lombok or Googles AutoValue in a project, an understanding of Javas details become paramount or otherwise all kinds of interesting things can happen (if we speak on a higher level like Michael @bitboss Plöd argues, inflationary generation of accessors defies information hiding and encapsulation and should be avoided).

If you want to master the language Java, read all items in the book. If you’re more into other (JVM) languages as well, the chapters General programming, Exceptions and Concurrency have value without Java, too (By the way, you should sometimes have a look at other languages. Kotlin is nice and Simon has a great blog. However it might be a good idea to really look outside the OO box and take a sneak peek at Clojure).

tl;dr: I firmly believe that one has not to master every detail of a day-to-day language but one should know more than just the basics and to the right things the right way. Effective Java has some more or less controversial items, but overall, it indeed helps to be more effective.

| Comments (0) »

08-Jun-18