我正在对初级(也许是高级)软件工程师所犯的常见错误和错误假设进行一些研究。

你坚持时间最长、最终被纠正的假设是什么?

例如,我误解了整数的大小不是标准的,而是取决于语言和目标。说起来有点尴尬,但事实就是这样。

坦率地说;你有什么坚定的信念?你大概坚持了多长时间?它可以是关于一种算法、一种语言、一个编程概念、测试,或者任何关于编程、编程语言或计算机科学的东西。


当前回答

其他人都在使用最新最好的技术,而我的团队是唯一一个使用劣质过时工具的人。(除了神秘的cobol恐龙)

其他回答

我认为我应该尽可能地进行抽象。我的脑袋被这个撞了,因为太多交织在一起的小功能。

现在我试着让事情尽可能的简单和分离。重构使事物抽象比预测需要如何抽象要容易得多。

因此,我从开发规则它们的框架转移到完成工作的功能片段。从来没有回头,除了当我想起那段时间,我天真地认为我会是那个开发下一个大东西的人。

:

for (int i = 0; i < myObj.variable; i = i + 1)

优化为:

int j = myObj.variable; 
for (int i = 0; i < j; i = i + 1)

哇,当我意识到它们每次都在运行时,我停止在j的地方放入函数调用!

原因:

for (int i = 0; i < myObj.variable; i = i + 1){ 
    if (function_argument == NULL){ 
        myObj.variable++; 
    } else { 
        printf("%d", myObj.variable);
    }
}

并不等同于:

int j = myObj.variable;
for (int i = 0; i < j; i = i + 1){ 
    if (function_argument == NULL){ 
        myObj.variable++; 
    } else { 
        printf("%d", myObj.variable);
    }
}

任意的例子,但是您可以看到优化将如何改变执行。

我想我需要它。

用汇编语言进行优化=重写。

When I first really understood assembly (coming from BASIC) it seemed that the only way to make code run faster was to rewrite it in assembly. Took quite a few years to realize that compilers can be very good at optimization and especially with CPUs with branch prediction etc they can probably do a better job than a human can do in a reasonable amount of time. Also that spending time on optimizing the algorithm is likely to give you a better win than spending time converting from a high to a low level language. Also that premature optimization is the root of all evil...

假设我要使程序100%完成,没有错误,并报告它为“完成”。有时,公司想要在程序存在很多漏洞时发布该程序,以抢占市场份额。