What if the code we have uses a concrete class in its implementation?
如果我们拥有的代码在执行中使用一个具体的类该怎么办?
If you only have a concrete class, you can create an interface from the class, change your application code to program to the interface, and then proceed as described above.
如果您只有一个具体的类,那么您可以从类中创建一个接口,您的应用程序代码改写为接口,然后按照前面的描述继续进行。
For DI to work, you must have an interface whose concrete class you can inject into the consumer of the behavior you desire.
为了让DI工作,必须拥有一个接口,可以把这个接口的具体类注入到需要的行为的消费者中。
Because only skeleton code is generated, you must next provide concrete implementation code for each class.
因为只生成了框架代码,接下来必须为每个类提供具体的实现代码。
Create a mock object class as a subclass of the concrete class.
创建一个模拟对象类作为具体类中的一个子类。
The value object in Listing 2 looks almost identical to our remote interface, but it's actually a concrete class.
清单2中的值对象看起来和我们的远程接口几乎相同,但它实际上是具体类。
Figure 7 presents the persistence model when each concrete class is mapped to a data entity.
图7显示了将每个具体类映射成数据实体时的持久性模型。
In this way, you can change the concrete class later without changing the library code, which relies solely on the definition you created in the interface.
这样,日后就可以在不改变库代码的情况下修改具体的类,因为库只依赖接口中创建的定义。
Client classes can be coded to require only the abstract type, leaving the strategies and outcomes of implementation to the concrete class instances passed to them at run time.
客户机类可被编码为只需要抽象类型,而把实现策略和结果留给在运行时传递给它们的具体类实例。
Another class of concrete models is based on declarative languages.
具体的模型的另一个类别是基于声明语言的。
If an operation is declared as abstract then the inheriting class must provide a concrete implementation.
如果某项操作被宣布为抽象的那么继承的类必须提供了一个具体的实施方案。
All you've done here is take the same signature you used for the method in the actual concrete class.
在这里完成的所有操作是获得用于实际的具体类中方法的同一个签名。
The class can be either an interface or a concrete class.
这个类既可以是个接口,也可以是个明确的类。
You can simply instantiate it programmatically, but then your code will depend on a concrete implementation class.
可以简单地以编程方式对其进行实例化,但是这样的话,您的代码将依赖具体的实现类。
A class (whether abstract or concrete) that implements an interface does not really inherit anything from the interface it implements.
一个类(不管是抽象的还是具体的)实现一个接口并不真正从它实现的接口继承任何东西。
The above line pairs the fully qualified class name of the concrete remote service class with a path name that is essentially the URL for this service.
上面一行把具体远程服务类的全限定类名与实质上为此服务url的路径名组成一对。
Using one data entity per concrete class.
每个具体类使用一个数据实体。
Strategy 3: One table per concrete class (Estates).
策略3:每个具体类一个表(estates)。
Our third and last strategy is probably the most imaginative of all: having one table per concrete class and none for the Estate abstract superclass.
我们的第三个,也是最后一个策略可能是三个策略当中最有想象力的:每个具体类一个表,抽象超类estate没有表。
Scenario 3: Use jMock and RMock to mock a concrete class with a nondefault constructor
场景3:使用jMock和RMock 模拟带有非默认构造函数的具体类
First, much of the work done by a concrete class is specified in the docstrings of methods.
首先,具体类所完成的大部分工作都在方法的文档字符串(docstring)中指定。
A concrete class that implements the DAO interface.
一个实现了dao接口的具体类。
ScriptEngineManager is probably the only concrete class in the scripting package you'll use regularly; most of the rest are interfaces.
ScriptEngineManager可能是脚本包中惟一一个经常使用的具体类;其他大多数都是接口。
You now have a concrete JUnit TestCase class that can be treated as if the suite composite were statically defined.
现在就有了一个具体的JUnitTestCase类,可以像静态定义的包那样处理它。
Instead of accepting an ICollaborator interface, it now accepts a concrete class implementation (the Collaborator class).
它现在不接受ICollaborator接口,而接受具体类实现(collaborator类)。
The powerful as operator in Groovy takes a code block and generates a new class that implements the interface, which you can then call as if it were a concrete class implementing the interface.
Groovy中强大的as操作符接收一个代码块并生成一个新类来实现该接口,您可以像调用实现该接口的具体类一样调用它。
Typically this is implemented by having an abstract class that has a static create method that returns a concrete object implementing the abstract class.
这种模式的典型实现方式是创建一个抽象类,其中具有静态方法create,这个方法返回的是实现了这个抽象类的一个具体对象。
You can achieve some code separation if you represent the concrete Customer Persistence class as an interface instead.
如果换用接口来表示Customerpersistence类,可以实现一些代码分离。
Table per-class: (Optional) Each concrete subclass is mapped to a table and contains columns for super class attributes.
按类表:(可选)每个具体的子类映射到一个表,并且包含超类属性的列。
The concrete DAO class contains logic for accessing data from a specific data source.
具体的dao类包含访问特定数据源的数据的逻辑。
应用推荐