Improve problem positioning and solving skills through psychological knowledge (Part 1)

This article was first published by myself on the infoq Chinese site: http://www.infoq.com/cn/articles/improve-problem-solve-ability-by-psychology-knowledge-part01. Please indicate the author when reprinting: Huang Wenhai Source: http://viscent.iteye.com

 

foreword

Software development work can be regarded as a problem-solving process from both a macro and a micro perspective. From a macro perspective, software development, in simple terms, is to figure out what the customer's needs are, and then solve the problem of how to convert the requirements into code through a series of activities such as analysis, design, coding and testing. From a micro perspective, developers also face a variety of problems in their daily work. For example, the web server used to debug code suddenly fails to start, and the developer must fix this first, or the work at hand may not progress.

As a developer, instead of complaining about working overtime, it's better to reflect on where your time is going. I believe most of the developer's time is spent solving various problems. Whether you are a senior developer or a novice, you will encounter all kinds of problems in your daily work. The difference is that a problem that an experienced developer can solve in seconds can take hours, or even a day or two, for a novice! It can be seen that improving the problem-solving ability of developers is of great significance for both individuals and teams.

In fact, psychology, as an independent discipline, has its own special research on problem solving. Its research results are worth learning from to improve our own and other members of the team's problem-solving skills. This article will introduce the knowledge about problem solving in psychology to readers, and give relevant guidance to improve problem solving ability in combination with the characteristics of software development work. Readers without a background in psychology don't have to worry about "interlacing like a mountain". Most of the psychological terms involved in this article are easy to understand.

Revisit what is a "problem"

To improve your problem-solving ability, you must first figure out what a "problem" is, and then you can talk about how to solve it more efficiently.

Psychology defines a "problem" as a "stimulating situation in which there are certain barriers between the given information and the goal that need to be overcome". The popular understanding is that for a given initial state of things (the so-called "given information") and the target state, we do not know how to convert the initial state into the target state (the so-called "obstacle"), and the "problem" arises. For example, in the famous Vannota problem, the initial state is that 64 disks are on pole A, the target state is that all disks are on pole C, and each small disk is on top of the large disk. The "hurdle" that exists that needs to be overcome is how to move the 64 plates from the A to the C pole.

Figure 1. Vannota problem

 

According to the above definition, problem solving is the process of overcoming "obstacles", that is, the process of finding a path from the initial state to the target state. For example, in the Vannota problem, we repeatedly use the B rod, and finally the process of moving all the plates on the A rod to the C rod "untouched" is the process of solving the problem.

Improving problem solving, then, is improving our ability to find a path from an initial state to a goal state.

For the convenience of the following discussion, the "problems" in the field of software development are simply divided into well-defined problems and Ill-defined problems. The former refers to problems in which the initial state and the target state are clear, such as the Vannota problem. The latter refers to problems with an initial state, a goal state, or both, which are often more difficult to solve and require more of the problem solver. Problems related to software operation and maintenance fall into this category. For example, there is such a problem: the database system in a production environment is automatically restarted, and the cause needs to be found out.

mental process of problem solving

Just as understanding how computers process information helps us use computers better, understanding how humans solve problems helps us solve problems better.

Psychologists generally decompose the problem-solving process into four steps: problem representation, problem-solving plan design, execution of the problem-solving plan, and monitoring.

Problem characterization refers to specifying the initial state of the problem, the target state, and the allowed operations and constraints that must be satisfied. In the Vannota problem, the problem solver first characterizes the problem, that is, to figure out: 64 plates are on the A pole, the small plate is on the large plate (initial state), and the goal is to move these 64 plates to C On the rod, each plate on the C rod still keeps the small disk on top and the large disk on the bottom (target state). During the moving process, the B rod can be used, but during the moving process, ensure that the small disk is always on the large disk (allowable operation and must meet the requirements). limits).

Designing a problem-solving plan refers to identifying steps to solve a problem. By comparing the initial state of the problem with the target state, the problem solver of the Vannota problem prepares to use the B rod to recursively move all the plates of the A rod to the C rod, which is to design a problem-solving plan.

After the problem solver has designed the problem solving plan, he will execute the problem solving plan, and during the execution process, he will always check whether the current operation is helpful to solve the problem and whether the relevant operation meets the limitation of the problem, that is, monitoring is performed. For example, the problem solver of the Vannota problem should pay attention to whether the small plate is on top of the large plate during the process of moving the plate, and whether the result of moving the plate is as expected, so that more and more plates are placed on the C-rod. .

Below we discuss the psychological factors that influence problem solving.

Psychological factors that affect problem solving

how the problem is represented

The problem representation in the first step of problem solving can be further divided into two small steps: surface understanding and deep understanding of the problem.

Surface understanding of a problem is the process of describing the problem in the language of the problem solver, which is the most basic step in solving the problem. The deep understanding of the problem is based on the surface understanding of the problem, and further synthesizes each statement of the problem into a unity of conditions and goals. In this sub-step, it is very important to distinguish between relevant and irrelevant information in the question. For irrelevant information, it can be ignored, or it can be understood and represented in different ways (ie, representation).

In the process of deep understanding of the problem, different ways of representing the problem may have a great influence on the difficulty of solving the problem. This can be reflected in a typical problem - the problem of monks going up the mountain (see the sidebar on the left).

The intuitive reflection of the question of monks going up the mountain is that it seems unlikely that there is such a point, because the speed of the monks going up and down the mountain is not the same. However, when we found that this problem can be regarded as such a problem: two monks at the same time, along the same mountain road, one going down the mountain and the other going up the mountain, the answer is very straightforward: there must be a point on this mountain road , at some point the two monks will meet. Well, the answer to the original question is yes. A key step in solving this problem is that in the process of deep understanding of the problem, we use a different way to represent the problem than in the surface understanding of the problem: the problem in the surface understanding describes the same monk going up and down the mountain, while the deep understanding When we find out whether it is a monk going up and down the mountain is an "irrelevant" information, we can understand this information as two monks going up and down the mountain at the same time.

 

下面看一个软件开发中的实际例子:我们要对网页上的一个表示文章关键字列表的字段的值进行合法性校验。校验的规则是该字段的值不能为空,若字段值不为空,则多个关键字间用英文分号分隔。例如:“keyword1;keyword2;keyword3”。显然,这个可以用正则表达式来校验。问题就转化为这个正则表达怎么写。按照问题的表层理解(如上面文字的描述),关键字列表的字段值的格式会被表征为:

(关键字1)+;+(关键字2)+;+(关键字3)+...

这样的表征固然直白简单,但依照这个表征,相应的校验正则表达式不是那么容易写。相反,如果把字段值的格式换作另外一种表征,相应的正则表达式就容易写得多:

(关键字1)+(;关键字2)+(;关键字3)+ ...

依照上述表征(即从第二个关键字开始,每个关键字都需要以";"为前缀),可以得出相应的正则表达式(Javascript语言表述)为:“^[^;]*(;[^;]+)*$”。

因此,当我们在解决问题,尤其是一些比较困难的问题时,若没有什么进展,而又没有什么新的思路时,不妨回到问题的原点,重新去表征问题,换一种新的方式去表征问题。或许,这个时候就会豁然开朗。这就好比我们在侦探题材的影视作品中经常看到的情景:侦探在查案过程中,费了许多人力和时间案情都没有什么进展,这个时候要突破困境的一个好的方法是从“零”开始:重新回到案发现场,重新去寻找蛛丝马迹,重新进行推敲。这个时候,案情往往就柳暗花明了!

问题的表征充分程度

若我有一小时的时间来拯救世界,我会花59分钟来定义这个问题,并花一分钟的时间来寻找解决方案(If I had an hour to save the world, I would spend 59 minutes defining the problem and one minute finding solutions)。 ––– Albert Einstein

 

心理学研究表明,在解决常规问题时,专家比新手快得多。而在解决困难问题时,专家用于表征问题的时间比新手要长一些,他们会用更多的时间去收集问题的相关信息,因而对问题的表征更加充分。

有这样一个个案。运维人员报告某个生产环境的进程数过多,向研发人员求助定位该问题。而对方所提供的信息仅仅是说“主机上的进程数过多”,附带一款监控软件所报的告警信息:“XXX主机上的进程数超过260”。

该问题的解决过程是:首先,弄清所谓“进程数过多”,具体是什么意思。结合监控软件的告警信息,可以回答该疑问:所谓进程数过多,是指主机上所启动的进程数大于监控软件所预设的进程数量(如260)。此时,问题似乎明朗了:找出260个进程之外的进程是哪些,问题应该就能解决。但这也存在一个问题,假设进行问题定位的时候,该主机的进程数是265个,这其中的每个进程对我们来说都是没有差别的,我们又如何将这些进程区分为两部分呢?进一步向对方询问得知,问题所涉及的主机系一个集群环境(共几十台主机)中的一台,而经过确认其它主机上并没有出现该问题。那么,通过比较该主机上的进程名称列表和集群环境中另外一台主机的进程名称列表,可以发现出现问题的主机“多出”了哪些进程。最后发现,该问题系运维人员定制了一个定时任务,该定时任务调用的Shell脚本重复运行(前一次脚本运行对应的进程未结束,新的脚本运行又开始了),从而导致进程数越来越多。

当笔者将上述问题写为问题定位案例给新手进行定位时,新手的反应是懵了,不知从何下手。

正如上述个案所展示的,软件行业中遇到的问题多数是定义模糊的问题,尤其是一些生产环境中出现的问题。对于这样的问题,专家能够通过自己的分析判断、进一步收集与问题有关的信息,使问题逐步转化为定义良好的问题,再通过适当的问题解决策略(如上述的比较法),从而解决问题。而新手往往不知所措。

因此,对于定义模糊的问题,其解决思路大体上是试图将其转化为定义良好的问题,途径是通过分析判断,收集有关问题的更多信息。而对于新手,平时通过观察专家解决问题的过程,并试图模仿之,也是一个提高解决问题能力的方法。

观察能力

一切推理都应该从观察和实验中得来。

––– 伽利略

在解决软件行业的问题过程中,视觉是人脑获取信息的主要途径。解决问题的过程中,人脑并不是被动地接受视觉信息,而是通过有意识的、带有目的性的主动观察获取信息。另外,软件开发过程中遇到的问题多数是界定含糊的问题,通过观察获得有关问题的更多信息有助于对问题进行充分的表征。因此,观察能力在解决问题的过程中显得非常重要。在我们的日常工作中也不难发现一点:专家在解决问题过程往往能够从一堆视觉信息中快速捕捉到其所需的关键信息,而新手面对专家所赖以解决问题的信息时却往往视若无睹!

例如,如图2所示的一个几十行的Call Stack信息中,专家可以快速地定位到第35行这行关键信息,从而断定问题系磁盘空间不足所致,而新手则可能不知从何下手。

图 2. 从错误信息中快速定位关键信息

日志文件、软件界面等所呈现的错误信息是问题定位的一个重要信息来源。但是经验告诉我们,“二八原则”在此也是适用的:这些错误信息中的大部分对于解决问题来说是无用或者用处不大的,而那些对问题的定位和解决能够起到决定性作用的关键信息往往就那么几行甚至一行。因此,能否在这些大量的错误信息快速找出那些我们需要的关键信息,往往决定了问题解决的效率。

快速找到我们所需的关键信息,需要问题定位者的拥有敏锐的观察能力。提高观察能力,首先需要意识到观察能力的重要性。其次,在日常工作中逐步地学会区分自己在问题定位过程中所遇到的错误信息,哪些是关键的,哪些是帮助不大的。再次,掌握一些获取关键信息的基本技能。例如,对于与数据库有关的错误信息,要能够重点关注数据库系统所报的错误码。对于Java Call Stack信息,重点关注“Caused by”部分的头几行。

笔者曾经通过引导组员意识到其观察能力的薄弱和观察能力的重要性,并通过实际的问题定位向其展示如何快速获取关键信息,帮助了组员一定程度上提高了观察能力。

小结

本篇介绍了问题解决的心理过程以及问题表征阶段影响问题解决的一些心理因素。并结合笔者实际经历的例子通过比较专家与新手在解决问题时表现出的差异给出提高问题定位与解决能力的指导意见。下篇将介绍影响问题解决的其它心理因素,并给出相关指导意见。

作者简介

黄文海,著有《Java多线程编程实战指南(设计模式篇)》。有多年敏捷项目管理经验和丰富的技术指导经验。关注敏捷开发、Java多线程编程和Web开发。在InfoQ中文站和IBM DeveloperWorks上发表过多篇文章。其博客:http://viscent.iteye.com/


感谢张龙对本文的审校。

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326420695&siteId=291194637