Showing posts with label Mentoring. Show all posts
Showing posts with label Mentoring. Show all posts

Tuesday, 3 June 2014

Learnings from software development coaching sessions

Back in November 2013 I wrote a post sharing with you my decision of being mentored by a friend and agile coach Matteo Baglini with the goal of exposing myself to agile engineering practises and become a better developer.

At the time, I promised to write posts about my learning but ultimately I didn't. So, it is time to start now!

First of all, I wish to thanks my manager Dom Smith in Red Gate Software to offer me the opportunity to have these sessions during working hours. This really offers me the ability to have sessions regularly every week.

In this post I will condensate the learning of the last few months of mentoring with links to the various resources that I read since then.

We started discussing TDD and the approach described by Kent beck:
  1. Write new code only if an automated test has failed
  2. Remove duplications
Duplication is the most important code smell and it can be hard to see. For this reason, sometimes it is useful to write verbose code just to help you find duplications.

I did the full Money example in the book TDD By Example exactly how Kent did it (with few changes as I did in C#) and deeply reflected on each step. I spent a full day to do it but it was worth the effort.

Learning well a refactoring tool like ReSharper is very important. However it is important to consider that the biggest advantages of a refactoring tool is not merely productivity:
  • Avoid the human error
  • Remove the context switch between using keyboard and mouse
  • Shorten the feedback loop by decreasing the time needed to refactor a piece of code
  • You can answer quickly questions like: Is the new design better?
Doing a kata multiple times without changing the solution to just focus in how you code and use refactoring tools is a very useful technique.

Here is a collection of very useful advices:

  • Check the error message when a test fail
  • Run tests often
  • After a refactoring run the tests
  • Avoid copy & paste as much as possible
  • When you find something to do, don't stop your current task. Add a note and do it later.
  • Don't stop the flow only to rename a method or a property! Add a note and do it later.
  • Primitive obsession can be often removed by introducing Value Objects
  • Sometimes you can add a test and comment it out in order to do necessary refactoring
  • Don't be too confident! Always use tests to validate what you are doing
  • Keep tests as stupid as possible. Limit test logic as much as possible!
  • In case of regression (red bar) never change test logic otherwise you won't know what was right
  • If you lose control, just slow down or discard changes and restart
  • Don't restrict yourself in a Top Down or Button up approach.
  • The code guides you. TDD is a feedback tool.
  • Consider adding code even if it is not strictly required to improve readability or simply to add symmetry
  • Some tests are simply tests to support you during development. You can remove them when other tests cover the same functionalities. Don't be afraid. 
  • Consider the "Copy Type" ReSharper command
  • The production code tests the tests!
  • Extract Method is a powerful refactoring tool
  • It is sometimes useful to make a private internal method public just for the sake of temporary writing unit tests but don't submit that code! Use it only to increase your knowledge about the problem.
  • Learn how to do small steps when needed.
  • A test is done only when duplication is eliminated!
  • Consider writing a test to force the creation of an object that we expect to need late but attention of not doing upfront design
  • Relying on the compiler can be a useful technique
  • If it takes a lot of time to make a test green... reflect!
  • Prefer static methods to factory classes when implementing the factory pattern
  • Getters are smells. Pay attention to not use objects as mere data structure.
  • Resist the temptation of not creating new classes... try, get feedback and see!
  • Observe the frequency of change. Change should be distributed among classes.
  • Use the Single Responsibility Principle to see pattern of change
  • The class who own the data should do the operation: Tell, Don't Ask!
  • In designing API it is best to offer a single way to do something. Make it simple!
  • Use the history in SCM to get insight about your project
  • Analyse temporal correlation of class changes
  • If you feel that something is annoying in the code base that is a sign of poor design.
  • Remain at the same level of abstraction within a test
  • Write a high level test and when you see the need to cover a lot of cases go down of one level of abstraction and write more specific unit tests.
  • You will often be pushing tests up and down between different levels of abstraction
  • Remember to not look inside the object when you do testing even on individual classes! Test the behaviour so that you can easily change the instance of the class with a new class but keep the tests intact.
  • Do not use TDD as a way to get permissions to write production code (that is cheating).
  • Do not be too enthusiastic about new technologies or methodologies. Slow down and reflect. There will be always a hype and later a fall. If you are pragmatic you can fall less.
  • Consider writing the assertion first

The essence of object orientation is thinking about behaviours

TDD test are always behavioural and at different level of abstraction. TDD can be done at different levels of zoom: it is sort of a dance between them. Unfortunately TDD has been often misunderstood and even attempts were made to fix this with ATDD and BDD. But these methods have often been identified with tools and things like Cucumber only create a new layer without bringing much value: having the on-site customer is far better than executable requirements that are a dream.

Pair programming helps a lot to keep focused and the role of navigators is supporting drivers in maintaining discipline and avoiding distractions

I and my mentor discussed many times about the Theory of Constraints and the importance of identifying bottlenecks in order to remove them. It is quite interesting to note that also humans can be a bottleneck and therefore an issue that can be addressed by increasing sharing. This can be done both with pair programming or with the Expert in Earshot pattern.

Quotations:
I never known exactly how to achieve high cohesion and loose coupling regularly until I started writing isolated tests, Kent Beck
I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence (I suspect this level of confidence is high compared to industry standards, but that could just be hubris). If I don’t typically make a kind of mistake (like setting the wrong variables in a constructor), I don’t test for it. I do tend to make sense of test errors, so I’m extra careful when I have logic with complicated conditionals. When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong. Different people will have different testing strategies based on this philosophy, but that seems reasonable to me given the immature state of understanding of how tests can best fit into the inner loop of coding. Ten or twenty years from now we’ll likely have a more universal theory of which tests to write, which tests not to write, and how to tell the difference. In the meantime, experimentation seems in order. Kent Beck
Resources:

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.