God Object 反模式是一个很容易犯的错误。 有时,停课似乎工作量太大。 然后在稍后的某个时候你会付出代价。 我发现这种反模式与紧密耦合密切相关。
当您使用供应商特定语言时,供应商锁定反模式也可能很难避免。
The God Object anti-pattern is an easy mistake to make. Sometimes it can seem like too much work to break classes up. Then at some point later you pay for it. I have found this anti-pattern goes hand in hand with tight coupling.
The vendor lock-in anti-pattern can also be a hard one to avoid when you're using vendor specific languages.
In the comments and I think It's warrants being an answer - the Singleton pattern.
It is a way of achieving global variables when a language (such as Java) doesn't support it. This is one of those patterns where you should never use - except when you need it. The important bit is being able to differentiate between when you need to have a global variable (there are instances) and when you just want one.
There are problems with singletons beyond the serious problems of introducing global state, in Java for instance they are only single within the class loader with multiple class loaders you can end up multiple copies.
There is always that one vendor specific thing that gets added for a specific piece of functionality since it makes more sense than writing it yourself. I've spent much time kicking myself for this decision later on.
It is very easy trying to make something flexible, and ending up with the Inner Platform Effect. I'm guilty of inner-databases, for example.
And sometimes it is too tempting to code things yourself rather than use that pre-canned similar version - Not Invented Here. I try to avoid it, but...
发布评论
评论(6)
God Object 反模式是一个很容易犯的错误。 有时,停课似乎工作量太大。 然后在稍后的某个时候你会付出代价。 我发现这种反模式与紧密耦合密切相关。
当您使用供应商特定语言时,供应商锁定反模式也可能很难避免。
The God Object anti-pattern is an easy mistake to make. Sometimes it can seem like too much work to break classes up. Then at some point later you pay for it. I have found this anti-pattern goes hand in hand with tight coupling.
The vendor lock-in anti-pattern can also be a hard one to avoid when you're using vendor specific languages.
您可以在 SO 本身中找到更多信息:
您“最喜欢的”反模式是什么?
最常用的反模式是什么?
you can find more info in SO itself:
What is your “favorite” anti pattern?
What are the most commonly used anti-patterns?
在评论中,我认为这是一个答案——单例模式。
它是当语言(例如Java)不支持时实现全局变量的一种方式。 这是您永远不应该使用的模式之一 - 除非您需要它。 重要的是能够区分何时需要全局变量(有实例)和何时只需要一个全局变量。
除了引入全局状态的严重问题之外,单例还存在一些问题,例如在 Java 中,单例在类加载器中只是单个,而多个类加载器可能会导致多个副本。
In the comments and I think It's warrants being an answer - the Singleton pattern.
It is a way of achieving global variables when a language (such as Java) doesn't support it. This is one of those patterns where you should never use - except when you need it. The important bit is being able to differentiate between when you need to have a global variable (there are instances) and when you just want one.
There are problems with singletons beyond the serious problems of introducing global state, in Java for instance they are only single within the class loader with multiple class loaders you can end up multiple copies.
供应商锁定
总是为特定的部分添加一个供应商特定的东西功能,因为它比自己编写更有意义。 后来我为了这个决定花了很多时间责备自己。
Vendor Lock In
There is always that one vendor specific thing that gets added for a specific piece of functionality since it makes more sense than writing it yourself. I've spent much time kicking myself for this decision later on.
尝试使某些东西变得灵活是很容易的,最终会产生内部平台效应 。 例如,我对内部数据库感到内疚。
有时,您很容易自己编写代码,而不是使用预先封装的类似版本 - 并非此处发明< /a>. 我试图避免它,但是...
It is very easy trying to make something flexible, and ending up with the Inner Platform Effect. I'm guilty of inner-databases, for example.
And sometimes it is too tempting to code things yourself rather than use that pre-canned similar version - Not Invented Here. I try to avoid it, but...
复制粘贴反模式
Copy and paste anti pattern