Friday 22 November 2013

Are you serious about achieving mastery? Find your mentor!

Few months ago, I read a book that significantly helped me in reflecting about my career and aspirations as a Software Engineer. It helped me in taking a very important decision that, I am sure, will have a great impact in my future.

The book is called Apprenticeship Patterns: Guidance for the Aspiring Software Craftsman and in this post, I am going to tell you my decision and the reasons behind it.

The book offer advices and solutions to dilemmas that software engineers typically have. The goal is helping them in increasing their expertise and becoming masters in what they do.

The book celebrates the importance of Software Craftsmanship as one of the best way to really learn the skills and the practical abilities required to design and develop high-quality tested software.
"Having knowledge is not the same as having the skill and practical ability to apply that knowledge to create software applications. This is where craftsmanship comes in."
There is one advice in particular that emerge constantly:
"If you are serious about achieving mastery, be tenacious about finding mentors to guide you."
These words made me deeply reflect.

I am an avid self-learner and definitely serious about achieving mastery. I read a lot of books written by experts in their fields that in an indirect way are like mentors for me. At the same time, at work, I am surrounded by very smart and talented people that are always willing to help and share their knowledge with me. I attend events and I am a founder of a community that helps me to network with passionate and energetic individuals.

This is awesome and it is great but I realized that I needed something more.

I really needed to find a mentor outside work, a person who I respect, with many years of experience and a strong reputation in the field, a professional that can follow me in my learning process and coach me in the right directions to become a great software engineer.
"The goal is to find ways to expose yourself to the daily working habits of other skilled people, and observe the ways in which they gradually refine those habits into even greater skill"
The main question was: Who to choose?

The answer to me was almost immediate: Matteo Baglini.


Matteo Baglini is a very senior software developer and architect with a lot of experience in building software in various different domains from business, web, mobile applications to embedded softwares. He is freelancer, a consultant, a technical writer, a speaker and founder of DotNetToscana and Coders TUG.

I have to say that Matteo is the most disciplined, the most pragmatic and the best programmer I ever met. I met him during my last year at the university and he already had a lot of impact on me at the time when we founded DotNetToscana and he surely represent what I want to become in the future. In addition, he is also a very good friend of mine.

So, in August, I sent a mail to him explaining my reflections and my intention to have him as my official technical mentor. 

Luckily, he was in a stage in his career when he wanted to invest more time in technical coaching activities so he accepted with enthusiasm and pride.

We started officially in October after my wedding and since then we had a meeting every week.

I have to say that the experience so far is incredible and I have all the intentions to share on my blog the results of this experience and the big lessons I am learning.

The ultimate goal is to being able to build cathedrals and Matteo can help me in achieving this :)
"Digging deep into a technology is that you can actually explain what’s going on beneath the surface of the systems you work on. This understanding will distinguish you from other who can’t describe the software they've helped build in a meaningful way because all they understand is one little portion. Once you’re part of a team, it’s the application of this pattern that separates out those who are making random piles of rubble (the Pragmatic Programmers called this “programming by coincidence” while Steve McConnell calls it “cargo cult software engineering”) from those who are building cathedrals."
If you are interested in the technical coaching services offered by Matteo, get in contact with him using his web site: Make It Simple.

This experience will be profound and useful for me and I am really excited about it.

Tuesday 5 November 2013

Top Coder Problem - WolfDelaymaster

During my last SRM 593 on TopCoder I found the medium problem quite interesting and I was happy that I have been able to solve it relatively quickly using the technique of Dynamic Programming.

Solving this problem taught me two important lessons:

  1. The power of Dynamic Programming
  2. The trap of over-optimization

The interesting thing is that I didn't realize the second lesson until I wrote this post so I am really glad I decided to write it.

I am going to quickly describe my solution.

The problem statement: WolfDelaymaster (Why register on TopCoder?)
My solution: WolfDelaymaster implementation.

The definition of the problem suggest an immediate recursive implementation.

You can first check that the string satisfy the first condition. You start checking against "wolf", then "wwoollff" and so on. Considering that the maximum input string is 50 characters the biggest string to test against contains 12 times each individual character.
  1. For each positive integer n, the string which consists of n copies of 'w', then n copies of 'o', then n copies of 'l', and finally n copies of 'f' is a valid word.
If this test fail, we can use the second rule and split the original string in two parts and recursively check them. It is important to try all the possible split points that are multiple of 4 (there are no valid strings shorter than 4 characters).
  1. The concatenation of two valid words is a valid word.
This is the initial implementation:


Does this implementation works?

Yes, it works!

Are you concerned about the performance implication of having two recursive branches?

I was and for some reasons I decided to apply the technique of dynamic programming in order to speed up the program. You can learn more about dynamic programming on Wikipedia. It basically consist of caching the intermediate result of computation to quickly cut the recursion tree.

Here the implementation (addition highlighted).


Does this effort was required?

Absolutely not!!! The original implementation was good enough.

What is the worst case?

The worst case is a string that is invalid with a length of 50 characters like "fofflwllwooowowwwllllwlwllwwlwwfwwfwofwwfolowlolwo".

The execution time of the original algorithm on the worst case is: 0.0110 seconds.
The execution time of the optimized algorithm on the worst case is: 0.00056 seconds

Dynamic programming is powerful as it improved the speed of the algorithm of a factor of 19 but in this case it was not necessary. This is the biggest mistake I made. I wasted a lot of time that I could have spent on the next problem.

It is worth to mention that the problem could have being solved in an iterative way but for some reasons the I didn't get it during the competition and the recursive implementation was more natural for me.

This is a possible implementation adapted from the winner of the competition (I didn't test it using the TopCoder system tests).


The time of the iterative version on the worst case is: 7.1E-06

This version is absolutely the quickest version!

Monday 4 November 2013

What is your personality type indicator?

The Myers-Briggs Type Indicator (MBTI) is a psychometric questionnaire designed to measure psychological preferences in how people perceive the world and make decisions.

Doing the test can helps you in understand yourself better and clarify your work preferences so that you can set career goals on your natural inclinations as suggested in the book 10 Career Essentials: Excel at Your Career by Using Your Personality Type.


You can take a free test on Humanmetrics.


This is my result.



It seems that I am a INFJ type of person that is the most rare of all the types (1% of population). I am quite impressed about the description of this type as, in some way, I recognize myself in it.

In particular the following is somewhat true about me:

  • They put a lot of energy into identifying the best system for getting things done, and constantly define and re-define the priorities in their lives.
  • The INFJ is as genuinely warm as they are complexINFJs hold a special place in the heart of people who they are close to, who are able to see their special gifts and depth of caring
  • INFJs are concerned for people's feelings, and try to be gentle to avoid hurting anyone
  • They are very sensitive to conflict, and cannot tolerate it very well.
  • INFJ is a perfectionist who doubts that they are living up to their full potential
  • INFJs are rarely at complete peace with themselves - there's always something else they should be doing to improve themselves and the world around them
  • They believe in constant growth, and don't often take time to revel in their accomplishments. 
  • They have strong value systems, and need to live their lives in accordance with what they feel is right.
  • INFJs are in some ways gentle and easy goingConversely, they have very high expectations of themselves, and frequently of their families. They don't believe in compromising their ideals.
  • INFJ is a natural nurturer; patient, devoted and protective.
  • Many excel in the sciences, where they make use of their intuition.
  • They are capable of great depth of feeling and personal achievement.
For more info: http://www.knowyourtype.com/myers-briggs/famous-mbti-personality-types/

I have the same type as Mohandas Gandhi and Eleanor Roosevelt. It is probably not coincidental that the book The Art of Happiness: A Handbook for Living is one of my favourite books.


What is your personality type indicator?