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?
当前回答
在他面前重构他的代码,并显示两个版本之间的差异。他肯定会喜欢的。
其他回答
并不是说我真的要在这个问题上增加那么多,但我必须同意,在处理这个问题时,最重要的两件事是解释你的推理,以及允许有问题的编码器解释他们的推理。坏代码不是凭空而来的(是的,“坏代码”当然是一个值得讨论的术语——我在某种程度上假设在这种情况下,您可以定义什么是好代码和坏代码)。
我发现提问式、教育性的方法对我的团队很有效。我从来不会在没有任何讨论或解释的情况下说“这样做”。
虽然你应该对这个问题有点敏感,但你不能粉饰这个问题。理想的情况是,您的团队正在考虑他们正在编写的代码,而不只是考虑代码在做什么,而是考虑它是如何编写的。
最后,我想补充一点,关于这个主题有很多值得探索的书籍——目前我最喜欢的是微软。net BCL团队的Brad Abrams和Krystof Kwalina(等人)所著的《框架设计指南》。它在讨论和解释所做的决定方面做得很出色,并展示了内部没有遵循指导方针的地方以及由此产生的后果。
糟糕的命名习惯:总是不可原谅的。
是的,不要总是认为你的方式更好……这可能很困难,但必须保持客观性。
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.
这完全取决于你写作的文化。在一个自由软件项目中,你告诉他们他们写的代码不好,并给出积极的建议、改进方法和反馈。你也可以给他们的代码发送一个补丁。
一封友好的电子邮件也不会有什么坏处。
他们可能也认为你的风格很糟糕。让团队一起讨论一套一致的编码风格指南。同意某事。这是否适合你的风格并不是问题,选择任何风格只要它是一致的才是重要的。
以一种非对抗性的方式提出一个更好的选择。
“嘿,我觉得这个方法也可以。你们怎么看?”[用手势表示屏幕上的代码明显更好]
推荐文章
- 检查字符串是否包含字符串列表中的元素
- 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