Wednesday, September 13, 2017

Write a Book Exactly as If You're Developing Code

A book is a product and writing books is exactly the same as developing a product. I'm using XP and Agile technical practices and techniques to write my first book Guess what? It works perfectly!

The story started sometime ago when I heard about LeanPub. It was cool and I thought I'll use it once. Now, I'm actively writing, or rather developing my first book: Refactoring to Clean Code:

The experience is very similar to developing a software product. Or, I can say it is exactly the same.
I'm not gonna talk about the book topics as features which may or may not suite your target customers, and how you should frequently pivot your strategy till you reach a solution market fit. These are very obvious similarities. Rather, I'll talk about the actual development of the book, producing book chapters, which is very similar to writing code modules.
I'm using version control, issue tracking, and full traceability (using github). I'm also using continuous deployment. Hah? yes, it is that black magic in software which enables features to be instantly deployed on production with very little overheads (for this, I use automated hooks which links githup with leanpub. Leanpub automatically generates a new version of the book upon every push from my side on github)
Finally, I'm using a full fledged development environment (Atom) which has realtime linter to check bugs on the fly (spelling and grammar mistakes). Atom in connects directly to github. So, I develop and commit changes on the same window.
Later on, I will prepare a test environment for my early adopters and reviewers. They will receive special editions from leanpub. They may open issues on githup, and even they may fix parts of the book and send me pull requests on github 
Those who love coding, if they thought of the book as a software product, they will love writing as well 
Would you like to become a reviewer (or early adopter)?
If you would like to become one of the early adopters, please let me know. Here is a link to the book with highlights about the contents:

Tuesday, September 12, 2017

Guidelines for Reviewing my Book: Refactoring to Clean Code


  • If you found a typo, change it right away and submit a pull request
  • If you have a better wording or phrasing, you have two choices:
    • Submit a pull request
    • Open an enhancement
  • If you open an enhancement, please link it to the section you're commenting on as such:
    1. browse the file on github
    2. hover on the section, you'll find a small link appearing as in the following screen shot. Copy the link and paste it in the issue. 



Sunday, June 18, 2017

Lessons Learned from Mob Programming

Recently, I had enough time to experiment with mob programming, a revolutionary technique for developing software. It's like pair programming with 6-7 team members in stead of 2! Seems ridiculous, right? This is how extreme programming (XP) practices seam at first before they spread like wildfire!

For those who didn't hear about it, please watch this video:


To get a deeper dive, watch this lecture by Woody Zuill, the father of the idea.

Currently, mob programming is spreading so fast in the world, and people are starting to realize so much value out of it. In the Agile Conference 2017 (which I'm on the reviewers list of its program), we have two sessions on mob programming, one talks about this technique used for on-boarding large number of people, and the other talks about it in teaching colledge students.

Working With Mob Programming Onsite

Now, back to the topic. I worked with two teams to whom I introduced and used this technique. One of them in co-located, and the other is distributed. I'll introduce the setup of the onsite experiment, then will list some observations and lessons learned from both teams.

We have restructured the room, got a projector, and started the session. Here is what we've done:
  1. We have dedicated an on-wall kanban board, other than the one on Jira
  2. Started with three main tasks for the day, which are the most important ones so far
  3. I have explained some basic rules for the game, one of which is that I'll act as the facilitator
  4. Then we started!

Rules of the game

Several basic rules are put into action:
  1. We'll break every now and then, probably once every 1-2 hours
  2. It's ok that you leave the room for any side task, not for so long though
  3. Any emerging unplanned task will be put on the backlog. We've started with three tasks on board, and ended up with about 13!
  4. Work is time-boxed from 10 am till 4 pm. No other "significant" work should take place outside these working hours

How people felt about it:

"Some tasks would have never been carried-out without mob-programming them" - one team member
 It's very interesting seeing how people interact and collaborate during the session. Here are some observations I noted:

  • Contrary to what I expected, technical leaders and development managers where happier with this technique. They felt more confident and more productive. Plus, they appreciated learning from other team members while mobbing!
  • Learning took place in all directions. seniors taught juniors and vice versa. Old team members taught new one and vice versa. This was amazing! One can never think of what new ideas, techniques, even inspirations he'll learn from other team members unless he start working with them hand-in-hand
  • Interaction and collaboration were high, definitely higher than solo-programming, probably a bit lower than pair-programming. Again, this is contrary to my expectation, which was that half of the team will take a long nap during the session :)

 Finally, here are some feedback points I got in the retrospective;

  • It was fun! and joyful
  • Some tasks would have never been carried-out without mob-programming them
  • We used to do the same task so many times. This way, we all do it one time!
  • Collaboration with the product owner is much better; we all ask him the same question, get the same answer, all at the same time
  • It's a better approach to reach the best solution for a problem
  • It's less suitable for small and easy tasks
  • It may be impossible to work this way if we're working under pressure

All-in-all, it was an excellent experience. Right now, I'm engaged with a company doing remote mobbing as a means to train new team members in a faster and more effective way. Guess what? Still the old team members learn from new ones!

Sunday, March 12, 2017

Ground Rules for Refactoring Legacy Systems


If you have a very poor code which is buggy, cluttered, ugly, scary, etc. If you have such code,  do one of the following:
  1. Sunset this application
  2. Ask your customers to stop asking for changes and fixes
  3. Quit your job and switch to a more convenient one (other than software of course)
If you can't do any of these, then you're stuck with refactoring this code base. This is possible and even exciting.

Here is a set of ground rules to take into consideration before you start doing that:
  1. Zero "more" defects policy: That is, stop working the moment you find the next bug, and fix it immediately. The rule is adapted from the Zero defects policy! which is a bit overwhelming at this stage.
  2. Any "new" code must be covered by tests. Period.
  3. Peer review is part of our DNA (till we're able to automate parts of this review, or all of it)
  4. The Boy-Scout Rule applies to all of us. 
  5. Automate all donkey work, one script at a time! That is, everything we do in a systematic way, can be scripted. What we should do is to automate all this work. 
If you do that, you'll find things slightly improving at the beginning, but exponentially improving later on, insha'Allah :)

Friday, March 3, 2017

How to find dead code?

Recently, I have read this interview with Kevlin Henney, an independent consultant and a great developer.

These are some very good insights about ways to find dead code:
  1. Static analyzers are a good start
  2. Search for files that has never changed since a while. "There are many reasons code may be stable — it’s just right, it’s just dead, it’s just too scary — but unless you investigate you’ll never know."
  3. Runtime monitoring and Dynamic program analysis may be used to rule out parts of the code which is not dead code, effectively reducing the code under investigation
One very interesting note is that:
"Deleting dead code is not a technical problem; it is a problem of mindset and culture."
Furthermore, in this very interesting lecture by Kevlin, he tells the very famous story about Kinght corporation which lost hundreds of millions due some dead code left over. Also, narrates some very interesting stories alike. I highly recommend any developer to watch this lecture.