如何处理复杂的事情? [英] How to approach something complex?

查看:28
本文介绍了如何处理复杂的事情?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您知道代码中对项目至关重要但可能需要很多时间才能完成的特定部分吗?您是否有过这样的感觉:您宁愿从事其他工作(可能不太重要)或根本不编写代码而不是从事该部分工作?你努力避免并使用你知道的每一个懒惰的技巧来延迟它不可避免的实现的那个野兽?

You know that particular part of your code that is essential for the project but will probably take a lot of time to get it done? Do you ever get the feeling that you'd rather work on something else (probably less important) or not code at all instead of working on that part? That beast you try so hard to avoid and use every lazy trick you know to delay its inevitable implementation?

现在,我可能只是懒惰,但我总是不得不处理这样的代码.写一些我不想写的东西(如果你是为了好玩而不是为了得到报酬而写的话,那就更糟了!).一个大型系统,需要花费大量时间才能使其进入一个阶段,在那里您可以获得任何有用的结果或它工作的迹象.你如何开始编码这样的东西?大多数人可能会建议分而治之和类似的建筑技术,但这与你如何去做无关;这是关于你如何让自己开始做这件事.您首先要采取的步骤是什么?

Now, I'm probably just being lazy, but I've always had to deal with code like that. Write something I don't feel like writing (and it's worse if you're doing it for fun and not getting paid!). A large system that will take a lot of time to get it into a stage where you get back any useful results or indication of it working. How do you start coding something like that? Most people would probably suggest divide and conquer and similar architectural techniques, but this isn't about how you do it; it's about how you get yourself started on doing it. What's the very first steps you'd take?

推荐答案

我将讲一个发生在我身上的案例.

I'll tell a story of a case in which this happened to me.

我想为 x264 实现一种新的帧类型决策算法,该算法使用前向动态编程(Viterbi 算法).但它会变得复杂、凌乱、丑陋,等等.我真的不想这样做.我试图把这个项目抵押到 Google Summer of Code 上,但由于某种可怕的厄运,我们有一个学生只是放弃了他的项目......就是选择那个项目的学生.

I wanted to implement a new frametype decision algorithm for x264 that used forward dynamic programming (the Viterbi algorithm). But it was going to be complicated, messy, ugly, and so forth. And I really didn't want to do it. I tried to pawn off the project onto Google Summer of Code, but out of some sort of terrible bad luck, the one student that we had that simply bailed on his project... was the student that chose that project.

所以经过两个月的抱怨和躲避之后,我终于开始研究算法了.我就是这样做的.

So after two months of complaining about it and dodging it, I finally got to work on the algorithm. And here's how I did it.

首先,我与另一位开发人员进行了交谈,他显然已经对如何去做有了一些想法.我们讨论了它,他向我解释了它,直到我从算法的角度完全理解了这个过程.这是任何此类项目的第一步:充分了解其背后的算法,以便您可以对整个项目进行伪代码.

First, I talked to the other developer, who apparently already had some ideas on how to do it. We talked it over and he explained it to me until I fully understood the process from an algorithmic standpoint. This is the first step of any such project: understand the algorithm behind it so well that you can pseudocode the entire thing.

然后,我与我的另一位同事交谈.我们走到一块白板上,我把它画出来,直到也理解了它.通过向别人解释,我自己也明白了.这是第二步:向其他人解释算法,以便他们可以对它进行伪代码.这是对编程过程的模拟,因为编程是一种向计算机解释"算法的形式.

Then, I talked to another coworker of mine. We went up to a whiteboard and I sketched it out until he understood it too. By explaining it to someone else, I gained understanding myself. This is the second step: explain the algorithm to someone else so well that they can pseudocode it. This is an emulation of the programming process, since programming is a form of "explaining" an algorithm to the computer.

然后,我编写了一个简单的 Java 原型,该原型使用任意虚假值作为成本函数,并且仅用于测试 Viterbi 搜索.我完成了它,并通过详尽的搜索对其进行了检查——它完美匹配.我的动态规划是正确的.这是第三步:在尽可能简单的环境中编写尽可能简单的算法形式.

Then, I wrote a simple Java prototype that used arbitrary fake values for the cost function and was solely being used to test the Viterbi search. I finished it, and checked it against an exhaustive search--it matched perfectly. My dynamic programming was correct. This is the third step: write the simplest possible form of the algorithm in the simplest possible environment.

然后我将它移植到 C,x264 的母语.它又奏效了.这是第四步:将算法的简单形式移植到完整环境中.

Then I ported it to C, x264's native language. It worked again. This is the fourth step: port that simple form of the algorithm to the full environment.

然后,最后,我用真实的成本函数替换了虚假的成本函数.经过一些错误搜索和修复后,它起作用了.这是最后一步:将算法与环境完全集成.

Then, finally, I replaced the fake cost function with the real one. After some bughunting and fixing, it worked. This is the final step: integrate the algorithm completely with the environment.

这个过程只用了一个星期,但在项目开始时的我看来,这完全是令人生畏的,我什至无法让自己开始——然而通过把它分解成这样一个步骤步骤过程,我不仅能够完成它,但比我预期的要快得多.

This process took barely a week, but from the perspective of me at the start of the project, it was completely daunting and I couldn't get myself to even get started--yet by breaking it down into such a step by step process, I was able to not only get it done, but get it done much faster than I expected.

而且好处远不止x264;我现在非常了解维特比,我现在可以向其他人解释它……而其他人可以从中受益匪浅.例如,一位 ffmpeg 开发人员正在使用我的算法和代码的改编版来优化解决一个有些不同的问题:音频文件中的最佳标头位置.

And the benefits went far beyond x264; I now understand Viterbi so thoroughly that I now can explain it to others... and those others can benefit greatly from it. For example, one of the ffmpeg developers is using an adaptation of my algorithm and code to optimally solve a somewhat different problem: optimal header placement in audio files.

这篇关于如何处理复杂的事情?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆