串口调试程序例程_不仅在代码中调试日常例程

串口调试程序例程

Earlier this year, I was asked to give a short lecture in front of my colleagues, a daunting 400+ students, a lecture on Debugging, and since then, my approach to Web development and living have changed.

今年早些时候,我被要求在我的同事面前做一个简短的演讲,一个令人生畏的400多名学生,一个关于调试的演讲,从那时起,我对Web开发和生活的态度发生了变化。

(Disclaimer: There will be a lot of pasta talk.)

(免责声明:将有很多面食话题。)

Debugging is the process of checking previous chunks of code you’ve written, for errors. For reasons, like prevent unexpected behaviours, getting your code to work, and getting it to work better.

调试是检查以前编写的代码块中是否有错误的过程。 由于某些原因,例如防止意外行为,使代码正常工作以及使其更好地工作。

Make it work, then make it better and faster — Gabriel Alexander Stephen

使它工作,然后使其变得更好,更快— Gabriel Alexander Stephen

It was an impromptu presentation, I had studied for it but didn’t actually think I would get called to do it that day. I was shocked to see that people enjoyed my presentation.

这是一个即兴的演示文稿,我已经为它做过研究,但实际上并没有想到那天我会被要求这样做。 看到人们喜欢我的演讲,我感到震惊。

Talking to people about programming isn’t easy, it’s hard to keep their attention and honestly if you’ve come this far, I’m impressed. So what did I say exactly?

与人们谈论编程并不容易,很难吸引他们的注意力,如果您走了这么远,说实话,我印象深刻。 那我到底怎么说?

编程是日常生活 (Programming is Daily Life)

Image for post

That didn’t take much convincing as it is actually true, in my other article “What I Learnt Trying to Build Two Apps Using JavaScript”. I was able to talk about some of the approaches I use to code that is applicable to life. But more than that, concepts like object oriented programming (creating re usable objects) to functional programming (functions that use objects to achieve output) are derivatives of life’s behaviour. Cooking for example implements the use of recipes and cooking methods that to achieve outputs. And just like Programming, there is a certain flexibility, there are many ways to cook pasta as there are many ways create a function to take inputs and perform arithmetic on them.

在我的另一篇文章“我学到的尝试使用JavaScript构建两个应用程序的知识”中 ,这并没有那么令人信服,因为它确实是真实的 我能够讨论一些我用来编码的适用于生活的方法。 但不仅如此,诸如面向对象编程(创建可重用对象)到功能编程(使用对象来实现输出的功能)之类的概念是生活行为的衍生。 例如,烹饪会使用食谱和烹饪方法来实现输出。 就像编程一样,它具有一定的灵活性,因为有很多方法可以创建一个函数来接受输入并对它们执行算术运算,所以有很多方法可以烹饪意大利面。

有时,调试程序要比编写程序花费更多的时间。 (Sometimes it takes more time to debug a program than to code it.)

那么我们如何精确调试生活和代码。 (So how exactly do we Debug Life and code.)

A while ago, I was working on a project that selectively isolates job applicants on the basis of their qualifications, but in my case I could only take it one parameter. This brings me to the first thing I did:

前一段时间,我正在一个项目,该项目根据求职者的资格选择性地隔离他们,但就我而言,我只能将其作为一个参数。 这将我带到了我做的第一件事:

  1. Identify The Problem

    找出问题

You need to identify what exactly the problem is, are you unable to keep up a good habit, or is the pasta you’re cooking too salty ?

您需要确定问题出在哪里,您是否无法养成良好的习惯,或者您煮的意大利面太咸?

2. Understand The Nature Of The Problem

2. 了解问题的本质

Image for post

There are four types of problems, you have to classify your problem, the reason is, this makes it the solution come easier and with clarity.

问题有四种类型,您必须对问题进行分类,原因是,这使解决方案变得更容易且更清晰。

  • A SIMPLE PROBLEM

    一个简单的问题

It’s a problem where you fully understand it and you have something up your sleeve that can solve it, then go ahead and do that. Example:

您完全理解它是一个问题,并且袖手旁观可以解决它,然后继续进行下去。 例:

LIFE: You want the pasta to taste a certain way.

生活:您想让意大利面有某种风味。

CODE: If I wanted to click a button to display the color red.

代码 如果我想单击一个按钮以显示红色。

  • A COMPLICATED PROBLEM

    复杂的问题

This is the kind of problem where you have a known unknown. You have to take steps to acquire that unknown, provided you know what it is. It’s a problem that when solved is basically turns into a simple problem.

如果您有未知的问题,这就是这种问题。 只要您知道未知物,就必须采取措施来获取未知物。 这个问题从根本上解决就变成一个简单的问题。

LIFE: You want to season the pasta but you don’t have the salt.

生活:您想调味意大利面,但是没有盐。

CODE: I want to write Javascript but I don’t have a script tag open or I don’t have a javascript file.

代码:我想编写Javascript,但是我没有打开script标签或没有JavaScript文件。

  • COMPLEX PROBLEM

    复杂的问题

This a problem where you can only figure out afterward why what happened happened. Here you have to take some sort of action to see what happens before you act again. This is as real as debugging gets, the behavior of your project after you’ve taken certain steps.

这个问题只能在事后找出发生的原因。 在这里,您必须采取某种措施来查看会发生什么,然后再采取行动。 在采取某些步骤后,这就像调试一样真实,是项目的行为。

LIFE: So you taste the pasta, and you’ve noticed, it’s not salty enough or too salty.

生活:因此,您品尝意大利面时会发现,它的咸味不足或太咸。

CODE: I click the button but I’m getting an error message.

代码:我单击按钮,但收到错误消息。

That process of clicking and tasting, is the action that helps you understand a complex problem.

单击和品尝的过程就是帮助您理解复杂问题的动作。

Ask yourself what is the nature of your problem? This is the actual first step to debugging.

问问自己,问题的本质是什么? 这是调试的实际第一步。

Upon contact with a problem, take account of everything, from the states of the program, variables and values at the time it happens.

遇到问题时,请考虑到程序状态,变量和值在发生时的所有情况。

3. Take Actions

3.采取行动

Based on identifying the nature of the problem you can then go on with solutions.

基于确定问题的性质,您可以继续解决问题。

Examples from Number 2

2号示例

In the SIMPLE PROBLEM

简单的问题中

You want the pasta to taste a certain way - salting it would be the solution.

您想让意大利面尝起来有一定的风味- 将其盐溶即可。

If I wanted to click a button to display the color red - then I have to add a function that works on clicking that button.

如果我想单击一个按钮以显示红色- 那么我必须添加一个可以单击该按钮的功能。

In the COMPLICATED PROBLEM

复杂的问题中

You want to season the pasta but you don’t have salt — so you have to take steps to acquire salt, buying for example sounds good enough, or go to the North Atlantic and from it’s salt water, extract salt. But maybe some other time, for now you’re hungry for pasta

您想调味意大利面,但没有盐- 因此,您必须采取步骤来获取盐,例如购买听起来不错,或者去北大西洋,然后从盐水中提取盐。 但是也许其他时候,现在你饿了意大利面

I want to write Javascript but I don’t have a script tag open or I don’t have a javascript file — I create a javascript file so that I can write the code for the button, so it performs a function.

我想编写Javascript,但是没有打开script标签或没有javascript文件—我创建了一个javascript文件,以便可以为按钮编写代码,以便它执行功能。

In the COMPLEX PROBLEM

复杂的问题中

So you taste the pasta, and you’ve noticed, it’s not salty enough or too salty — and then you decide that adding water to dilute it’s salty nature or, adding more salt to increase it’s salinity is good enough

因此,您品尝了面食,并且注意到,它的咸度不够或太咸- 然后您决定添加水以稀释其咸性,或者添加更多的盐以提高其盐度就足够了

I click the button but I’m getting an error — so I have to go back and pinpoint the error in code. Maybe there’s an omitted ‘}’ on line 32 as usual. So you fix that and you have click the button again, to verify your solution.

我单击按钮,但出现错误- 所以我必须返回并查明代码中的错误。 可能照常在第32行上省略了'}'。 因此,您已修复此问题,然后再次单击该按钮,以验证您的解决方案。

4. That’s Not Alll

4. 那不是Alll

Have you ever written a sentence but by changing one word, most especially a verb, the nature of the whole sentence changes. You have too look out for that, by salting your pasta, you can make the food less peppery. Or by adding a curly brace to the end of one line you have to remove another down the line.

您是否曾经写过一个句子,但是通过更改一个词(尤其是动词),整个句子的性质就会改变。 您也太在意这一点,可以通过给面食加盐来减少食物的胡椒味。 或通过在一行的末尾添加大括号来删除另一行。

Fix the existing bug, but also check that any new bug does not occur.

修复现有的错误,但还要检查是否不会发生任何新的错误。

Some problem will take longer than others to implement this process, but it is one of the best blueprints for solving problems either in life situations or on line 32 of your Javascript file.

某些问题要比其他问题花费更长的时间来实现此过程,但这是解决生活中或Javascript文件第32行问题的最佳方案之一。

Note : Debugging isn’t always fixing a problem, you can create counter measures to prevent with problems in the future, a sort of preventive maintenance or measures to accommodate problems (a factor of safety), a sort of adaptive maintenance.

注意:调试并不能总是解决问题,您可以创建应对措施以防止将来出现问题,采取某种预防性维护措施或采取措施解决问题(一种安全因素),采取一种适应性维护措施。

So at any point in time, take a moment to debug, yourself and/or your code.

因此,在任何时间点,花点时间调试自己和/或代码。

翻译自: https://medium.com/swlh/debugging-a-daily-routine-not-only-in-code-dc8ce133ac8e

串口调试程序例程

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值