More fasting benefits

I came across another article on hackernews about the benefits of fasting. It seems that as more and more time goes by the evidence grows that intermittent fasting has enormous health benefits. This story is even more amazing from the diabetic standpoint and the regenerating your pancreas.

Then my coworker sent me this video which I also think is good food for thought:

This got me thinking that maybe I should try the one meal a day thing throughout lent this year and see how that goes. I was already considering closing it out with another 72 hour fast. Though this year I am not going to fast from coffee I found that I was too mentally foggy in the afternoons without it. So given that I like to experiment anyway spending a bit over a month just having maybe supper every day and coffee (black) in the morning I think will be a good test to see how this actually would work lifestyle wise. I haven’t decided for sure whether I will go with that or not (I don’t have to decide until Wednesday morning), but that is the direction that I am leaning right now.

Jackson JSON

Jackson Bug Update

Well that was fast. I didn’t expect the day after the post to have an update but here it is. One thing I love about open source it is possible to find answers quickly. So it turns out that this is not in fact a bug. Apparently Jackson 2 aims for a Java 6 compatibility level. As a result of this they can’t include Java 8 features in the baseline as that would break compatibility. So they have a module to use the Java 8 features that you can bring into Maven with the following settings:


Once I did that everything started working. I appreciate how quickly the Jackson team responded to my ticket to help me out.

Jackson JSON

Bug in Jackson JSON serialization of Immutable objects

The bug

I have been using Jackson for JSON processing for many years now. It is a great framework and mostly just works. It is the default framework in Spring Boot and mostly it just sits behind the scenes and drives most micro services in Java these days. That is why I was surprised when we hit a bug in the framework as I hadn’t really had any issues in the past.

The backstory

Anyone who has coded with me knows that I tend to favor immutability for most java objects. By default I make everything final and then only has non final things when they are necessary. This principle is documented in Effective Java Second Edition Item #15. As a side note everyone should read that book. Even senior developers benefit greatly flipping through the book once a year and reviewing the items. It may be the best Java book I have ever read for writing very good code. My hope is that Josh Bloch does a 3rd edition to cover all the new functional operations in the language.

The best way that I have found to create Immutable Data Transfer Objects in Java with Jackson is to have all the fields be final values, and to annotate the constructor with @JsonCreator and each property in the constructor with @JsonProperty("propertyName"). Just like that you have an object that won’t change state and works seamlessly between your Java Service and your JavaScript front end or between 2 Java back end services.

The problem

The problem we found with this approach occurred in an integration with another partner. Our developer was trying to use Java best practices so the variables are camel case and he is using @JsonCreator in the constructor and naming the properties there. While that works great for an inbound object when trying to serialize that object out to JSON Jackson is throwing away those property names and serializing off of the field name. Normally our field name matches our property name so this is no issue. But in this case the property on the other side was something like first_name, but we record the variable as firstName. Jackson is serializing that as firstName if you only use the Constructor approach. If you add @JsonProperty("first_name") to the field it will work. So you are basically left either double annotating the field or going with a mutable POJO object to get the correct output. I have created a project on github demonstrating the problem:

Additionally I have opened an issue on the Jackson project for anyone who is interested in following this issue. So far I haven’t heard anything back on it.

Closing thoughts

So the real question is how did this thing go through without getting caught. My suspicion is that most developers don’t actually create Immutable objects in general. The other possibility is that people don’t often have an output that doesn’t match the variable names. We could take the ugly approach and declare final String first_name; to fix it but that doesn’t make me happy either.

I will be interested in seeing if anyone responds to the issue and what they say. I think it is always a good test of a project to see how active it is by seeing how long it takes for the developers of the project to at least comment on a given issue found in their code. I did a little bit of debugging into the Jackson code and I can see where it is throwing away the correct property values, but I am not sure what the correct fix is. It feels like a method that if I tried to fix I could easily break some other use case.


Turns out it wasn’t a bug and I got great help on the team to fix the issue.


Why starting a blog will change your life


I came across this post on linked in and it was too good to not share. The author highlights all the benefits of starting a blog. The key thing he mentions is that you accrue all these benefits even if no one reads your blog. I have found all of this to be true in my personal life. I have very few readers of this blog, but in the end I write this blog for me and not for someone else.

Blogging helps you learn…

The benefits he mention include that blogging helps you learn. This has been true for me, as if I want to talk about something I often find myself doing some research into the topic and digging a little deeper so that I can express my points in writing. His point about helping you learn points to the studies about how teaching others and writing things down sort of solidify ideas in your head, and while this is undoubtedly true, the research aspect alone has also forced me to take a deeper dive into things.

Back when I worked for Infor they had a program called green bean mentoring. This program would pair a recent college graduate with a senior person in the company for one on one mentoring. When my director asked me if I was interested in participating in the program as a mentor. Though I had never mentored anyone before I decided to give it a try. I was required to take some company training on the program and then as a part of that program I was paid a bonus for being a mentor and my mentees got pay raises that didn’t come out of our main budget at various milestones in the program. After taking the company training it was clear that this was designed for general business people and not technical people. So I put together my own milestones for the guys to work on as part of their technical growth and one of the items I had on the list was they needed to start blogs and post to them weekly. At that point I had only been writing on this site myself for maybe 9 or 10 months but I was already seeing the benefits, and so I felt it would really help their growth as well. At the end of the day communication is extremely important in all job roles and writing down your ideas is a great way to improve that skill.

Blogging will help you reach your goals faster…

The next benefit listed is that blogging will help you reach your goals faster. This one isn’t apparent when you start blogging. But I think it has worked out for me. I had various career goals that seemed to align much faster after I started this blog than was happening prior to it. Correlation isn’t causation, but I think it is related. Focusing on trying to get out a weekly post here focused my mind in general about technology, the state of the industry, and what I was working on at my job as well as what I wanted to be doing. Just having those things kicking around my head was unconsciously focusing my attention on things that are important to me in my career resulting in me spending less time on various time sinks that we all waste time with. At the end of the day time is our most precious resource that we have, and anything that improves your focus and pulls you away from time wasters is a huge benefit in your life.

Another career related aspect that I noticed was when I was actually changing jobs last year. Recruiters immediately noticed that I had a blog and it makes you stand out from other candidates. If you are in competition for a position and the company is able to see your writing and get some insights into how you see the world and how you approach problem solving, or what your interests are that can be edge against another candidate that they don’t know anything about. The big risk when hiring anyone is the unknown quantity. Is this person going to be any good? What if they are great at interviewing but they don’t actually perform. You end up wasting a bunch of time both hiring that person and now are in a position of not getting what you had hoped to get when you hired them. This reason alone is why hiring people based on referral is often preferred as they are known quantity.

Blogging will make you a better writer

The final point mentioned is that blogging will make you a better writer. This is definitely true as writing isn’t something that most people practice after they graduate from University. You wrote all those essays for any liberal arts classes that you took and then all of a sudden you don’t do any writing anymore save for the occasional email. Like most skills if you don’t practice it the skill degrades. We are compensated for the value that we can create in our professions and if you have a great idea, the only way that you can bring people along to implementing those ideas in an office environment is by being able to clearly communicate the idea and how it will drive value for the business. If you aren’t good at communicating your ideas this is going to hold you back in life. So when you start blogging and your colleagues don’t you are improving a skill that over time will get you farther ahead.

Closing thoughts

I needed to share the article as when I applied it to myself I definitely found it to be true for me and something that people should consider. Blogging can also be relaxing, as you have all these ideas kicking around and getting them out is great. I feel it also helps improve your ideas, as you are considering all these ideas and trying to make a case for them when you write them down it forces you to focus on them and scrutinize them and improve those ideas. Give it a shot and I predict after 6 months you still start seeing the benefits that I have seen as well. (Which is also why a consistent Theme of mine every year is regular posts as I don’t want to lose the benefits that I already have).


Slow Carb Diet and Book Review

Shortly after Epiphany I started doing the slow carb diet as outlined in the Tim Ferriss book The four Hour body. Basically slow carb is a high protein low carb diet. It seems friendly to fat in general, but I would say not as fat friendly as Paleo is. In the past I did paleo (the Primal version by Mark Sissan) and successfully lost a lot of weight, but I wanted something that I thought was a little more flexible. In the month and a half of slow carb I have lost 20 pounds. I think the rate of weight loss is slightly slower than doing paleo for me, but I think it is sustainable longer term. One interesting aspect of the diet is you can eat whatever you want on one day of the week (your cheat day). On my cheat day (Saturday) I tend to gain a pound or 2 but the weight loss the rest of the week eats this away and still leaves you with gains. I think it is an interesting aspect of the diet because now instead of saying I can’t eat X, it becomes I need to wait till Saturday to have this. Waiting a few days is much easier on the will power than saying I can’t eat this as eventually people tend to cheat. The other thing to note is even though I have been doing this diet on the weekend of my Wife’s birthday I ate whatever she wanted and we had Valentines where we ate fondue so I haven’t been entirely faithful to the diet like I was with Primal. Given how well it is working with all those aspects I will keep going with it, I would like to lose at least another 30 pounds so I am almost halfway to where I want to be.

The other change I have made is I purchased a new body scale. I went with the Withings Body Cardio. The key features I was looking for in a new scale included wifi or blutooth and integration with Apple’s Heath kit. My thinking is just tracking something like weight makes you more aware of it, which influences your decisions that you make. Now every morning I step on the scale and the data is downloaded to my phone. I have a very nice graph to look at of the last month of weight loss which is also great motivation to stick with something. Withings has their own app, but I just configured it to feed their data into Apple’s app as that is what I am interested in tracking. If anything were to ever get me into a smart watch it would probably be that app as I love all the stats rolling in there, and with the watch you would then have pulse data and other health metrics recorded. I would highly recommend the scale as it really is a game changer to have all that data fed into your phone.

Now back to the book. I would also recommend the 4 hour body book. Not only does it have some great data about diet, it has all sorts of other exercises based on experiments that the author has done with trainers. There is a body hack for using cold therapy to grown brown fat cells (which burn white fat). There are ideas on improving athletic performance, whether you are interested in running faster or getting stronger or putting on muscle mass it has all sorts of ideas. At this point I am only playing around with the diet ideas, and I may move on to some of the cold therapy ideas to see if that accelerates fat loss. All in all it is worth checking out and playing around with.


TIL: default hashCode() in Java

I came across this blog post today which I thought was really good. It is a deep dive into the default hashCode() implementation in java. To me the most amazing outcome of the piece is that if a given class is going to be accessed by multiple threads you really need to override hashCode otherwise biased locking is disabled. All in all it is an interesting look in the guts of the JVM and worth a read: default hashCode


Sorry for the lack of updates

Sorry for the lack of updates. We have been busy working on a game changing micro service for our business. It has been a blast but a couple of crazy sprints. I hope to get back to more writing in the near future.