作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在编程时,我们都会开发我们使用和依赖的实践和模式。然而,随着时间的推移,随着我们的理解、成熟度甚至技术使用的变化,我们逐渐意识到一些我们曾经认为很棒的实践并不适用(或不再适用)。
我曾经经常使用但近年来发生变化的做法的一个例子是使用 Singleton object pattern 。
通过我自己的经验以及与同事的长期辩论,我逐渐意识到singletons are not always desirable - 它们可以使测试变得更加困难(通过抑制模拟等技术),并且可以在系统各部分之间产生不良的耦合。相反,我现在使用对象工厂(通常使用 IoC 容器)来向系统中不关心或需要知道的部分隐藏单例的性质和存在。相反,它们依赖工厂(或服务定位器)来获取对此类对象的访问权限。
本着 self 完善的精神,我向社区提出的问题是:
最佳答案
//Coming out of university, we were taught to ensure we always had an abundance
//of commenting around our code. But applying that to the real world, made it
//clear that over-commenting not only has the potential to confuse/complicate
//things but can make the code hard to follow. Now I spend more time on
//improving the simplicity and readability of the code and inserting fewer yet
//relevant comments, instead of spending that time writing overly-descriptive
//commentaries all throughout the code.
关于language-agnostic - 您曾经喜欢的哪些编程实践后来改变了主意?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1089327/
我的项目中有以下文件。
我们目前拥有相当大的相互依赖的多项目代码库,使用 Java7 和 Groovy,通过运行 Tomcat 7 的 Eclipse/WTP 和 Ant 构建。基本上,您可能会在大多数 Java 企业软件开
我是一名优秀的程序员,十分优秀!