Wednesday, 12 March 2014

Thinking About Code

Last night I dragged my colleague Simon to the monthly LSCC Round Table and we had some interesting conversations around the topic: "how to balance time between discussing code and actually coding". The session was enlightening and we ended the night with a lot of food for thought (to supplement all the pizza and soft drinks provided by our wonderful hosts xD).

The original premise for the discussion came from a feeling within our team that we were doing retrospectives too often. Assuming that nothing "bad" has happened lately, was it necessary to hold a retrospective? Would forcing a retrospective simply push people to artificially discuss arbitrary topics for the simple sake of it?

We need more data to make a proper judgement but it is clear that there is more we can do to benefit from our retrospectives. One of the obstacles in our way could be a misperceived purpose of a retrospective: a process through which to fix problems. Whilst this is an aspect of retrospectives, if we look at how others do retrospectives it quickly become apparent that the focus is primarily on gathering feedback. Even when things are going well, there is bound to be something that could be improved, nobody is perfect after all!

Contrary to this, changing simply for the sake of change can be a waste of time. Identifying the right areas/processes to change is hard. In our case it very much feels like we need to prepare better for our retrospectives and do more to facilitate the discussions inside them. There is a wealth of material out there on retrospective facilitation but Tom's blog post on the 7 pillars of agile and spiderweb retrospective caught my eye.

As mentioned, it is very early days for our team as we only had two retrospectives since we changed the format and it would be premature to apply any changes as a knee jerk reaction. Going back to the very core of the issue, we have to ensure everyone understands the purpose of the retrospective. Once everyone has the same mindset, we can start evolving the process from there :)

Credit to http://sebastianlab.com/post/140303165/typing-is-not-the-bottleneck from which I got the typing monkey image :)

Tuesday, 4 February 2014

Skimmer's Guide - Head First Design Patterns - Welcome To Design Patterns

“The best way to use patterns is to load your brain with them and then recognize places... where you can apply them. Instead of code reuse, with patterns you get experience reuse.”

FOREWORD

I'm reading Head First Design Patterns along with a few others in the LJC Book Club. As we read, I'll produce a series of Skimmer's Guide posts for each significant section of the book. The previous section, on the Introduction, is here. If you are interested, please join the discussion on our Google+ community.

WHAT IS THE ABOUT? 

Continuing from the introduction, we now take a deep dive into the world of design patterns. Emphasis is on the ethos that "someone had already solved your problems" and how we can reuse the experience of others. Design patterns are our way of standing on the shoulders of giants!

Keeping with the Head First method, there are many lessons and even more ways to make the knowledge stick inside your brain. We may only cover the Strategy Pattern and general design concepts but you can rest assured you will remember all of it!

WHAT STOOD OUT? 

Exercise - Coding Ducks! (Strategy Pattern - p.18)
This simple exercise gives us our first opportunity to get our hands dirty :) It is a very straightforward problem and does an excellent job of teaching you the Strategy Pattern. I've pushed my work to Github: https://github.com/arkangelofkaos/head1st_designpatterns_duck

Exercise - Design Puzzle (p.25)
Make sure you have mastered the basics by trying your hand at organising the entity/class diagram in this exercise. Everyone remembers their UML arrows, right? ;)

Exercise - Crossword (p.33)
I know what you are thinking, we are learning and ain't nobody got time for messing around with a crossword! Rather surprisingly however, it is very valuable for seeing if you have been paying attention. Doing it exercises a different part of the brain and in the very least helped me notice I missed a page! Nevertheless it is incredibly frustrating if you're bad at crosswords!

IF YOU READ NOTHING ELSE... 

Shared Vocabularly (p.26)
Communicating is one of the greatest challenges facing developers and learning to succintly transfer thoughts from your head to another person's is invaluable. Part of this is using the right language, which in our case is the language of Design Patterns. Learning all of this enables us to communicate faster as well as code faster!

Object Oriented Principles (p.30)

At the very heart of everything we are trying to do, there must be a firm foundation of solid object orientated principles. Design patterns work in tandem with these tenants, you must learn the practice and understand the wisdom behind it. All of this is reassuringly woven into the theme of the book: from subtly highlighting how "Inheritance is evil" to explicit recommendations (program to an interface!)

CONCLUSION

If you have little to no experience with the Strategy pattern, this chapter is a fantastic way for you to master the art of encapsulating varying behaviour. Even for those with some experience on the topic, the exercises both amuse and tax you, helping to reinforce our knowledge :)

Friday, 31 January 2014

London Code Dojo 30

Monday was London Code Dojo 30 and this time we were back in Barbican with the lovely people at valtech

WHAT WENT DOWN

The kata for the evening was based upon Fibonacci numbers... but with a twist! The problem was centred around Fibonaccimal Numbers (link) which use the Fibonacci numbers as a base for representing numbers. So taking 1, 2,3,5 and 8 as a base, we can represent 9 as 10001 or 01101. As you can see, some numbers can have multiple representations and this added to the complexity of the problem. For the majority of the evening I paired with Rob and I found it really valuable getting his insight into the problem! The code we produced for the night can be found here: https://github.com/arkangelofkaos/CodeDojo30_Fibonacci

MY IMPRESSIONS

Nothing beats a good plan

More so then anything else, I came to appreciate the value of having a solid plan. Having a high level design which everyone agrees will solve the problem is incredibly important. Test driving code doesn't magically produce well designed algorithms.


LESSONS LEARNT

Decompose complexity into simple functions

Functional concepts supplement object oriented coding in a fantastically seamless way. When dealing with collections or calculations it is surprising how  higher order functions like map and reduce translate to how you naturally think about the problems.

For instance, to produce all the Fibonaccimal representations of a number, you can use a two step process:
  1. Find all unique ways to express that number as a sum of different Fibonacci numbers 
    • For example: 3 is [3] and [2+1]
  2. Translate each way into the corresponding Fibonaccimal 
    • [3] is 100 and [2+1] is 011
These steps are both mapping a number to a list of lists, then each list to a String. This is reflected in the code below:
return sumsCalculator.fibonacciSumsFor(number) // Step 1
                             .parallelStream()
                             .map(toStringCalculator::fibonacciSumToString); // Step 2

Suddenly I've decomposed an abstract problem into two concrete functions which I understand and can test drive!

Perhaps this is the crux behind solving all problems. Reduce the complexity until the solution is series of simple steps. Needless to say, making things simple is not simple... But there in lies the rub :)