chore: add 3.4.6.2
chore: add 3.4.6.3
chore: add 3.4.6.4
chore: add 3.4.6.5
chore: add 3.4.6.6
chore: add 3.4.6.7
chore: add 3.4.6.8
chore: add 3.4.6.9
chore: add 3.4.6.10
docs: add 3.6.5.1
This commit is contained in:
FallenYing
2023-07-27 23:15:47 +08:00
parent b9449a0d88
commit b043fd1d05
14 changed files with 535 additions and 89 deletions

View File

@@ -1,10 +1,10 @@
# 3.指明地点
某种极其糟糕的编程习惯
## Copy-paste
::: warning <font size=5>某种极其糟糕的编程习惯</font>
<font size=5><strong>Copy-paste</strong></font>
我们很多同学在编程的过程中,可能会写出一大堆重复性很强的代码,在最近看的 pa 中,举了这样一个例子,你不需要看懂只需要感受到就可:
:::
```c
if (strcmp(s, "$0") == 0)
@@ -86,7 +86,7 @@ bx = torch.cat((xs[0], bs[0], xs[1], bs[1], xs[2], bs[2], xs[3], bs[3], xs[4], b
xs[24], bs[24], xs[25], bs[25], xs[26], bs[26], xs[27], bs[27], xs[28], bs[28], xs[29], bs[29], xs[30], bs[30], xs[31], bs[31]), 1)
```
你想想,你遇到这么长的代码,你愿意看他吗?
::: tip <font size=5>你想想,你遇到这么长的代码,你愿意看他吗?</font>
更可怕的是,这种编码模式可能会导致意想不到的 bug。
@@ -97,6 +97,7 @@ bx = torch.cat((xs[0], bs[0], xs[1], bs[1], xs[2], bs[2], xs[3], bs[3], xs[4], b
后来周源源教授发现,相比于操作系统,应用程序的源代码中 Copy-Paste 的现象更加普遍。于是她们团队把 CP-Miner 的技术应用到应用程序的源代码中,并创办了 PatternInsight 公司。很多 IT 公司纷纷购买 PatternInsight 的产品,并要求提供相应的定制服务,甚至 PatternInsight 公司最后还被 VMWare 收购了。
这个故事折射出,大公司中程序员的编程习惯也许不比你好多少,他们也会写出 Copy-Paste 这种难以维护的代码。但反过来说,重视编码风格这些企业看中的能力,你从现在就可以开始培养。
:::
<em>传统上,文本冒险是由(许多)不同位置组成的虚拟世界。虽然这不是必需的(一些冒险发生在一个房间里!),但这是解释</em><em>数据结构</em><em>使用的好方法。</em>
@@ -112,7 +113,7 @@ struct location {
};
```
::: warning 🤔思考题:
::: warning 🤔 思考题:
我们为什么要用结构体来保存位置?
这样子做有什么好处?