Applying Problem-Solving Techniques to Programming
( Source: https://pixabay.com/de/schach-spiel-schachbrett-glas-433071/ )
This is the corresponding blog post to my previous SAPTeched talk in Barcelona 2017. First of all, it is for me the solution to remember the key topics of this talk and I hope also helps everyone who is curious about this topic.
This is a really interesting topic for me and I hope you’ll enjoy my post here. I will show you a technique that highly successful people use to create innovative solutions. You will learn a simple 4-step problem-solving process that you can apply in your everyday work, as well as a couple of more insights into the best practices for problem-solving.
The first time that I seriously thought about this was when I read an article in a German newspaper.
( Source: http://www.bild.de/news/inland/hochzeitsreise/hochzeitsreise-mann-vergisst-frau-an-tankstelle-32938580.bild.html )
In the newspaper, the husband forgot his wife at a gas station and I was thinking “oh my God, the poor woman” but also “the poor husband! He must be a Software Engineer, who had so much pressure on him that he forgot his wife at a gas station!”
I was thinking “okay, this is really a problem and are there any problem-solving techniques or strategies that we can apply in our daily business?”.
First, I started with the phrase “problem-solving”. I think the problem is also related to this wording since if we are only thinking about problems, then the solution part becomes smaller and smaller.
I prefer the phrase “solution finding” because it represents a different mindset. Here, the phrase “solution” is emphasized and this positive mindset will give you more confidence and optimism about finding the right solution.
Not only finding one solution but searching for multiple solutions.
( Source: https://pixabay.com/de/h%C3%B6hlenmensch-h%C3%B6hle-mann-primitive-1460898/ )
- For example, imagine 100,000 years ago: a man and a woman are sitting in a cave and it’s really cold.What different strategies could they apply to get rid of this coldness in the cave?
- The first option could be to ignore the situation, but this won’t work.
- The second strategy is to wear some clothes or to make some clothes out of animal pelt.
- The third strategy could be to focus on human closeness and warm each other up. Yes, this is also a possibility…
- The next option is to seal up the cave
- And the last option is to light a fire that will warm up the cave.
In this case, we have multiple options and we must select what fits best for us. We start with the easiest one or the most effective way – here we are using wishful thinking. How cool would it be to switch on fire when we need it?
Here we are starting to deeply think about this possible solution. Investing time, we remember situations we’ve had before with fire, and which situations lead to a fire. We identify fire after a storm, and also during a dry period, where dry wood very easily sparks and starts a fire. We also remember seeing sparks when firestones are rubbed together.
By, using associative thinking, we find some situations that offer a solution that we want to use. By starting to make some prototypes we explore possible solutions:
Let’s say, for example, that using firestones didn´t work. Here we have the possibility to decide if we should continue our exploration or stop at this step.
Finding no solution is not the goal, so we continue with the next strategy and at the end, with some luck, we manage to light a fire in the cave.
So what is the main point of this example?
Don’t give up too early.
As human beings, we like to puzzle and this makes us feel good. If we the find solutions, we become motivated. From the psychological perspective, this is called the ‘upword motivational spiral’ because it will lead to progress and improvement.
How to become better
There is a huge motivation to become better and better in solution finding. What is the way to achieve this?
It’s similar to other disciplines. If you want to become better, you have to practice a lot.
Everything has to do with training and experience. If you exercise your brain, you gain new knowledge. This knowledge will motivate you and help you to find better solutions. With more knowledge, you can think of good ways to solve something.
- It is similar to working with a hammer: if you want to hit a nail, then a hammer is the perfect tool and you are getting better and better. But imagine you need different kinds of tools…, If you could only have one tool then you would probably choose a Swiss Army knife, for example.Then you could use the appropriate tool for the situation you need to solve.
- It’s really similar to IT, because if you only have knowledge of one kind of solution, then your options are limited.But imagine you have more options in your toolbox… then you will use the right solution and it’s better to do this than just doing it the only way you know.
- There is also a different aspect of how to become better and it´s a lesson I learned from chess. A couple of years ago, I was playing chess with the world champion in chess problem-solving Piotr Murdzia. He explained to me how he became a world-class chess problem solver and what makes his approach different to others. Everything is related to training. At one point he realized that his intuition, his gut feeling, became so good that he could immediately recognize the right move when playing chess. He only had to verify his intuition. This works well because for 95% of the problems he faces he knows the right direction. This kind of chess-move-process drastically shortened the time for analysis and for verification. He’s able to solve problems in a shorter time and on a higher level.
This can also be applied to programming. If we have a variety of knowledge then we can use the right tools for our problem, but if we only know a limited number of programming topics, then we will limit our chances of finding good solutions.
As Ward Cunnigham said: “not only working software counts but clean code that works.” And to find out in different contexts what clean code means, we have to broaden our knowledge, and what is more important, stay up-to-date.
If we keep practicing, at some point we will develop our intuition and create a personal compass, which will be useful for our programming tasks. Sometimes it will help us to decide on the lowest level: for example which kind of programming algorithm we have to use. Sometimes this compass will help us decide which kind of architecture is the best or which kind of interfaces we should create. It can also tell us the kind of dependency we have to break or the kind of abstraction that is necessary for the programming problem we have to solve.
Imagine, for example, you’re like me: you want to lose some weight and you have many different strategies that you could try in order to achieve this goal to solve this problem.
- You could focus on your diet but this strategy is not enough on its own. As solution finders, we have to think about multiple options to see if we can combine it with another strategy that will help us solve the problem more effectively. For example, in this case, another strategy we could use is to exercise. With these multiple strategies, we will achieve better results: we become motivated, the results are achieved faster, and at some point, we are in an upward motivation spiral, which produces a positive snowball effect and helps us to lose weight.
We are losing weight, we are having fun, we are doing exercises, we are more motivated, we eat more healthily and at some point, we achieve our goal.
I was thinking about this Strategy and through some lucky circumstances, I found a technique called ABC-List, created by Vera v. Birkenbihl. She died eight years ago, but, before her death, she introduced a lot of strategies and techniques to support learning and to support the learning process.
The ABC-List is a simple technique and it works like this:
- You have a piece of paper and on the left side you write down the alphabet beginning with a and ending with z.
- At the top of the page, you have some space for your title and then you choose a topic, for example: what kind of techniques Could I use for programming?
- And then you have three minutes to write down all of the techniques you can use for programming that come to your mind
This time pressure forces to use your subconscious mind and write down the first things that come into your head since you don’t have a long time to think.
After finishing the first list you take a short break and then you think about the next topic:
For example what made me successful during my previous projects. For this question, you also have three minutes and you must write down what comes into your mind. At the end of this exercise, you will have two lists.
Now the magic happens: Vera v. Birkenbihl realized that geniuses and really highly skilled experts use these so-called associative thinking techniques a lot and this brings different perspectives on the topic. Sometimes you will connect two independent topics, and it becomes clear that the connections can produce fantastic possibilities. This helps us to produce more options for finding better solutions.
A Process for Solution Finding
Now, it’s time to show you the simple 4-step problem-solving process that you can apply to find a solution to any problem.
There are four steps in this model.
- The first step is to understand the situation
- The second step is to identify the root cause of the problem
- The third step is to develop an effective action plan
- And finally, the fourth step is to modify and to test your actual options until the problem is solved.
The magic of this process is that it is an iterative model. If you come to a step with the conclusion something has to be modified, then go back to step number one and follow the process steps again until you find a solution that you are satisfied with.
There is also another aspect of this topic and this aspect is your attitude.
For example, we have a starting situation and a clear goal. There are 5 different attitude styles that you could have which affect the process, as described by Ken Watanabe in his book Problem Solving 101.
- The first attitude style is desperation. This style doesn’t help you achieve anything. You stay in the place you were when you started.
- The second attitude is criticism. This a safe situation because you’re still at the starting point and you criticise every possible option. With this approach, you will never take a step forward.
- The third style is the so-called dreamer With this approach you’re dreaming about everything but nothing is related to the goal. You need to take action instead of just dreaming if you want to actually solve the problem.
- The next style is the so-called goal getter With this attitude you are moving forward but you don’t take the time to understand the root cause of the problem [very short pause] or to analyze what the situation is. You are moving forward but sometimes you’re moving in the wrong direction. You are losing energy and time, and this is not an efficient way to reach your goals.
- The final attitude is the style I suggest for problem-solving … This approach is the problem-solving kids are really good solution finders because they’re always focused on the goal. They always have that goal in their minds and if they have to change their strategy or to add that extra something that brings them faster results, they will do it. We should also use this kind of thinking style because it is really helpful for finding solutions. The important thing to remember is:
Be open-minded, like a kid.
With this knowledge in mind, we have a better understanding of how we as software experts who need to solve problems all the time should work together. This is why agile models like Scrum are so successful. They are iterative processes and they encourage open-mindedness. This shows us that problem-solving techniques can also be applied to our work.
probably… how TDD was created
Kent Beck invented TDD. And in my wishful thinking, I´d like the idea that he identified the root cause of the problem when developing in a procedural style. First, you´re thinking about the requirement, then you start coding and maybe (by luck) you secure your coding with a test. Often at the end of a solution, you don´t have any tests…
At the end, probably Kent changed the development process by following an easy, but disciplined approach. First, to understand the requirement, then write the test code, and verify the test code with enough production code and continue with improving the inner structure of your code (aka. Refactoring).
Often when problem-solving, you don’t just get the obvious benefits of the solution. There are other less obvious benefits too. It’s important to remember this.
The experience taught us, by developing the TDD-way we got:
- a security net of unit-tests
- our production code have lesser lines of code
- we focus on what is really necessary
- we are the first users of our code, so the code becomes more API-ready
- our software architecture improves so that it becomes easier to change for the future
“Sometimes things fall apart so that better things can fall together.” – Marilyn Monroe
I hope that you’ve stayed with me until the end of this blog 😉 I wish you all the best that you adopt these problem-solving techniques and become better solution finders.