28 December 2015

Testing Koans

Koans
Koans have been proposed as an effective way to learn a new programming language. But what exactly are Koans? According to Wikipedia a Koan (where the o has a macron, a straight bar placed above it - which my text editor refuses to produce) is a "case, story, dialogue, question or statement in the history and lore of Zen Buddhism". Huh? Reading the Wikipedia article did not help me at all. All I understand is that a Koan is something the Buddhist monks would work with, a mystical sentence or maybe a kind of poem, which does not make any sense, but somehow helps them on their way to enlightenment. It seems the metaphor has been transferred from Buddhism to software, e.g. Hacker Koans and Koans are related to the TAO of Programming. (Again no idea what TAO is supposed to mean here. This is like a recursive definition.)

Ruby Koans
As far as I know, the first Programming Koans were available in Ruby, created by the late Jim Weirich, a popular Ruby hacker. Ruby Koans consists of several little exercises, starting with basic things and building on each other to move to more advanced topics in the end. The goal is to learn Ruby, to walk the "path to enlightenment" as Jim put it. He also wanted to teach the Ruby culture. The Ruby community has a strong focus on testing, which is considered essential to "do great things in the language". In fact the exercises are a list of failing test cases, where tiny pieces of code have to be filled in to make them pass. For example, here is the exercise to learn accessing array elements,
def test_accessing_array_elements
  array = [:peanut, :butter, :and, :jelly]

  assert_equal __(:peanut), array[0]
  assert_equal __(:peanut), array.first
  assert_equal __(:jelly), array[3]
  assert_equal __(:jelly), array.last
  assert_equal __(:jelly), array[-1]
  assert_equal __(:butter), array[-3]
end
Doyle Spiral + InversionThe double underscore marks the place where the code has to be changed to make it work and pass the test. These tests are very simple and there is not much explanation. Maybe this is the connection to the Zen Koans: The Language Koans are a list of exercises to work through, to master the language (i.e. reach enlightenment). Each one is very small (i.e. a sentence) but does not make much sense on its own. The exercises are sorted by increasing difficulty (i.e. the path to walk). Following Jim's example, Koans are usually based on unit tests which you make succeed. Language Koans are available for many programming languages, see a list of Koans by Laura Diane Hamilton.

Testing Koans
I took the idea for Testing Koans from Carlos Blé's training JavaScript for Testers. He created some Koans for JavaScript with inverted work-flow. The code was already in place, but the assertions were missing. That was reasonable as the training was created for tester.

xUnit Koans
Earlier this year I ran an introductory unit testing workshop for the local PHP community. I expected a junior audience and aimed for the most basic exercise for xUnit assertions and life cycle methods. I wanted the participants to focus on PHPUnit alone. I created some sample code, together with unit tests, and then deleted the assertion statements. The first test looked similar to the following Java code:
import org.junit.Test;

public class Session1_GreeterTest {

  @Test
  public void shouldReturnHelloName() {
    Greeter greeter = new Greeter();
    // TODO check that "Hello Peter" is greeter.greet("Peter")
  }

  @Test
  public void shouldReturnHelloForNull() {
    Greeter greeter = new Greeter();
    // TODO check that "Hello" is greeter.greet(null)
  }

  // more tests skipped...

}
The participants went through the tests one by one, adding assertions or fixing incomplete statements, making the tests pass. While this looked like a very basic and short exercise, developers unfamiliar to PHPUnit (and xUnit in general) needed several hours to complete all my PHPUnit Testing Koans.

Due to the uniform nature of all xUnit ports, the style and structure of the exercise can be used for other programming languages. I ported the exercise to Java using JUnit, creating Java/JUnit Koans. Both Koans cover the basic functionality of PHPUnit and JUnit, e.g. assertions, testing for exceptions and before- and after-methods. More advanced features could be added. I will port the Koans to C#/NUnit and Ruby/minitest as soon as I will need them.

Conclusion
Koans are a great way to partition the process of knowledge acquisition into a series of little exercises. They verify themselves, giving you fast feedback but you can still learn at your own pace. Language Koans are established and available for many languages. These can be extended to any library or public API you want to master. Testing Koans work similar, just inverted. They are available for PHPUnit and JUnit for now. I would love to see more ports and also Koans for different testing styles, e.g. RSpec or Jasmine Testing Koans.

20 December 2015

Interview Christoph Neuroth

C089 - or Christoph Neuroth - was the Code of Conduct "officer" at SoCraTes Belgium. Obviously I asked him to answer my questions. Here is what he wrote. If you want to know more about Chris, read his blog or find him on Twitter.

Turbo Basic (HDR)Christoph, how did you become a software professional?
It started when I found a tutorial on programming in BASIC as a kid. I really liked video games and writing stories, so I wrote text adventure games with that. I was hooked and started saving my money to buy books on programming and educating myself. At the same time I had tons of problems at school. I was later diagnosed with ADHD but this was way before that became a well-known "condition", so they just tried to get rid of me and at least one teacher told me I would never achieve anything. But I couldn't care less: I sat through it, went home, told my parents there was no homework and wrote code. I cannot really recall wanting any other job since then. I cheated my way through school to get some degree that allowed me to go to university with the least effort possible and went on to study computer science, which I believed was the road to becoming a professional software developer. That was a bit naive though and I did not learn a lot of useful things about software development there and continued to self-educate instead. It was a great time for personal development though. I also worked part-time programming jobs to get more experience and after graduating went on to become a full-time developer. The really important thing however was that by chance I got to meet people from the craftsmanship community. I had read books like Clean Code and understood about the importance of testing already, but learning from all these people and becoming an aspiring craftsworker myself was so important.

My most recent big success was going independent last year. I currently work as a developer in teams and lead by example when it comes to better ways to build software, run training sessions on testing and design and advise technical management on what they can do to help their developers get better. Going freelance allowed me to level up my career in many ways that were not possible in a traditional employer/employee model. But more important to me are the small, everyday successes: When a developer tells me she learned something useful from me or that I helped her team overcome a problem. That is what gives me the energy to pursue excellence and keep going.

And you already know I also organise SoCraTes Conference, an un-conference for all people that are passionate about well-crafted code.

I know that you are vegetarian and noticed you sharing content about diversity and harassment. Why does that matter to you?
Well, vegetarianism (or my as of now part-time veganism) is the much smaller thing for me really. After moving out of my parents place I had to care for my own food, so I had a reason to think about what I eat. I gradually and unconsciously removed meat from my diet. At some point I noticed "oh, I am a vegetarian", and went on with my life. It was later that I began to think more about the ethics behind that and while that is interesting, I think it is much more pressing to talk about diversity and harassment in our industry. Many people that are actually affected by this have written about this question and I encourage everyone to listen to them, but as you specifically asked why it matters to me, here goes:

Being a software developer is a great job. It has given me the opportunity to do something I enjoy for work, get a very good salary plus freedoms people in other professions can only dream of on top (right now I am working from the beach in Tunisia to escape the cold German winter). But many people with more talent than I have need to work much harder to enter this profession, and when they make it, they end up in a hostile work environment. Here's the problem with this industry: Way too many of us are able bodied, cis, straight, white men in their twenties or thirties - just like I am - and the moment you do not fit in, you are likely to be discriminated and harassed in this industry.

This initially is not obvious because it is so prevalent in the whole society, and sold to us as normal. But once you realise it, it cannot be unseen: When I recently recommended a junior developer to check out some videos by Sandi Metz and ended the sentence with "she taught me a lot", he uttered a "she?" that sounded not just surprised, but rather disdainful. I have seen whole offices with a culture where using "gay" as a synonym for "bad" did not even make people raise an eyebrow. I have seen rape jokes posted on the wall of a 100% male development teams' office. All those things and much more, every day. I do not want to work like this, and no one should have to.

Now most people are not that bad - they do not want this, and I am sure they often feel uncomfortable because of this. But they may be afraid to speak up, so it is important that those who have really nothing to lose do. So, because I enjoy the privilege of being in this industry, not having to fear and having my voice heard, it is my responsibility to say something. That is why it matters to me. And we will all benefit from this: We will get to work with many new talented people that we excluded before and can together raise the bar of professional software development, which is what craftsmanship is all about. Sure, we may lose some too: those that show toxic behaviour and do not want to change - but are we really going to miss them? I do not think so.

Refugee Welcome Center HamburgWhat other topics are you concerned about and what do you do regarding them?
I am concerned about many things really, but of course I cannot act on all of them. The other really big issue that has been interesting to me the last years has been how we treat refugees that come to Germany. As to what I actually do, I do not want to go into details but rather look at that question from a different angle, one that is related to craftsmanship too: Probably not enough.

I am often concerned about not doing more work like that; and instead go to a client’s office where I make money building things that do not really improve society. And in our community, we put a lot of focus on lifelong learning, and then I do extra work like organising SoCraTes. I often wonder if my priorities are right. For my career, definitely; but will I be satisfied with this when I look back on my life one day? I am not so sure about that.

Outside your personal topics discussed till now, what do you consider the biggest challenges of our times?
Finding a way to thrive on another planet before we completely ruined this one.

When I talk to people, many express concern about meat mass production or pollution, but almost nobody really acts on it. What could we do to engage in the topics? For example, did you take part in public protests, donate money to NGOs or sign petitions?
I did all of that, at different times and for different things, yes. All of these things can be helpful, it is just a matter of choosing the right tool for the right problem. Regarding things like factory farming and pollution, I think the most effective protest happens through consumption, or rather the lack thereof: People do not mass produce animals because it is such a fun thing to do, they do it because it is a profitable business. So in the system we live in that is the way to end factory farming: Take away the profits.

However, that is fixing a symptom, not the root cause: Greedy people will exploit something or someone to make a bigger profit. When it is no longer factory farming, dirty engines or selling tanks to Saudi-Arabia, they will find something different. I do not really have a solution to that. While we have made progress in technology, when it comes to being respectful to each other and nature, we haven't really made that much progress. It is just very frustrating really.

I would like to see more impact on these important topics of my regular work. I would like to keep doing what I can do best and earn my salary as usual, just working on "the right things". Do you think that is possible in general?
Do we really need that "usual" salary though? Many of us could probably live on so much less! Last year, I moved out of my big flat, sold or gave away nearly all the stuff I had and since then I have lived a much less cluttered and happier life than before. Today, I could easily work for less money or just work less. But I remember the time when a person I trusted stole a good amount of money from me, I lived with friends for a few months and then spent years paying back loans. That is the way capitalism takes us as hostages: Every time I get to decide "do I want to take that contract, or spend three months doing voluntary work for refugees instead", this situation will be in the back of my head.

The other thing, and I guess that is true for you as well, is that I actually enjoy what I do for a living. Finding a way to contribute more to society with the skills I have would be wonderful. I think it would very well be possible, but right now I feel it is very hard to find. I cannot really think of software projects that have positive social impact and are backed by organisations that can pay market rate for their development.

There are many decisions we take before and during a project. Which choices do you think are relevant?
The Volkswagen scandal is an extreme example. While I have no idea if developers can be hold accountable for the fraud here from a legal point of view, it is very clear to me from a moral standpoint: It was their responsibility to refuse this work and blow the whistle. This is not something I would be a part of. But there are many small things everyone of us can do every day to improve things. Lena Reinhard recently spoke on that in her Talk About Everything that goes into more detail than Martin Fowler did in the talk Not Just Code Monkeys. She says it so much better than I could, so I will leave the stage to her: Talk About Everything.

How do you think about selecting industry, customer and project based on your values and social responsibility?
That has changed a lot for me. I chose my first job based on technology and so I ended in eCommerce by chance. Now that is an industry I am not very passionate about. Useful as it is, society has bigger problems to solve than improving the convenience of buying stuff. But at least it does not seem to be bad in itself.

As I can get to chose companies more frequently as a freelancer than as a permanent employee, this is now much more relevant to me. I will certainly not only base that decision on the money I can make. As I said before I would really love to work for a company that builds a product that actually has positive social impact, though I am not sure what that would be really. And after what I said about harassment before, it won't surprise you that I would prefer to work for a company where everyone cares about those things and is committed to build better work environments. I would probably even stay if I found a company that does both. But industry-wise? I am not sure, I cannot see any industry that is just "good". That is not how industries work I guess.

Do you have problems with any industries? What about the meat industry or weapon manufacturing?
I also do not think there are many industries that are inherently evil, so it would mostly be a case-by-case decision. Having a bank account is pretty useful compared to carrying around all your money, yet I would probably decline most banking-related projects - because I believe they are not about solving people's problems, but only about making rich folks richer.

Error 404 - Advert not foundThe weapons industry would surely be a no-go. A bit more surprising may be advertising: I view the advertising industry as somewhere between completely useless and outright evil. It is a whole industry that creates absolutely zero value for society. And it is not even that advertising is a mirror of a fucked up society with all it is problems - sexist advertisement only exists because there is a sexist society that responds to it. Capitalist consumerism only works if people stay unhappy, and advertisement is the primary weapon to create that unhappiness. You may think "weapon" is a strong word to use for that. Ironically, in Germany there is a campaign by the ad industry for itself (meta ads!) that says exactly that: "outdoor advertising: hits everyone". You hit people with your hands, weapons - or billboards. It is a very subtle war against freedom, and there is no opt-out of advertising. Which leads back to that thing I said before about being a hostage of capitalism: Ads are used to sell people stuff they do not need, which forces them to keep working their jobs even if they have ethical or moral issues with what they do for a living.

This brings me to another problem I have with my fellow humans: Our imagination seems so incredibly limited. When I say "let's ban ads", people always react with that old "that is not possible". Yet the city of Sao Paolo did exactly that with outdoor advertising in 2006, and the world kept turning even there. Why not try more of that.

Did you ever reject a customer or an actual project, that would bring you money based on your values?
Until now, that never happened. I am certain I would reject offers based on that if I had good reason, but being able to just walk away is also just privilege I have.

But how about the other way around? Maybe many companies do not even want to have people with ethical standards around, because their whole culture and business model is based on the absence of that? We are having this interview because in my twitter stream I mix things about my profession with my private views and I proposed a few sessions on diversity at SoCraTes conferences. I do the same offline: When I work at a client, I speak up against the kind of discrimination I described before. I usually speak with offenders in private the first time and then do it in front of their peers if the person person continues this behaviour. I think that in any group where someone shows such behaviour, there are people who feel this is not right, but do not speak up. So far I have never received any backlash because of this, but if that ever happened and the group decides I am the problem, I am more than prepared to get out of there, quickly. If I did not do it, it would make me an offender. I am in a luxury position of being able to speak up without fearing for my personal safety. If I did not speak up, it would make me an accomplice. So maybe some people will not hire me because of all this. I think I can live with that. I will go somewhere else. If society one day is so fucked up that I cannot get a job based on that, I will rather be poor than complicit.

On the other hand, what would be industries, customers and projects that you consider having a positive impact on society?
Maybe I am being pessimistic or just cannot see it yet, but I do not see how creating a software will improve things really. If anything, nearly all software is dual-use. Martin Fowler used the example of the developer that wrote printer drivers and how that is useful when you are building a house. While that is certainly true, the same printer driver can also be used to print the verdict that sentences a person to be killed by a fascist regime. Building software is something I enjoy and that pays my rent, there are many things wrong in how we do it and we can improve on that - but I do not see a way to make it an inherently good thing. It will be as good or bad as the people who write and use it. I really hope I am wrong with that though and will find projects to work on that are fulfilling on that level too.

Thank you Chris
Thank you

11 December 2015

Interview Samir Talwar

Next in line is my friend Samir Talwar to share his views about meaningful work. Read his blog or find him on Twitter to get in touch with him.

Samir, please take a few sentences to introduce yourself in a professional context.
Samir Talwar, software developer and software crafter from the UK. I like to break things. I am currently focused on automation of large systems - deployment, testing and such. I have been developing software for five years full-time, about ten years part-time.

I know that you are concerned with social topics. Why does that matter to you?
I think my position in life is mostly down to luck. Software development is profitable, and I am lucky I am good at that rather than, say, gardening. I know people who do more important things like teaching, but get paid less. We spend lot of time destroying jobs. In return, I would like to help people suffer less or educate on things that make others suffer less. Also I believe we should have a Universal Basic Income, so people do not have to worry about eating or paying the bills.

austerityWhat other topics are you concerned about?
In Britain there is a huge push towards austerity, despite the opinion of most economists that it is a terrible idea. It is an ideological push rather than an economically sound one by our right-wing government, and the media are simply pushing in the same direction. We do not have enough well-known independent media institutions in the UK; most are owned by a few right-wing moguls.

I do not believe in the current implementation of capitalism, because some people do not work and get a lot of money - landowners, for example, who make money by the appreciation of their land, which is mostly down to the surrounding area. Destroying the environment is not recognised as a cost, so it is often cheaper in monetary terms than taking care of it. In addition, the jobs that people want to do are often paid less because the recognised importance is considered a substitute for money. For example, teaching makes less money than many jobs, so fewer good teachers are available. The large and complex society we have built does not value important roles as much as they should be valued due to short-term thinking. This is my top concern right now because it is in my face.

Otherwise, I am concerned about many issues. 1. There is war in Syria, and no one will take responsibility for the refugees, despite recognition that the war is partially the fault of Europe. 2. In the software industry many people are under-represented, e.g. women, black people, gay people and trans people. I see this close-up, as it's the industry I am in, so I am trying to do something about it, even when they are under-represented in many highly-paid industries, not just in this one. My main effort here is in attending and helping out with codebar.io to teach coding.

Outside these topics, what do you consider the biggest challenges of our times?
The environment. We are destroying it and we have no idea how to fix it. And even when we do, we refuse to. We are going to kill ourselves and everyone else if we continue on this path, but we do it anyway because human beings seem to be incentivised for short-term gain. I have no idea how I can help, as it seems to be not a problem of convincing people but forcing them to pay attention, which I am no good at.

When I talk to people, many express similar concerns, but almost nobody really acts on it. What could we do to engage in these topics?
I have reduced my meat intake to approximately one day per week and I tell everyone the health benefits. I donate to Greenpeace and other organisations. That is all I do for now though. I hope talking to people about it will help.

Most activities are personal choices or non-profit charity projects. This is great but most of our time is spent on regular work. I would like to see more impact on these important topics of my regular work. Do you think that is possible in general?
I think it will become increasingly possible as non-profit organisations move to the Internet for more than just petitions and newsletters. As we see the Internet become a force for change in its own right, we will be able to contribute with our skill sets.

There are many decisions we take before and during a project. Which guidance do you have to navigate these decisions?
I have historically been very bad at this. I do not think enough about how I might harm people simply by doing my job. I have recently decided only to work for small organisations and completely avoid large ones, which I hope will help. it is my opinion that because large organisations become faceless and bureaucratic, it is much easier for decisions to be made that harm people without any one person taking responsibility for their actions. If I am working for small companies, I will see the results of my actions directly, and I really hope this will make sure I hold myself accountable.

Syrian RefugeeHow do you think about selecting industry, customer and project based on your values and social responsibility?
I have worked in the finance industry, but I will not any more. I just do not think I am helping the world by funnelling money around for no reason. It is a recent call for me, but I am going to try and avoid industries or projects that I think would make the world worse.

Do you have problems with any industries?
The difficulty here is the personal consequences. I have people who depend on me to provide some income, so quitting a job does not just affect me. I am finally getting to a point in my life where this isn't so much of an issue, as finding a new job should be pretty easy right now, so I can afford to make a decision to quit.

I finally think I am comfortable quitting a job as soon as I find out it is involved in something I find morally reprehensible. These include the military, intelligence and incarceration industries. The others are less black and white; I have heard that the percentage of people in porn coerced into doing the job is very low, though I do not have the numbers to back this claim, and I have no issue with consenting adults doing whatever they like on camera, as much as I would like to avoid being in any part of the industry myself. Sweatshops are horrible places, but often they are the difference between a job and starvation.

Did you ever reject a customer or an actual project based on your values?
I have until now only been working in permanent jobs, but I have turned down a job offer and quit another based on my morals.

On the other hand, what would be industries, customers and projects that you would consider important and would have an impact on society and the problems we discussed earlier?
I would love to work in something related to health care or self-improvement, either physical or mental. I have experimented with software that teaches coding in the past, and found it incredibly rewarding. I would also love to work on software that helps people retain their privacy.

Thank you Samir for sharing your answers with us. Good luck for your next stage of life.

7 December 2015

Another Journeyman Week

Recently I had the chance to accompany one of my fellow Craftsman to his work and immediately agreed to do so. While my own Code Cop Pair Programming Tour finished in 2013 I am still enthusiastic about being on tour. In the spirit of documenting my previous 13 weeks, I consider these past days to be week number 14 of my (probably never ending) Code Cop Tour ;-)

Room for Coderetreat Gran CanariaGlobal Day of Coderetreat 2015
To improve my facilitation skills, I ask facilitators to run trainings together with me. My friend Carlos Blé agreed to host me for a Code Retreat and I ended in Las Palmas, Gran Canaria for the Global Day of Coderetreat 2015. I recommend Gran Canaria for GDCR because the weather was much nicer than in Austria during mid-November.

For the Code Retreat itself I proposed to have a specific focus, a theme that we would use to shape the day. Carlos selected Object Orientated Design and we built the whole day around it. We started the day with a (very) short introduction - probably more a summary - of basic object oriented design principles. During the day we only used design centric constraints like No Naked Primitives or Tell Don't Ask. I was concerned that some people would like to try functional programming and indeed there was one participant working in Clojure in all sessions. But he did not complain and tried to fulfil the constraints, which was certainly a great exercise, even when using functional paradigms. We also asked participants to use Test Driven Development and pair programming, but we did not stress these topics. By making the Code Retreat more focused, we were able to exercise a single topic more in depth.

Besides from copying Carlos' every move, I learned a lot from the changed setting. I was a guest and knew nothing about how the Craftsmanship group of Gran Canaria and their Code Retreats. Further I had trouble communicating clearly and talked too fast for the Spanish participants. In return I did not get much feedback because I had not communicated well - which left me confused and made me sweat. I cannot remember feeling that exposed. The whole setting proved to be very challenging, exactly what I had been looking for.

Ruben wrote a summary of the day, which saved me from writing it myself. The slides Carlos and I used are available here.

AIDA Secret DoorAIDA Canaries
Because I "happened" to be around, Carlos invited me to spend a few days with his current client, AIDA, probably the largest IT company native to the island of Gran Canaria. I spend three days mob programming with Carlos, Emilio Medina and Ronny Ancorini. I used the opportunity to improve my C#, which I had not used since my session with Paul two years ago. I learned some more things about C# and ReSharper. We worked long hours and I did not see much of Gran Canaria during these days. As I had not come as a tourist, I did not mind.

Carlos published his summary of my visit already, which saved me a lot of typing again. (It seems that it pays off that my post is a month late ;-) I really loved staying some days in AIDA, everybody was nice and very inclusive. While a few employees had problems talking English, everybody seemed to appreciate my visit and the discussions I started. I enjoyed my time there. Thank you!

Spontaneous Unconference on Functional Programming
The following Friday I was lucky to meet Nicole Rauch. She had come to Vienna for her talk at the Agile Tour Vienna. She was one day early and we took the opportunity to spend the day together. While I had planned to host her, my friend Görge Albrecht, the "Code Mentor", stepped up and did the extra work of really organising the day, getting the necessary infrastructure and even paid for drinks and lunch. (Thank you Görge, I owe you.) The Software Craftsmen GmbH helped us out with their meeting room and shared their office with us for a day. The Software Craftsmen are a young company of experienced but still enthusiastic software professionals.

Mini Open Space MarketplaceSo a few members of the Vienna Craftsmanship group came together to discuss, share and exchange knowledge with Nicole. In the morning we collected possible topics. As Nicole is into functional programming, it was no surprise that Haskell, Monads and all kind of functional topics came up. We started discussing and reviewing one of her older presentation on Monads, which gave us plenty food for thought. In the afternoon we decided to do some coding and mob programmed an asynchronous error handling Monad in NodeJS. It was a great day and I learned a lot. Thank you Nicole for finding time for us and squeezing in a day of learning between your customer meetings, travel time and conference presentations.

Conclusion
The bottom line of this week is that our community is very inclusive. It is easy to find people who will accept you as a guest or be your guest if you just pay a little attention to their schedule. I had found Nicole's name in the list of speakers of Agile Tour Vienna, so I knew she would come. All I had to do was reach out to her early enough and we made it happen. The same was true for my visit to Carlos. I knew he would run a Code Retreat for GDCR15, so all I had to do was propose doing it together. I encourage you to look out for such kind of learning opportunities. Follow the people you meet at conferences, pay some attention to their (promotional) tweets and conference schedules and do not be afraid to reach out and ask them to spend some time together to discuss, learn, practise or just write some code together.