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?


当前回答

我不是我项目的首席开发人员,因此不能强加编码标准,但我发现糟糕的代码通常会迟早导致问题,当它发生时,我有一个更清晰的想法或解决方案。

通过在当时不插话,采取更自然的方法,我获得了领导更多的信任,他经常向我寻求想法,并让我参与项目的架构设计和部署策略。

其他回答

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

Privately inquire about some of the "bad" code segments with an eye toward the possibility that it is actually reasonable code, (no matter how predisposed you may be), or that there are perhaps extenuating circumstances. If you are still convinced that the code is just plain bad -- and that the source actually is this person -- just go away. One of several things may happen: 1) the person notices and takes some corrective action, 2) the person does nothing (is oblivious, or doesn't care as much as you do).

如果#2发生了,或者从你的角度来看,#1并没有带来足够的改进,并且它正在损害项目,并且/或对你造成了足够的影响,那么可能是时候在团队中开始建立/执行标准了。这需要管理层的支持,但只有从基层做起才最有效。

祝你好运。我能感受到你的痛苦,兄弟。

我真的很喜欢EnderMB的回答,但我想补充一点:

培养一种鼓励讨论代码质量的环境,而不是将其视为敏感或禁忌。例如,我曾在一个开源项目(一个Python库)中工作,团队经常讨论新代码和错误修复。不仅可以说“嘿,我认为这样做更好”,而且这实际上是被鼓励的,也是我们用于维护高质量代码的过程的一部分。

我知道不是每个环境都有利于这种过程,但它确实对我们很有效。每一次代码提交并不一定是一次委员会会议,但它应该是完全可以接受的,您可以讨论有问题的或非最优的代码并寻求改进。毕竟,更好的代码对团队中的每个人都有好处,团队合作的一个主要概念是一起工作,而不是松散的个人团体。

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

让有问题的人就他们编写的代表性模块的代码向小组的其他成员准备一份演示文稿,并让问答环节来处理(相信我,它会的,如果这是一个优秀的小组,它甚至不应该变得丑陋)。