如何才能更好地实现如何解决特定问题?

时间:2022-09-14 02:11:43

I have become pretty fluent in a few different languages now, but I seem to have a hard time actually figuring out the best way to go about solving particular problems. What are some ways to go about getting better at the actual problem solving of programming.

我现在已经熟练掌握了几种不同的语言,但我似乎很难找到解决特定问题的最佳方法。有什么方法可以更好地解决编程的实际问题。

17 个解决方案

#1


Experience. Solving something completely new is hard. The best way to solve problems is to try and find a problem that you've solved before, and that is similar, and adapt you solution to the new problem. So until you have experience with many different kinds of problems, it's hard to solve new problems that you come across. Visiting sites like this and reading questions and theirs answers are a great way of learning how others solved problems that they encountered.

经验。解决一些全新的事情很难。解决问题的最佳方法是尝试找到之前已经解决的问题,这是类似的问题,并使您的解决方案适应新问题。因此,在您遇到许多不同类型的问题之前,很难解决您遇到的新问题。像这样访问这些网站并阅读问题和他们的答案是了解其他人如何解决他们遇到的问题的好方法。

#2


Basically, "just do it". When you have to make a choice, just make any choice (except flipping a coin).

基本上,“就是这样做”。当你必须做出选择时,只需做出任何选择(除了翻转硬币)。

Once you have something that works, then sit back and scratch your head about what you did wrong and how to do it better.

一旦你有了可行的东西,那就坐下来,抓住你做错了什么以及如何做得更好。

If you have absolutely no clue how to do even that, just solve a part of the problem completely and move on.

如果你完全不知道怎么做,那就完全解决问题的一部分并继续前进。

I suggest checking out this book. They aren't the best kid on the block, though they want us to think they are...but they did well with Basecamp.

我建议看一下这本书。虽然他们希望我们认为他们是......但他们在Basecamp上做得很好,他们并不是最好的孩子。

#3


When all you have is a hammer, everything begins to look like a nail.

当你拥有的只是一把锤子时,一切都开始像钉子一样。

So, make sure you're well versed in algorithms and data structures. When you study them, think hard about what sort of uses a particular algorithm is good for.

因此,请确保您精通算法和数据结构。当你研究它们时,要认真考虑特定算法有哪些用途。

#4


  • Ask someone else. Someone in your office, on Twitter or SO, or even your wife. People with no technical knowledge often come up with simpler solutions.
  • 问别人。你办公室里,Twitter或SO上的人,甚至是你的妻子。没有技术知识的人通常会提出更简单的解决方案。

If you must solve it on your own, try one of these others:

如果您必须自己解决,请尝试以下其中一个:

  • Do a quick search for another person or project which has tried to solve your problem. If they have a blog, documentation or source code, you might be able to learn from their implementation.

    快速搜索试图解决问题的其他人或项目。如果他们有博客,文档或源代码,您可以从他们的实现中学习。

  • Come up with at least TWO solutions and pick the best one.

    提出至少两个解决方案并选择最好的解决方案。

  • Pretend you have 15 minutes to solve the problem before the civilized world is destroyed by Nuclear War / Skynet / Permanent endless re-runs of Seinfeld, you might think of something much simpler which gets 99% of the work done.

    在文明世界被核战争/天网摧毁之前假装你有15分钟的时间来解决这个问题/永久无休止地重新运行Seinfeld,你可能会想到一些更简单的东西,它完成了99%的工作。

#5


如何才能更好地实现如何解决特定问题?

The book is a set of heuristics to go through when solving a problem. Read about it on Wikipedia. Buy it on Amazon.

这本书是解决问题时要经历的一套启发式方法。在*上阅读它。在亚马逊上购买。

#6


By solving actual problems. Practice makes perfect.

通过解决实际问题。实践是完美的。

If you have time to become fluent in multiple languages, my guess is that you haven't spent much time doing any actual work. If you have a job, it might be time for a new one. If you're still in school, do you have any interest in starting a project for yourself or contributing to one that you use regularly?

如果你有时间精通多种语言,我的猜测是你没有花太多时间做任何实际的工作。如果你有工作,可能是时候换新工作了。如果你还在学校,你是否有兴趣为自己开办一个项目或者为你经常使用的项目做贡献?

It might help to know what kinds of problems you're having difficulty solving.

了解您难以解决的问题可能会有所帮助。

#7


Go find an open source or free project you can get excited about and contribute. I learned a lot by signing up to code for my favorite video game modification.

去找一个你可以兴奋和贡献的开源或免费项目。通过注册我最喜欢的视频游戏修改代码,我学到了很多东西。

#8


Experience.

Study really only goes so far. Find something fun and small. Do it.

研究真的只是到目前为止。找一些有趣又小的东西。做吧

#9


One way that seems to work for a lot of people is to pick use a book like Programming Challenges as a guide, and focus on solving problems of a particular type. For example if you're weak in an area like graph problems or dynamic programming, find a set of problems on an online judge and work through them. You'll start to recognize patterns and be able to classify problems.

对许多人来说似乎有用的一种方法是选择使用像“编程挑战”这样的书作为指南,并专注于解决特定类型的问题。例如,如果您在图形问题或动态编程等领域处于弱势,那么在在线评判中找到一系列问题并通过它们进行处理。您将开始识别模式并能够对问题进行分类。

#10


  • Google for an answer. Chances are someone else has solved the same problem or a similar problem before.
  • 谷歌的答案。可能是其他人之前已经解决了同样的问题或类似的问题。

  • Ask on SO. :)
  • 请问SO。 :)

  • Read some textbooks or online articles about design patterns.
  • 阅读一些有关设计模式的教科书或在线文章。

  • Problems may have many solutions, some simpler and some more complicated. Don't get stuck thinking there is only one solution. Just go with the simplest solution that makes the most sense in the context of your application.
  • 问题可能有很多解决方案,有些更简单,有些更复杂。不要以为只有一种解决方案。只需使用在您的应用程序环境中最有意义的最简单的解决方案。

  • After years of experience you'll be able to think of your own solutions to most problems. :)
  • 经过多年的经验,您将能够为大多数问题考虑自己的解决方案。 :)

#11


Study Algorithms!

Search and get a hold on as many examples, books on the subject programming or otherwise, etc.

搜索并掌握尽可能多的示例,关于主题编程或其他方面的书籍等。

Problem solving skills can also be improved by playing tactical games.

通过玩战术游戏也可以提高解决问题的能力。

These made me Enjoy problem solving and become better (not necessarily good) at problem solving:

这些让我很难解决问题,并在解决问题方面变得更好(不一定更好):

Chess and igo

国际象棋和igo

#12


I like this general method:

我喜欢这种通用方法:

  1. List the possible solutions with their strengths and weaknesses
    (This will push you to briefly taste all of them)
  2. 列出可能的解决方案及其优点和缺点(这将促使您简要介绍所有这些解决方案)

  3. Chose the best one and make your design on it
    (If you find any heavy obstacle, reconsider other options)
  4. 选择最好的一个并在其上进行设计(如果发现任何重大障碍,请重新考虑其他选项)

  5. Implement

most importantly, on every step, learn

最重要的是,在每一步,学习

#13


The best way is probably to learn form a master if that's an option. Especially if you can find someone familiar with the problems your addressing.

如果这是一个选项,最好的方法可能是学习形式大师。特别是如果你能找到熟悉你的问题的人。

Generally the more tools we have at hand the more options we have for tackling a problem. I agree that's important to always code and to always deliver something that works (however inelegant it is). But I think we need to increase our skills/knowledge in many directions:

通常,我们掌握的工具越多,我们处理问题的选择就越多。我同意始终编码并始终提供有效的东西(无论多么优雅)都很重要。但我认为我们需要在很多方面提高我们的技能/知识:

  • Language skills (know your language(s) in depth)
  • 语言技能(深入了解您的语言)

  • Programming paradigms (Imperative, Object, Functional)
  • 编程范式(命令,对象,功能)

  • Framework knowledge
  • Algorithms
  • Patterns
  • Date-Structures
  • Methodologies (Agile, DDD, BDD, ?DD)
  • 方法论(敏捷,DDD,BDD,?DD)

  • Tools
  • etc

You can get a lot of skill through on the job just-in-time-learning, but I usually have a pet subject at any time that I'm trying to get a deeper understanding of, typically this means getting the book and reading it cover to cover.

你可以通过即时学习获得很多技能,但我通常在任何时候都有一个宠物主题,我正在努力深入了解,通常这意味着获得这本书并阅读它盖住。

#14


Work your way through Project Euler, and look at other people's solutions to the problems. Almost every problem will have been solved in a way that wouldn't have occurred to you, and usually with greater efficiency.

通过Project Euler工作,并查看其他人对问题的解决方案。几乎每个问题都会以一种你不会想到的方式解决,通常效率更高。

#15


I think that there is a lot more than raw experience involved in becoming a good problem solver - because I've seen poor problem solvers with lots of experience.

我认为成为一名优秀的问题解决者还有很多原始经验 - 因为我见过很多经验丰富的问题​​解决者。

Here are a few tips but you can find many more around the web.

以下是一些提示,但您可以在网络上找到更多提示。

  • Look at a number of problems and figure out what they have in common. The greater the generality with which you understand the solution to a problem, the more you can apply it to other problems.
  • 看看一些问题并弄清楚它们的共同点。您理解问题解决方案的一般性越高,您就越能将其应用于其他问题。

  • Try to discover approaches which good problem solvers use to solve problem. But don't assume anyone has monopoly on problem solving
  • 尝试发现好的问题解决者用来解决问题的方法。但不要以为任何人都有解决问题的垄断权

  • If you read Richard Feynman's books, you'll notice that he considers many different routes to get to his goal. Don't narrow your approach prematurely
  • 如果你阅读理查德费曼的书,你会发现他考虑了许多不同的路线来实现他的目标。不要过早缩小你的方法

  • Be positive. Assume that you can find the solution to anything. Your state of mind matters. Enjoying the process of problem solving makes it much easier
  • 要乐观。假设您可以找到任何解决方案。你的心态很重要。享受解决问题的过程使其变得更加容易

  • Don't beat your head against the wall. If you don't seem to be making progress with one approach, try another approach
  • 不要把头撞到墙上。如果您似乎没有采用一种方法取得进展,请尝试另一种方法

  • Always be looking for more ways of solving problems and more insights into the process of problem solving itself
  • 始终在寻找解决问题的更多方法,以及对问题解决过程本身的更多见解

  • Be willing to work. It still can take a lot of effort solve some problems
  • 愿意工作。解决一些问题仍然需要付出很多努力

  • The more different fields of study you know, the more viewpoints you have. I have a strong math background and I find it very useful for many problems. Physics, music or any different viewpoint might be useful
  • 您知道的学习领域越多,您拥有的观点就越多。我有很强的数学背景,我发现它对许多问题非常有用。物理,音乐或任何不同的观点都可能有用

#16


  1. Practice solving problems.

    练习解决问题。

  2. Take an algorithms or discrete math course.

    参加算法或离散数学课程。

#17


Here some tools that I've used in the past to help me understand a particular problem and its solution. I don't always use them today, but they helped me to learn how to think about breaking down a problem and coming up with a solution.

这里有一些我过去用来帮助我理解特定问题及其解决方案的工具。我今天并不总是使用它们,但它们帮助我学习如何思考解决问题并提出解决方案。

  1. Class-Responsibility-Collaboration (CRC) cards One card per class, details the responsibility of the class and what other classes it collaborates with. Using cards you can layout your design for the solution and see where you have too much coupling or too much responsibility. They allow you to think about the design in a lightweight manner before committing to code.

    Class-Responsibility-Collaboration(CRC)卡每班一张卡,详细说明了班级的责任以及与之合作的其他课程。使用卡片,您可以为解决方案布置设计,并查看您有太多耦合或太多责任。它们允许您在提交代码之前以轻量级方式考虑设计。

  2. Use cases Either actual structured use cases that describe user interaction with the system or even briefer stories or story cards. I still use stories, though I capture them in a wiki instead. This allows you to capture the interaction with the system in an informal way. Stories are basically placeholders for conversations that you need to have with the customer about what is supposed to be done. Using the collected stories, you start getting a grasp on the overall intention of the code. You can also start seeing how things interact and what works with other things. This is really the beginning of design.

    用例描述用户与系统交互的实际结构化用例,甚至是简短的故事或故事卡。我仍然使用故事,但我在维基中捕获它们。这允许您以非正式方式捕获与系统的交互。故事基本上是您需要与客户讨论应该完成的对话的占位符。使用收集的故事,您开始掌握代码的整体意图。您还可以开始了解事物的相互作用以及与其他事物相关的事物。这真的是设计的开始。

  3. UML Diagrams - particularly interaction diagrams For awhile I used these a lot. It really helped to see how things actually worked together under the hood. I will still diagram, informally, some complex interactions to make sure I don't miss anything important. Going through a lot of these really helped me to think about how my objects interacted and now it is sort of second nature to think in terms of interactions.

    UML图 - 特别是交互图一段时间以来,我经常使用这些图。这真的有助于了解事情如何在引擎盖下实际协同工作。我仍将非正式地绘制一些复杂的交互图,以确保我不会错过任何重要的内容。经历了很多这些确实帮助我思考我的对象如何交互,现在它是在交互方面思考的第二天性。

  4. Class diagrams -- a really high level view of the code. These allow you to see your code structurally, especially if you can break the diagram down into components or layers of architecture. Mostly I use these now to explain the code to other people when necessary. When starting out these provide a pretty good visualization, though, if you're struggling with the bird's-eye view of the code.

    类图 - 代码的高级视图。这些允许您在结构上查看代码,特别是如果您可以将图表分解为组件或体系结构层。大多数情况下,我现在使用这些来在必要时向其他人解释代码。然而,当开始时,这些提供了非常好的可视化,如果你正在努力寻找代码的鸟瞰图。

The best advice I can give you if you try these is to follow the "rules" until you really have a good grasp of what is going on. Once you feel like you have a better understanding of what they provide, you can use them or not, or modify how you use them to keep only what is helpful and let the other stuff go.

如果你尝试这些,我可以给你的最好的建议是遵循“规则”,直到你真正掌握了正在发生的事情。一旦你觉得你对他们提供的内容有了更好的理解,你可以使用或不使用它们,或者修改你如何使用它们来保留唯一有用的内容并让其他内容消失。

#1


Experience. Solving something completely new is hard. The best way to solve problems is to try and find a problem that you've solved before, and that is similar, and adapt you solution to the new problem. So until you have experience with many different kinds of problems, it's hard to solve new problems that you come across. Visiting sites like this and reading questions and theirs answers are a great way of learning how others solved problems that they encountered.

经验。解决一些全新的事情很难。解决问题的最佳方法是尝试找到之前已经解决的问题,这是类似的问题,并使您的解决方案适应新问题。因此,在您遇到许多不同类型的问题之前,很难解决您遇到的新问题。像这样访问这些网站并阅读问题和他们的答案是了解其他人如何解决他们遇到的问题的好方法。

#2


Basically, "just do it". When you have to make a choice, just make any choice (except flipping a coin).

基本上,“就是这样做”。当你必须做出选择时,只需做出任何选择(除了翻转硬币)。

Once you have something that works, then sit back and scratch your head about what you did wrong and how to do it better.

一旦你有了可行的东西,那就坐下来,抓住你做错了什么以及如何做得更好。

If you have absolutely no clue how to do even that, just solve a part of the problem completely and move on.

如果你完全不知道怎么做,那就完全解决问题的一部分并继续前进。

I suggest checking out this book. They aren't the best kid on the block, though they want us to think they are...but they did well with Basecamp.

我建议看一下这本书。虽然他们希望我们认为他们是......但他们在Basecamp上做得很好,他们并不是最好的孩子。

#3


When all you have is a hammer, everything begins to look like a nail.

当你拥有的只是一把锤子时,一切都开始像钉子一样。

So, make sure you're well versed in algorithms and data structures. When you study them, think hard about what sort of uses a particular algorithm is good for.

因此,请确保您精通算法和数据结构。当你研究它们时,要认真考虑特定算法有哪些用途。

#4


  • Ask someone else. Someone in your office, on Twitter or SO, or even your wife. People with no technical knowledge often come up with simpler solutions.
  • 问别人。你办公室里,Twitter或SO上的人,甚至是你的妻子。没有技术知识的人通常会提出更简单的解决方案。

If you must solve it on your own, try one of these others:

如果您必须自己解决,请尝试以下其中一个:

  • Do a quick search for another person or project which has tried to solve your problem. If they have a blog, documentation or source code, you might be able to learn from their implementation.

    快速搜索试图解决问题的其他人或项目。如果他们有博客,文档或源代码,您可以从他们的实现中学习。

  • Come up with at least TWO solutions and pick the best one.

    提出至少两个解决方案并选择最好的解决方案。

  • Pretend you have 15 minutes to solve the problem before the civilized world is destroyed by Nuclear War / Skynet / Permanent endless re-runs of Seinfeld, you might think of something much simpler which gets 99% of the work done.

    在文明世界被核战争/天网摧毁之前假装你有15分钟的时间来解决这个问题/永久无休止地重新运行Seinfeld,你可能会想到一些更简单的东西,它完成了99%的工作。

#5


如何才能更好地实现如何解决特定问题?

The book is a set of heuristics to go through when solving a problem. Read about it on Wikipedia. Buy it on Amazon.

这本书是解决问题时要经历的一套启发式方法。在*上阅读它。在亚马逊上购买。

#6


By solving actual problems. Practice makes perfect.

通过解决实际问题。实践是完美的。

If you have time to become fluent in multiple languages, my guess is that you haven't spent much time doing any actual work. If you have a job, it might be time for a new one. If you're still in school, do you have any interest in starting a project for yourself or contributing to one that you use regularly?

如果你有时间精通多种语言,我的猜测是你没有花太多时间做任何实际的工作。如果你有工作,可能是时候换新工作了。如果你还在学校,你是否有兴趣为自己开办一个项目或者为你经常使用的项目做贡献?

It might help to know what kinds of problems you're having difficulty solving.

了解您难以解决的问题可能会有所帮助。

#7


Go find an open source or free project you can get excited about and contribute. I learned a lot by signing up to code for my favorite video game modification.

去找一个你可以兴奋和贡献的开源或免费项目。通过注册我最喜欢的视频游戏修改代码,我学到了很多东西。

#8


Experience.

Study really only goes so far. Find something fun and small. Do it.

研究真的只是到目前为止。找一些有趣又小的东西。做吧

#9


One way that seems to work for a lot of people is to pick use a book like Programming Challenges as a guide, and focus on solving problems of a particular type. For example if you're weak in an area like graph problems or dynamic programming, find a set of problems on an online judge and work through them. You'll start to recognize patterns and be able to classify problems.

对许多人来说似乎有用的一种方法是选择使用像“编程挑战”这样的书作为指南,并专注于解决特定类型的问题。例如,如果您在图形问题或动态编程等领域处于弱势,那么在在线评判中找到一系列问题并通过它们进行处理。您将开始识别模式并能够对问题进行分类。

#10


  • Google for an answer. Chances are someone else has solved the same problem or a similar problem before.
  • 谷歌的答案。可能是其他人之前已经解决了同样的问题或类似的问题。

  • Ask on SO. :)
  • 请问SO。 :)

  • Read some textbooks or online articles about design patterns.
  • 阅读一些有关设计模式的教科书或在线文章。

  • Problems may have many solutions, some simpler and some more complicated. Don't get stuck thinking there is only one solution. Just go with the simplest solution that makes the most sense in the context of your application.
  • 问题可能有很多解决方案,有些更简单,有些更复杂。不要以为只有一种解决方案。只需使用在您的应用程序环境中最有意义的最简单的解决方案。

  • After years of experience you'll be able to think of your own solutions to most problems. :)
  • 经过多年的经验,您将能够为大多数问题考虑自己的解决方案。 :)

#11


Study Algorithms!

Search and get a hold on as many examples, books on the subject programming or otherwise, etc.

搜索并掌握尽可能多的示例,关于主题编程或其他方面的书籍等。

Problem solving skills can also be improved by playing tactical games.

通过玩战术游戏也可以提高解决问题的能力。

These made me Enjoy problem solving and become better (not necessarily good) at problem solving:

这些让我很难解决问题,并在解决问题方面变得更好(不一定更好):

Chess and igo

国际象棋和igo

#12


I like this general method:

我喜欢这种通用方法:

  1. List the possible solutions with their strengths and weaknesses
    (This will push you to briefly taste all of them)
  2. 列出可能的解决方案及其优点和缺点(这将促使您简要介绍所有这些解决方案)

  3. Chose the best one and make your design on it
    (If you find any heavy obstacle, reconsider other options)
  4. 选择最好的一个并在其上进行设计(如果发现任何重大障碍,请重新考虑其他选项)

  5. Implement

most importantly, on every step, learn

最重要的是,在每一步,学习

#13


The best way is probably to learn form a master if that's an option. Especially if you can find someone familiar with the problems your addressing.

如果这是一个选项,最好的方法可能是学习形式大师。特别是如果你能找到熟悉你的问题的人。

Generally the more tools we have at hand the more options we have for tackling a problem. I agree that's important to always code and to always deliver something that works (however inelegant it is). But I think we need to increase our skills/knowledge in many directions:

通常,我们掌握的工具越多,我们处理问题的选择就越多。我同意始终编码并始终提供有效的东西(无论多么优雅)都很重要。但我认为我们需要在很多方面提高我们的技能/知识:

  • Language skills (know your language(s) in depth)
  • 语言技能(深入了解您的语言)

  • Programming paradigms (Imperative, Object, Functional)
  • 编程范式(命令,对象,功能)

  • Framework knowledge
  • Algorithms
  • Patterns
  • Date-Structures
  • Methodologies (Agile, DDD, BDD, ?DD)
  • 方法论(敏捷,DDD,BDD,?DD)

  • Tools
  • etc

You can get a lot of skill through on the job just-in-time-learning, but I usually have a pet subject at any time that I'm trying to get a deeper understanding of, typically this means getting the book and reading it cover to cover.

你可以通过即时学习获得很多技能,但我通常在任何时候都有一个宠物主题,我正在努力深入了解,通常这意味着获得这本书并阅读它盖住。

#14


Work your way through Project Euler, and look at other people's solutions to the problems. Almost every problem will have been solved in a way that wouldn't have occurred to you, and usually with greater efficiency.

通过Project Euler工作,并查看其他人对问题的解决方案。几乎每个问题都会以一种你不会想到的方式解决,通常效率更高。

#15


I think that there is a lot more than raw experience involved in becoming a good problem solver - because I've seen poor problem solvers with lots of experience.

我认为成为一名优秀的问题解决者还有很多原始经验 - 因为我见过很多经验丰富的问题​​解决者。

Here are a few tips but you can find many more around the web.

以下是一些提示,但您可以在网络上找到更多提示。

  • Look at a number of problems and figure out what they have in common. The greater the generality with which you understand the solution to a problem, the more you can apply it to other problems.
  • 看看一些问题并弄清楚它们的共同点。您理解问题解决方案的一般性越高,您就越能将其应用于其他问题。

  • Try to discover approaches which good problem solvers use to solve problem. But don't assume anyone has monopoly on problem solving
  • 尝试发现好的问题解决者用来解决问题的方法。但不要以为任何人都有解决问题的垄断权

  • If you read Richard Feynman's books, you'll notice that he considers many different routes to get to his goal. Don't narrow your approach prematurely
  • 如果你阅读理查德费曼的书,你会发现他考虑了许多不同的路线来实现他的目标。不要过早缩小你的方法

  • Be positive. Assume that you can find the solution to anything. Your state of mind matters. Enjoying the process of problem solving makes it much easier
  • 要乐观。假设您可以找到任何解决方案。你的心态很重要。享受解决问题的过程使其变得更加容易

  • Don't beat your head against the wall. If you don't seem to be making progress with one approach, try another approach
  • 不要把头撞到墙上。如果您似乎没有采用一种方法取得进展,请尝试另一种方法

  • Always be looking for more ways of solving problems and more insights into the process of problem solving itself
  • 始终在寻找解决问题的更多方法,以及对问题解决过程本身的更多见解

  • Be willing to work. It still can take a lot of effort solve some problems
  • 愿意工作。解决一些问题仍然需要付出很多努力

  • The more different fields of study you know, the more viewpoints you have. I have a strong math background and I find it very useful for many problems. Physics, music or any different viewpoint might be useful
  • 您知道的学习领域越多,您拥有的观点就越多。我有很强的数学背景,我发现它对许多问题非常有用。物理,音乐或任何不同的观点都可能有用

#16


  1. Practice solving problems.

    练习解决问题。

  2. Take an algorithms or discrete math course.

    参加算法或离散数学课程。

#17


Here some tools that I've used in the past to help me understand a particular problem and its solution. I don't always use them today, but they helped me to learn how to think about breaking down a problem and coming up with a solution.

这里有一些我过去用来帮助我理解特定问题及其解决方案的工具。我今天并不总是使用它们,但它们帮助我学习如何思考解决问题并提出解决方案。

  1. Class-Responsibility-Collaboration (CRC) cards One card per class, details the responsibility of the class and what other classes it collaborates with. Using cards you can layout your design for the solution and see where you have too much coupling or too much responsibility. They allow you to think about the design in a lightweight manner before committing to code.

    Class-Responsibility-Collaboration(CRC)卡每班一张卡,详细说明了班级的责任以及与之合作的其他课程。使用卡片,您可以为解决方案布置设计,并查看您有太多耦合或太多责任。它们允许您在提交代码之前以轻量级方式考虑设计。

  2. Use cases Either actual structured use cases that describe user interaction with the system or even briefer stories or story cards. I still use stories, though I capture them in a wiki instead. This allows you to capture the interaction with the system in an informal way. Stories are basically placeholders for conversations that you need to have with the customer about what is supposed to be done. Using the collected stories, you start getting a grasp on the overall intention of the code. You can also start seeing how things interact and what works with other things. This is really the beginning of design.

    用例描述用户与系统交互的实际结构化用例,甚至是简短的故事或故事卡。我仍然使用故事,但我在维基中捕获它们。这允许您以非正式方式捕获与系统的交互。故事基本上是您需要与客户讨论应该完成的对话的占位符。使用收集的故事,您开始掌握代码的整体意图。您还可以开始了解事物的相互作用以及与其他事物相关的事物。这真的是设计的开始。

  3. UML Diagrams - particularly interaction diagrams For awhile I used these a lot. It really helped to see how things actually worked together under the hood. I will still diagram, informally, some complex interactions to make sure I don't miss anything important. Going through a lot of these really helped me to think about how my objects interacted and now it is sort of second nature to think in terms of interactions.

    UML图 - 特别是交互图一段时间以来,我经常使用这些图。这真的有助于了解事情如何在引擎盖下实际协同工作。我仍将非正式地绘制一些复杂的交互图,以确保我不会错过任何重要的内容。经历了很多这些确实帮助我思考我的对象如何交互,现在它是在交互方面思考的第二天性。

  4. Class diagrams -- a really high level view of the code. These allow you to see your code structurally, especially if you can break the diagram down into components or layers of architecture. Mostly I use these now to explain the code to other people when necessary. When starting out these provide a pretty good visualization, though, if you're struggling with the bird's-eye view of the code.

    类图 - 代码的高级视图。这些允许您在结构上查看代码,特别是如果您可以将图表分解为组件或体系结构层。大多数情况下,我现在使用这些来在必要时向其他人解释代码。然而,当开始时,这些提供了非常好的可视化,如果你正在努力寻找代码的鸟瞰图。

The best advice I can give you if you try these is to follow the "rules" until you really have a good grasp of what is going on. Once you feel like you have a better understanding of what they provide, you can use them or not, or modify how you use them to keep only what is helpful and let the other stuff go.

如果你尝试这些,我可以给你的最好的建议是遵循“规则”,直到你真正掌握了正在发生的事情。一旦你觉得你对他们提供的内容有了更好的理解,你可以使用或不使用它们,或者修改你如何使用它们来保留唯一有用的内容并让其他内容消失。