|
|
1
4
I would argue that it isn't a CreditCard object's job to validate anything. A factory would validate the check digits to ensure that it is instantiating a conforming card, while a verification service would validate the card for expiration/$ limit. |
|
|
2
1
我想这么说
从 C2 wiki :
如果
I usually have Value Object, Service and Business Object. I don't know about "Growing Object-Oriented Software", but restricting yourself to only Value Object and Service seems odd to me. |
|
|
3
0
我会打电话
Anyway, it should be perfectly fine for an entity class to use service classes. If the implementations of said services don't need to be selected at runtime based on external configuration, then I would simply instantiate and use the desired service class inside the client method. Contrary to what some may think, this doesn't preclude unit testing, as a mocking tool can be used for isolation. 如果服务实现 做 需要在运行时选择,而不是 服务定位器 可以使用。This pattern can provide direct support for mocking/faking, without the need for a specialized mocking tool. Use of a DI framework supporting injection into "newed" objects would be another alternative. |
|
|
simply lemon · python上链表的添加方法 2 年前 |
|
|
Anonymous · 为什么在这个例子中self和类名的用法不同? 2 年前 |
|
|
P N Singh · 在CPP Oops中调用对象而不创建它 2 年前 |
|
|
Muthuraj · 如何创建一个通用工厂来创建某种类型的实例[重复] 2 年前 |
|
|
Andy Votava · 从父类定义调用学生方法 2 年前 |