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商店,建议坚持微软的c#风格和注释指南,因为这将使你更符合社区的标准实践。
您还可以指出一些遵循统一代码风格的例子——例如,如果不熟悉代码库的人查看了它,他们就不必破译多种风格。可以这样想:如果你正在读一本书,很容易看出每一章都是由不同的人写的,你会在读了几章后感到困惑吗?
我认为重要的是不要用消极的方式批评你的同事。最好是向人们推销改变的好处,这比说服他们写的是糟糕的代码要容易得多。
其他回答
使用一些wiki软件在你的网络上创建一个wiki。
在你的网站上开始一个叫做“最佳实践”或“编码标准”的类别。
把每个人都指向它。允许反馈。
当您发布软件时,让负责将代码放入构建中的人员向开发人员推送,让他们指向上面的Wiki页面。
我曾在我的组织中这样做过,人们花了几个月的时间才真正熟悉使用Wiki,但现在它是一个不可或缺的资源。
耐心再怎么强调都不为过。我见过这种完全事与愿违的事情,主要是因为有人希望现在就发生变化。相当多的环境需要进化的好处,而不是革命。今天强行改变,可能会给所有人带来一个非常不愉快的环境。
接受是关键。你的方法需要考虑到你所处的环境。
听起来你所处的环境有很多“个性”。所以…我不建议使用一套编码标准。你会发现你想把这个“有趣”的项目变成一个高度结构化的工作项目(哦,太好了,接下来是什么……功能文件?)相反,正如其他人所说,你必须在一定程度上处理它。
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).
耐心。进化,而不是革命。
祝你好运。
可能在效果后有点晚了,但这就是一致认可的编码标准是件好事的地方。
首先,我会注意不要太快下结论。有些代码很容易被认为是坏的,尽管可能有很好的理由(例如:使用带有奇怪约定的遗留代码)。但让我们暂时假设他们真的很糟糕。
你可以建议建立一个基于团队输入的编码标准。但是你真的需要考虑他们的意见,而不仅仅是强加你对好的代码应该是什么样子的看法。
另一种选择是把技术书籍带进办公室(《代码完成》、《有效的c++》、《实用的程序员》……),并主动把它借给别人(“嘿,我用完了,有人想借吗?”)
代码标准的想法是一个很好的想法。
但考虑一下不要说什么,尤其是因为这是为了好玩,而且大概是和你的朋友。这只是代码……
推荐文章
- 检查字符串是否包含字符串列表中的元素
- 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