Sunday, February 21, 2016

Don't use the greater than sign in programming


One simple thing that comes up time and time again is the use of the greater than sign as part of a conditional while programming. Removing it cleans up code, here's why:

Conditionals can be confusing

Let's say that I want to check that something is between 5 and 10. 
There are many ways I can do this

All of these mean the same thing... Wait, did I actually do all that right? Sorry, one of those is incorrect. Go ahead and find out which one, I'll wait...

If you remove the use of the greater than sign then only 2 options remain:
(x < 10 && 5 < x)
which is a stupid option because it implies 10 < 5 and
(5 <&& x < 10)

This is a nice way of expressing "x is between 5 and 10" because it is literally between 5 and 10.

It's also a nice way of expressing that "x is outside the limits of 5 and 10"
(x < 5 || 10 < x)

Again, this expresses it nicely because x is literally outside of 5 to 10.

Simple. Clear. Consistent.

This is such a nice way to express numbers I wonder why programming languages allow for the greater than sign ( > ) at all.

But why is this so expressive?

The Number line

Here's how you represent between 5 and 10 on a number line vs code:
number line of between 5 to 10
(5 <&& x < 10)


Here's how you represent outside of  5 and 10 on a number line vs code:
number line of outside 5 to 10
(x < 5 || 10 < x)


On a number line everything to the left is less than the numbers to the right, so these two ways of representing the relationship between things matches up.

Combinatorics

This problem gets much worse as the conditional grows. For example
 number line of between -5 and -1 or between 2 and 4
((-5 <&& x < -1) || (2 <&& x < 4))

Has 15 other possible ways to be expressed if you  include the greater than sign and don't make your expressions conform to the number line.





Saturday, September 5, 2015

Mob Programming and Trivial problems

Whenever I hear about Mob Programming people always talk about how great it is for the hard problems.

But let’s explore a fictional example of some trivial work because I believe this is where things really start to shine.

At the Institute for Boring  & Monotonous work (IBMw) there was a team of 6 developers that whose large code base had all become destroyed due to a large disk crash. Fortunately, all of the code had been printed out before the destruction, but it had to be re-typed in. The estimated work was going to take the 6 programmers 8 months. It doesn’t get more trivial than this, IBMw was really living up to its name.

Nonetheless, Mob Programming was the new buzzword so this team said, “why not try it out?”. Here’s what happened.

Day 1 (Many eyes):

The team started typing in the pages. They quickly started to arrange focus so that a couple would be manning the physical paper and couple eying the projector to keep everything in tack. They were definitely slower with only one person typing, but they also realized that they weren’t making any typos. This is very important as the code had to be perfect or the whole system wouldn’t fit together again.

At the end of the day they retrospected as it is recommended for mobs. They came up with 2 big findings.
1)   quality is up
2)   some people can’t type
Idea for improvement: “Let’s spend 20 minutes tomorrow working on typing”

Day 2 (Countable Improvements)

The mob downloaded a typing tutor and started the day working on keyboarding. It didn’t make a huge difference, but  it was nice to know the slower members were working on it. Made it easier to be patient with them during the day.

But one part of the day went a bit off, something went wrong with the typing and they had to debug a bit. As they did someone counted the number of words. Paper: 304 Computer:303. Damn. Eventually they found the missing part.

At the daily retrospective, a couple of post-its showed up in the positive side with ‘word count helped debugging’

Day 3 (Checks)

They continued with the typing practice in the morning. A little progress but not much, some members had moved from 15 words a minute to 16.

The word count was really helpful so they started doing that with each part. It usually wasn’t wrong but there was something reassuring in knowing that the computer matched the paper so they kept doing it. It was extra helpful when it didn’t match. However programmers can be extra lazy and  someone complained that it sucked that they had to count the words on the computer as well. Everyone agreed, and then they suggested they write a small programmer to count the words for them. Easy enough; No more manual counting of the words.

The retrospective had a lot of sticky notes with “auto counter” written on them in the what went well section.

Day 4 ( Auto-enhancement)

It was great having the ability to know the word count when they matched up, but still a bit hard figuring out where the missing part was when it didn’t. So they would add improvements to the AutoCounter to allow for easier debugging. It was interesting to note that some of the best ideas came from the most frustrated people. Team members that never would have been able to implement those ideas on their own.

At one point, they just couldn’t get past one section.
“I know something is wrong”
“But the word count is the same, even the character count is the same”
“but look at it, it doesn’t feel the same”
“yes, but, oh the printed font is different. That’s why it feels different”

The retrospective had a bunch of “font caused frustration” in the negative side.

End of Week 1 (double check)

After typing practice the first thing suggested was to change the font to match the paper. This made the day a lot easier. They would hold the paper up and do a quick sight match. Still programmers are nothing it not lazy. The retrospective included “arm tired from holding up paper”

Week 2 (Seeing words)

The second week seem much easier than the 1st. They brought in a second projector to overlay the paper so it was even easier to see the differences, but this also got them thinking why do we need to count the photo? It was too hard to program up something to read the printouts, but it wasn't to hard to detect the words. They could figure out the boxes around words. It wasn't great but it helped.  Now WordCounter could also help a bit with the physical world.

They were still doing typing, but it wasn't helping much the slowest was up to 22 words per minute on Friday from 21 words per minute Thursday.

Oh, someone was sick and out for 2 days, didn’t really matter.

Week 3 (Word counter sees letters and bugs)

The team was able to get the boxes from words to letters. This really improved the speed of the checking and we are almost completely sure there are no bugs going in from typing now. Of course there were some bugs in the original code. We got in one argument over a weird compiler setting that has different effects on how a struct would end up in assembly code. It was rather goofy, but we added setting to Word Counter to notify us if this shows up again.

Typing still isn’t helping much, our slowest is barely making 26 words per minute.

Week 4 (Splitting Word Counter)

The team split up the Word Counter into a separate program that detects the patterns of common bugs. We only have 3 patterns so far but its pretty neat and we are removing some bad code because of it. We were also able to run this over the previous code so fixed some stuff from the first 3 weeks.

We also had an idea of how to detect the letters from the printouts, but it didn’t work.
On the failure side, typing is still not really improving. Slowly McTypesABit is only doing 30 words a minutes.

Month 2  (OCR & Linting)

This month we were able to add a lot to the bug finder. Up to 13 patterns. We’ve even shared the program with other teams to help them check their code. We also got a way to do a bit of automated reading of the characters from the printouts. It’s not very good (about 50%) but it gives us a starting point which is nice and we are doing good overall. Might even be a month or two early to finish this project.

On a side note: because of a 2 week vacation we have a new slowest typer! It’s very close though (40 wpm vs 39 wpm)

Month 3 (Done Done?)


The WordReader is still having problems (only 80% accurate) but it’s been helping us move really much faster. With the combination of BugFinder we are going to be done with the rewriting by the end of next month. The teams still has budget though and it looks like both WordReader and BugFinder might be useful outside of just helping us finish our original Task. We are looking into making them more robust…

Wednesday, April 15, 2015

Making Things Smaller

Often, when people talk about minimum viable product or story splitting we hear the question

"but how can I make this smaller?"

I'm going to show a very simple, powerful and yet often overlooked strategy for doing this.

Use smaller numbers

If your scenario has numbers in it make them smaller. You can do this in 2 ways depending on what you are trying to accomplish.

Minimum Viable Product

When you are trying to get to the smallest thing start your numbers near 0 or 1.

Here are some examples:
 "This report should do 5 things" -> "This report should do 1 thing"
 "Get data from 3 sources" -> "Get data from 1 source"
 "The UI changes these 8 things" -> "First we will change this 1 UI feature"
"We check in code every 8 hours" -> "We check in code at least once an hour"

Sometimes people 'hide' the numbers
 "Handle English, Spanish & French" = "Handle 3 languages" -> "Handle 1 Language"

Also, remember that programmers tend to think in terms of only 3 numbers: 0, 1 & many
 "Save directories" -> "Save many directories" -> "Save 1 Directory"

This also creates a very nice step from 1 to many of 1. In programmer that is:

"int postalCode = 90210"  -> "int[] postalCodes = {90210}"


Minimum Viable Change

When coaching you usually want to go the opposite direction so that the change is less noticeable and easier to absorb without conflict.

 "Our sprints are 4 weeks" -> "Our sprints are 3 weeks" -> "Our sprints are 2 weeks" -> "Our sprints our 1 week" ->  "We release weekly" -> "We release daily"

 "Our Build has 9 manual steps" -> "Our build has 8 manual steps"
 
Sometimes this shows up as negative numbers:
"No teams are writing tests" = "8 teams aren't writing tests" -> "7 Teams aren't writing tests" = "1 team started writing tests"


The Point is... if you start making a habit of looking for numbers in your stories and processes you will see them everywhere and then they are easier to reduce.

Monday, January 5, 2015

Women in Tech & Men in Zumba

I have been a long time supporter of women in tech but today I realized how little I truly understand their situation.

Today my girlfriend brought me along to a Zumba Gold class. This is a easier version of zumba and often is frequented by older (60+) women. We were the youngest there by far.


I was the only man.

I'm a good dancer. Proficient in swing, salsa, cumbia & merengue which is basically what Zumba is. Youth is also an advantage in most physical activity. This should be very easy for me. Also, everyone was both very nice, complementary and welcoming. 

I was the only man.

I felt very uncomfortable. I would not have been there if not with my girlfriend and can't imagine going there by myself. I wouldn't say that I enjoyed it. I wouldn't say that it was "my thing". I wish I could have turned invisible many times. But that was not the worst thing.

The worst thing was I had absolutely no idea what to do to make the situation more comfortable. Here I was, with all the self interest in the world to want to make things easier and no idea at all how to do it. 

I did gain some clear insight into what I did NOT want:
  • please, oh god please, do not single me out or call more attention to me
  • I felt very uncomfortable when people would come over to give me compliments
  • I did not enjoy the particularly extra girly dance moves
This makes me question some of the things I would do in regards to women in tech. Such as 
  • Make sure the women are recognized
  • Compliment women when they do good 
  • Anything remotely 'brogrammer' related (the mere thought of this now makes me cringe)

As uncomfortable as it was being the only man in zumba today, it was one day. It's not like it's my career... 

I can only imagine how many girls we lose the first few days of a programming class when they just feel like they don't fit in.

Sunday, October 12, 2014

The Interview - Putting together a new mob

Hello. I’m Llewellyn Falco and recently I embarked on forming a 5-person mob to be hired for full time employment. This series is about our journey where I will share the good and bad so others can benefit from our experiences.

This week:

Interviewing

Once I finally figured out who the potential mob was I was faced with a difficult question. “How in the world are we going to determine if all 5 of us are the right fit for this company”
In other words:

“How do you interview a new mob?”

Speed Dating

I have always found interviewing for full time employment a bit of a crapshoot. It’s like going on a single date with someone and then asking
“How about getting married?”

I am not saying it can't work. It’s just a bit risky and the cost of a failure of judgment is large. This risk becomes extra large when the new job includes a move of either your current job or your current hometown or both.

Now multiply that by 5 for the mob.

Add to it the fact that both sides are looking for the entire mob to be hired, only 1 or 2 of us isn’t what is desired.

Finally, the ‘entity’ that is looking to be hired hasn’t even formed yet. The 5 of us had not worked together and the dynamics of how we will work together are still unknown. And the only way to detirme this is to take the time to allow us to figure it out.

Here is the solution we came up with and it worked well in solving out of the above problems. I’m sure its not the only way to tackle this problem but I was happy with it’s effectiveness.

Minimum Viable Hire

Most of agile looks at breaking big risky things into smaller more concrete tasks and then assessing the next step with the help of actual data & experience. So we took the same approach with the interview.

Rather than going from a few hours of talking, to everyone quitting their current jobs and signing on full time, we introduced some middle steps.
In particular, we decided to start with two separate consulting trails of two weeks each.

Advantages of the trial consult

This offered many advantages.

Each member of the mob simply took their vacation time which meant that no one had to quit their current jobs until they were sure this was the right move.

 Likewise, no HR and no unemployment from the hiring company if they decided we were not the right fit for them later on.

This allowed for time for the mob to form so all party were acting on first hand true information about what we would be like as a functioning mob. No guess work needed

There can be a large difference between stated values and demonstrated values. This was long enough to get past the ‘honeymoon phase’ and have a clear understanding on all sides

As a matter of practicality we decided to average all our rates so that all of us started out on equal footing. While I’m an advocate for open salaries I do not believe everyone should be paid equally. However, this was a temporary measure to allowed a much cleaner start and I believe it also leads to a fairer final pay scale.

Note: I was the highest paid of everyone which means I had the most to lose (my rate was about ½ of my normal rate when averaged out with the 5) and I still believe this was for the best long term results.

So we simply added 2 smaller steps between first introductions and full time employment and it was better for everyone.

Next week: Discovering the right Physical Environment for the mob.

About the author:


Llewellyn Falco is the creator of ApprovalTests & cofounder of TeachingKidsProgramming. He is currently a consultant and Technical Instructor. He introduced Woody to the randori style of programming and has been a fan of Mob Programming since the beginning. 
You can follow him on twitter at @LlewellynFalco or email him at isidore at setgame.com

Tuesday, October 7, 2014

Putting together a new Mob

Hello. I’m Llewellyn Falco and recently I embarked on forming a 5-person mob to be hired for full time employment. This series is about our journey where I will share the good and bad so others can benefit from our experiences.

This week:

Putting together the Mob



The final 5 of us all meeting for the first time for a get to know you dinner

A very common question is
“What’s the right number for a mob?”

Of course, there is no right answer for this and we tend to use the heuristic of

A mob is the right size as long as:
Everyone is learning or contributing

However, if you are assembling a mob for full time hire then that heuristic is not very valuable.  So here is what I used with the best understanding I have as to why I choose these strategies.

Size: 4-6 people

This really came from the idea of the Amazon 2-pizza box team. I wanted a team that was small enough to really operate as a team. I did not want to try to start more than one mob at a time and I didn’t want the “scrum of scrums” approach. We were looking for the “matrix of indepenant services”

Individuals

Finding the right people is always a tricky thing. I wanted an all-star team of some of the best programmers I know. As such I quickly made a list of the top 20 programmers I was aware of in southern California. This gave me a playing field, but there was still a lot to do.

Gathering Talent: There are the practicalities that none of the best people were unemployed, which makes it harder to hire them. However, this is a real plus for mob programming. Being able to work with the best people is a real incentive for the top people and many people on the list were willing to explore this opportunity despite already having great jobs.

Skill Sets: I also needed a good mix of skill sets and personalities. When I say skill sets I don’t mean the trivial things like json or c#; anyone can pick those up quickly in a mob. 
I mean harder to learn things like: 
artistic ability, 
algorithmic thinking, 
sense of style, 
emotional intelligence, 
creative problem solving, 
etc. 
I wanted a good mix of these harder to learn prophecies to create a more diverse mob.

I ended up with a 5 person mob ( 2 people turned me down ). I had worked a little bit with each of them on some open source projects and some of them knew/worked with each other beforehand but we had never worked as a mob before.

But now we had chosen the mob. We met for dinner (pictured above) and set out on our next adventure.

Next week:  How a company interviews for a 5 person full time hire.



About the author:


Llewellyn Falco is the creator of ApprovalTests & cofounder of TeachingKidsProgramming. He is currently a consultant and Technical Instructor. He introduced Woody to the randori style of programming and has been a fan of Mob Programming since the beginning. 
You can follow him on twitter at @LlewellynFalco or email him at isidore at setgame.com