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?


当前回答

与其让他们写代码,不如让他们维护代码。

除非他们不得不维护他们那堆冒着热气的意大利面,否则他们永远不会明白自己在编码方面有多糟糕。

其他回答

进行代码审查,并从审查你的代码开始。

这将使人们在整个代码评审过程中感到轻松,因为您是通过评审自己的代码而不是他们的代码来开始这个过程的。从你的代码开始也会给他们提供如何做事的好例子。

可能在效果后有点晚了,但这就是一致认可的编码标准是件好事的地方。

介绍代码标准的思想。关于代码标准最重要的事情是它提出了代码库的一致性(理想情况下,所有的代码都应该看起来像由一个人一次编写的),这将导致更容易理解和可维护的代码。

如果可能的话,确保他们明白你是在批评他们的代码,而不是针对他们个人。

如果你有一个松散的编码标准,能够指出这一点,或者表明你不能遵循代码,因为它不是正确的格式可能是值得的。

如果您没有编码格式,现在将是一个好时机。类似于这个问题的答案可能会有帮助:https://stackoverflow.com/questions/4121/team-coding-styles