You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Understanding problem decomposition and why we need to do it
Using top-down design to carry out problem decomposition and write programs
Writing an authorship identification program using top-down design
理解问题的分解及其重要性
运用自顶向下的设计方法来分解问题并编写程序
使用自顶向下的设计编写一个作者识别程序
In Chapter 3, we talked about why we shouldn’t ask Copilot to solve big problems. Imagine what could happen if we asked Copilot, “Write a program to determine the author of a book.”
In the best case, we’d get a canned program with all of the decisions made for us. That program may not match what we wanted. Part of the power of being a programmer is customizing what we’re creating. To do this, we need to feed small sub-problems to Copilot and assemble those solutions into a program of our own. Even if we didn’t want to customize anything, what would we do if the program from Copilot had flaws? It would be difficult for us to fix a large program that we don’t understand.
In the worst case, Copilot wouldn’t do anything useful. We observe this sometimes when Copilot gives us comments again and again but never provides us with real code.
In this chapter, we will learn how to break large problems into smaller ones. We can then use Copilot to solve each of the small sub-problems, thereby solving the large problem that we ultimately care about solving.
7 Problem Decomposition
第七章 分解问题
This chapter covers
本章内容概要
In Chapter 3, we talked about why we shouldn’t ask Copilot to solve big problems. Imagine what could happen if we asked Copilot, “Write a program to determine the author of a book.”
在第三章,我们探讨了为什么不应该要求 Copilot 去解决大型问题。试想一下,如果我们对 Copilot 说 “编写一个判定书籍作者的程序”,会发生什么情况?
In the best case, we’d get a canned program with all of the decisions made for us. That program may not match what we wanted. Part of the power of being a programmer is customizing what we’re creating. To do this, we need to feed small sub-problems to Copilot and assemble those solutions into a program of our own. Even if we didn’t want to customize anything, what would we do if the program from Copilot had flaws? It would be difficult for us to fix a large program that we don’t understand.
在最理想的情况下,我们将获得一个全套的程序,其中所有决策都已经代我们做出。但这个程序可能并不完全满足我们的要求。程序员这个角色的魅力在于能够定制我们所创造的东西。为了实现这一点,我们需要向 Copilot 提出具体的子问题,并将这些解决方案组合成我们自己的程序。或许我们不想定制任何内容,但如果 Copilot 编写的程序存在瑕疵怎么办?修复一个我们不了解的大型程序会非常困难。
In the worst case, Copilot wouldn’t do anything useful. We observe this sometimes when Copilot gives us comments again and again but never provides us with real code.
在最糟糕的情况下,Copilot 给不出任何有用的东西。我们有时候会发现这种情况,比如 Copilot 只是反复输出注释,而不是提供实质性的代码。
In this chapter, we will learn how to break large problems into smaller ones. We can then use Copilot to solve each of the small sub-problems, thereby solving the large problem that we ultimately care about solving.
在本章中,我们将学习如何将大问题分解成小问题。然后我们可以使用 Copilot 来解决每个小的子问题,从而解决我们最终关心的大问题。
本章目录
The text was updated successfully, but these errors were encountered: