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?
当前回答
人们编写糟糕的代码只是无知的一种症状(这与愚蠢不同)。这里有一些对付这种人的技巧。
Peoples own experience leaves a stronger impression than something you will say. Some people are not passionate about the code they produce and will not listen to anything you say Paired Programming can help share ideas but switch who's driving or they'll just be checking email on their phone Don't drown them with too much, I've found even Continuous Integration needed to be explained a few times to some older devs Get them excited again and they will want to learn. It could be something as simple as programming robots for a day TRUST YOUR TEAM, coding standards and tools that check them at build time are often never read or annoying. Remove Code Ownership, on some projects you will see code silos or ant hills where people say thats my code and you can't change it, this is very bad and you can use paired programming to remove this.
其他回答
这取决于程序员。有些人实际上喜欢听到“这太糟糕了”,因为他们知道代码很臭,但不知道为什么。
其他程序员需要更多的照顾。我发现告诉他们坏事是好的;“这不是写代码的好方法”,然后是一些指导“这里,看看我们是否这样做,它更可读/更少警告/诸如此类”。建设性的批评是有帮助的;如果你不能说到做到,最好不要评论,即使你知道这是不好的。
唯一一个两种方法都失败的人是一个固执的行政助理,他用VBscript写了大量的宏,一切都是逆向的。她竟然厚颜无耻地告诉我,我对计算机编程一窍不通,我可以向她学习。
进行代码审查,并从审查你的代码开始。
这将使人们在整个代码评审过程中感到轻松,因为您是通过评审自己的代码而不是他们的代码来开始这个过程的。从你的代码开始也会给他们提供如何做事的好例子。
并不是说我真的要在这个问题上增加那么多,但我必须同意,在处理这个问题时,最重要的两件事是解释你的推理,以及允许有问题的编码器解释他们的推理。坏代码不是凭空而来的(是的,“坏代码”当然是一个值得讨论的术语——我在某种程度上假设在这种情况下,您可以定义什么是好代码和坏代码)。
我发现提问式、教育性的方法对我的团队很有效。我从来不会在没有任何讨论或解释的情况下说“这样做”。
虽然你应该对这个问题有点敏感,但你不能粉饰这个问题。理想的情况是,您的团队正在考虑他们正在编写的代码,而不只是考虑代码在做什么,而是考虑它是如何编写的。
最后,我想补充一点,关于这个主题有很多值得探索的书籍——目前我最喜欢的是微软。net BCL团队的Brad Abrams和Krystof Kwalina(等人)所著的《框架设计指南》。它在讨论和解释所做的决定方面做得很出色,并展示了内部没有遵循指导方针的地方以及由此产生的后果。
在他面前重构他的代码,并显示两个版本之间的差异。他肯定会喜欢的。
以一种非对抗性的方式提出一个更好的选择。
“嘿,我觉得这个方法也可以。你们怎么看?”[用手势表示屏幕上的代码明显更好]
推荐文章
- 检查字符串是否包含字符串列表中的元素
- codestyle;把javadoc放在注释之前还是之后?
- .toArray(new MyClass[0]) or .toArray(new MyClass[myList.size()])?
- 你如何告诉别人他们写的代码不好?
- main()中的Return语句vs exit()
- 对于一个布尔字段,它的getter/setter的命名约定是什么?
- 为什么CSS选择器/ HTML属性首选破折号?
- 在c++中使用"super
- 在PHP中使用getter和setter而不是函数或简单的公共字段有什么优点?
- foo到底是什么意思?
- 什么时候使用“this”关键字?
- 对Python ' import x '和' from x import y '语句排序的正确方法是什么?
- 在Python中创建空列表
- 将c++定义放在头文件中是一个好习惯吗?
- 使用“for”循环遍历c++ Vector