正如您所见,类方法非常简单。
确保只有一行是父类方法调用。
Make sure that there is only one line that is a super method invocation.
超类方法——在运行时不需要其他实例。
Superclass methods — no additional instance needed at run time.
现在让我们添加形成DSL的类方法。
这也适用于函数,甚至是类方法,如下所示。
The same concept can be used with functions, or even class methods, as shown below.
这是另一个类方法。
实际上有两类方法。
清单4展示如何使用php重载调用对象和类方法。
Listing 4 illustrates using PHP overloading to invoke object and class methods.
第一类方法使用任意的xml片段,如下所示。
In one class, some of the methods work with arbitrary fragments of XML, as follows.
图2中的第二类方法则操纵元素中的属性。
The second class of method in Figure 2 comprises methods that manipulate attributes within elements.
对于实际的时间戳转换,我们使用了下面的类方法。
For the actual timestamp conversion the following class method was used.
这就是类方法为了进行时间戳转换而在内部使用的值。
That is the value that would be used internally by the class method for the timestamp conversion.
这意味着存储过程不同于类方法,因为它们不是表的一部分。
This would imply that stored procedures are not similar to class methods since they are not part of tables.
类的API目前包含对于继承和超类方法调用的完善支持。
The class API now includes full support for inheritance and superclass method calls. (See Mislav's tutorial for more info.)
相反,可以在Web服务类方法中使用以下内容作为参数或返回值。
Conversely, you can use the following as parameters or return values in a Web service class method.
一般来讲,可以通过类方法或实例方法的调用来获得对象引用。
Generally, object references can be obtained by the invocation of a class method or instance method.
同样,您几乎总是在子代方法主体的开始或结束部分调用超类方法。
Likewise, you almost always call a superclass method at either the start or end of a descendent method body.
Ruby还包括另外一个方便的DSL机制:alias_method类方法。
Ruby also includes another handy DSL mechanism: the alias_method class method.
在本文中,我讨论了延迟静态绑定、名称空间支持、类方法重载和heredoc支持。
In this article, I looked at late static binding, namespace support, class method overloading, and heredoc support.
确定代码库中类方法的CC并连续监视这些值将使您的团队在复杂问题出现时抢先处理它们。
Determining the CC of class methods in a code base and continually monitoring these values will give your team a head start on addressing complexity issues as they arise.
为简化问题,我没有为类的所有属性都建模;也没有为其完整签名或任何类方法建模。
To keep the issues simple, I have not modeled all of the attributes of the classes; nor have I modeled their full signatures or any of the methods of the classes.
您需要这些文本字段的内容和对其进行格式化的Formatter类方法,如 清单2所示。
You need the contents of these text fields and the Formatter class methods to format them, as Listing 2 shows.
就像您有时想对继承方法中的超类方法进行调用一样,您有时还想在分派器内对不太特定的规则进行调用。
Just as you sometimes want to call on superclass methods in an inherited method, you also sometimes want to call on less specific rules within a dispatcher.
有了JSFUnitAPI,测试类方法可以提交表单数据,并且验证管理的bean是否被正确更新。
With JSFUnit API, the test class methods can submit data on a form and verify that managed beans are properly updated.
要确保对链中所有类的正确初始化,实现者必须手动编写超类方法调用的代码,如清单11 所示。
To guarantee the correct initialization for all the classes in the chain, the implementer must manually code the superclass method invocation as shown in Listing 11.
您可以研究本文的代码下载中包含的类方法,以了解关于如何计算每个结果对象值的更多信息(请参阅参考资料)。
You can examine the class methods included in the code download for this article to find out more about how each result object value is computed (see Resources).
回顾一下插件制作者需要的三个条件:放置实现的位置,公开DSL(类方法)的方法以及为状态机公开实例方法的方法。
Recall that a plug-in author needs three things: a place to put the implementation, a way to expose the DSL (the class methods), and a way to expose the instance methods for the state machine.
可以将GuiTestObject只传递到构造函数中一次,然后将设置和获取文本的方法用作实例方法,而不是用作类方法。
Instead, you can pass in the GuiTestObject to the constructor once, and then use the methods to set and get the text as instance methods instead of class methods.
它们不像实例方法那样常见,但您将会经常看到一些类方法,它们作为创建新的类实例的工厂方法;这免得您必须进行分配和初始化。
These are not as common as instance methods, but you will often see class methods that are factory methods for creating new instances of the class; this saves you from having to alloc and initialize.
应用推荐