I've been working with a small group of people on a coding project for fun. It's an organized and fairly cohesive group. The people I work with all have various skill sets related to programming, but some of them use older or outright wrong methods, such as excessive global variables, poor naming conventions, and other things. While things work, the implementation is poor. What's a good way to politely ask or introduce them to use better methodology, without it coming across as questioning (or insulting) their experience and/or education?


当前回答

他们可能也认为你的风格很糟糕。让团队一起讨论一套一致的编码风格指南。同意某事。这是否适合你的风格并不是问题,选择任何风格只要它是一致的才是重要的。

其他回答

提出问题,让他们意识到他们所做的是错误的。例如,问这样的问题:

你为什么决定让它成为一个全局变量? 你为什么给它起这个名字? 这很有趣。我通常这样做,因为[插入你更好的原因] 这样行吗?我通常[插入你会如何让他们看起来很傻]

我认为最理想的方法是巧妙地问他们为什么要这样编码。你可能会发现他们相信其他方法也有好处。除非我知道他们的编码风格是由于错误信息,否则我永远不会在没有充分理由的情况下判断我的方法更好。最好的办法就是问他们为什么选择那样做;一定要让自己听起来对他们的推理感兴趣,因为这才是你需要攻击的,而不是他们的能力。

编码标准肯定会有所帮助,但如果它是每个软件项目的答案,那么我们都只能在天堂的私人岛屿上啜饮鸡尾酒了。在现实中,我们都容易遇到问题,软件项目的成功率仍然很低。我认为问题主要是源于个人能力,而不是传统的问题,这就是为什么当问题浮出水面时,我建议大家一起解决问题。

最重要的是,不要马上认为你的方法更好。在现实中,可能是这样,但我们在处理另一个人的意见,对他们来说只有一个解决方案。永远不要说你的方式是更好的方式,除非你想让他们认为你是一个自鸣得意的失败者。

耐心再怎么强调都不为过。我见过这种完全事与愿违的事情,主要是因为有人希望现在就发生变化。相当多的环境需要进化的好处,而不是革命。今天强行改变,可能会给所有人带来一个非常不愉快的环境。

接受是关键。你的方法需要考虑到你所处的环境。

听起来你所处的环境有很多“个性”。所以…我不建议使用一套编码标准。你会发现你想把这个“有趣”的项目变成一个高度结构化的工作项目(哦,太好了,接下来是什么……功能文件?)相反,正如其他人所说,你必须在一定程度上处理它。

Stay patient and work toward educating others in your direction. Start with the edges (points where your code interacts with others) and when interacting with their code try to take it as an opportunity to discuss the interface they've created and ask them if it would be okay with them if it was changed (by you or them). And fully explain why you want the change ("it will help deal with changing subsystem attributes better" or whatever). Don't nit-pick and try to change everything you see as being wrong. Once you interact with others on the edge, they should start to see how it would benefit them at the core of their code (and if you get enough momentum, go deeper and truly start to discuss modern techniques and the benefits of coding standards). If they still don't see it... maybe you'll need to deal with that within yourself (especially on a "fun" project).

耐心。进化,而不是革命。

祝你好运。

糟糕的命名习惯:总是不可原谅的。

是的,不要总是认为你的方式更好……这可能很困难,但必须保持客观性。

I've had an experience with a coder that had such horrible naming of functions, the code was worse than unreadable. The functions lied about what they did, the code was nonsensical. And they were protective/resistant to having someone else change their code. when confronted very politely, they admitted it was poorly named, but wanted to retain their ownership of the code and would go back and fix it up "at a later date." This is in the past now, but how do you deal with a situation where they error is ACKNOWLEDGED, but then protected? This went on for a long time and I had no idea how to break through that barrier.

Global variables: I myself am not THAT fond of global variables, but I know a few otherwise excellent programmers that like them A LOT. So much so that I've come to believe they are not actually all that bad in many situations, as they allow for clarity, ease of debugging. (please don't flame/downvote me :) ) It comes down to, I've seen a lot of very good, effective, bug free code that used global variables (not put in by me!) and great deal of buggy, impossible to read/maintain/fix code that meticulously used proper patterns. Maybe there IS a place (though shrinking perhaps) for global variables? I'm considering rethinking my position based on evidence.

我和和我一起工作的人有类似的情况。他们不像我那样接触编码,但他们在编码方面仍然很有用。

而不是我让他们做他们想做的然后回去编辑整篇文章。我通常只是让他们坐下来,告诉他们两种做事的方法。他们的方式和我的方式,从这里我们讨论了每种方法的优缺点,因此对我们应该如何进行编程有了更好的理解和更好的结论。

这是真正令人惊讶的部分。有时他们会提出一些连我都不知道答案的问题,经过研究,我们都对方法论和结构有了更好的概念。

讨论。 告诉他们为什么 甚至不要认为你总是对的。有时甚至他们也会教你一些新东西。

如果我是你,我也会这么做

这取决于程序员。有些人实际上喜欢听到“这太糟糕了”,因为他们知道代码很臭,但不知道为什么。

其他程序员需要更多的照顾。我发现告诉他们坏事是好的;“这不是写代码的好方法”,然后是一些指导“这里,看看我们是否这样做,它更可读/更少警告/诸如此类”。建设性的批评是有帮助的;如果你不能说到做到,最好不要评论,即使你知道这是不好的。

唯一一个两种方法都失败的人是一个固执的行政助理,他用VBscript写了大量的宏,一切都是逆向的。她竟然厚颜无耻地告诉我,我对计算机编程一窍不通,我可以向她学习。