The singleton is a useful design pattern for allowing only one instance of your class, but common mistakes can inadvertently allow more than one instance to be created.
单例模式是一种非常有用的设计模式,它允许你的类对外只提供一个实例,但是常犯的错误在于不止一个实例被创建。
This pattern lets us hide a complicated interface by substituting a class or component with a simplified interface.
将类或组件以一个简化界面替代,该模式可以使我们将复杂的界面隐藏起来。
The simplest approach is to encapsulate the creation of the proxy class within the Factory pattern.
最简单的方法就是在工厂模式中把代理类的建立封装起来。
Figure 6 shows the class diagram from the WS response template pattern.
图6显示了WS响应模板模式的类关系图。
Figure 1 shows a class diagram of the adapter pattern.
图1显示了适配器模式的类图。
Figure 3 shows a class diagram of the iterator pattern.
图3显示了迭代器模式的类图。
The simplest character class is a single character, which is just included in the pattern as a literal.
最简单的字符类就是单个字符,它在模式中只是一个字。
This is a class that can be used repeatedly to instantiate a class as a singleton without having to re-write the singleton pattern code for that specific class.
这是一个可用来创建单例类实例确不需要为每个特定的类重写单例模式代码的可重用的类。
Figure 5 shows a class diagram of the delegate pattern.
图5显示了委托模式的类图。
Figure 4 shows a class diagram for the decorator pattern.
图4显示了装饰器模式的类图。
One of the approaches for overcoming drawbacks of the previous pattern is to treat enterprise data access as a first class business services.
克服上一个模式缺点的一种方法就是将企业数据存取当作第一级的业务服务。
Create a new Unified Modeling Language (UML) class diagram, then open the Pattern Explorer that Figure 1 above shows.
创建一个新的统一建模语言(Create a new Unified Modeling Language,uml)类图,然后打开上图1中显示的模式浏览器。
This pattern is ideal for the configuration class because there should only be one configuration object for the application.
这种模式对于configuration类是十分理想的,因为应用程序应当仅有一个配置对象。
This serves as a useful base case, similar to a base Visitor class in the classic Visitor pattern.
这将作为一种有用的基本用例,类似于经典访问者模式中的基本Visitor类。
The file will include the specific servlet class definitions and their corresponding URL pattern.
这个文件将包括特定的servlet类定义以及它们对应的URL模式。
As a general rule, add a PatternParameterDelegate statement to the constructor of each parameter class of the composed pattern.
为复合模式的每个参数类的构造函数增加PatternParameterDelegate声明已成为一种普遍规律。
Bug patterns often stem from confusing features of the language or the class library; this bug pattern stems from the somewhat counterintuitive fact that RuntimeException extends Exception.
bug模式通常源自语言的模糊功能或类库;出现此bug模式是因为RuntimeException扩展了Exception,这稍微有点违反常理。
In keeping with the Reactor pattern, a Selector class is a multiplexor of Channels.
与反应器模式一致,Selector类是Channel的多路复用器。
You can use a Factory pattern to create an instance of an implementation class that implements your interface.
您可以使用Factory模式来创建实现接口的实现类的实例。
There is no need to further specify the Marshaller interface because we will get prompted to specify the location of this class by the wizard when the pattern is applied.
没有必要去进一步指定Marshaller接口,因为应用模式时向导会提示我们指定这个类的位置。
Concrete classes provide the appropriate implementation for their respective base class. The Factory Method Pattern consists of the following classes.
concrete类为它们各自的基类提供恰当的实现。
You can also represent the pattern solution visually, in terms of both structure and behavior. Figure 5 is a UML class diagram showing the participants in the Observer pattern.
您还可以按照结构和行为两方面从视觉上来展示模式图5是一个UML类图标,表示Observer 模式的参与者。
Consider the visitor pattern in which a visitor class is defined with a for method for each class in a composite hierarchy.
请考虑访问者模式,其中用for方法为复合层次结构中的每个类都定义了访问者类。
This is demonstrated using the ExceptionHandler class, which again adopts a singleton design pattern.
使用exceptionhandler类可以展示这一点,该类也采用了singleton设计模式。
Since the pattern requires a class word and "ADDRESS" is not a class word defined in the glossary model, a warning with the following description will be displayed in the Problems view.
因为这个模式要求有一个类单词,但是“ADDRESS”不是术语表模型中定义的类单词,所以problems视图中显示一个警告,其描述如下。
This expression is then retained by the Pattern class before it is passed on to the Matcher class to check for matches in the context of a character sequence.
Pattern先保存要使用的表达式,然后将其传递给Matcher 类以便在字符序列的上下文中检查其匹配情况。
Line 33 - Uses the 'fnmatch' method of 'file' class to check if the file found matches the pattern given.
第33行-使用“File”类中的“fnmatch”方法检查发现的文件是否符合给定的模式。
Line 24 - Uses the 'fnmatch' method of 'file' class to check if the file found matches the pattern given.
第24行-使用“File”类中的“fnmatch”方法检查发现的文件是否符合给定的模式。
Listing 6 creates a Field using the Factory pattern in the Layout class.
清单6用工厂模式,在Layout类中创建了Field。
Since the pattern requires a class word and “CIVILIAN EMPLOYEE" doesn't contain a class word, a warning with the following description is displayed in the Problems view
因为这个模式要求有一个类单词,但是 “CIVILIANEMPLOYEE”不包含类单词,所以Problems视图中显示一个警告,其描述如下
应用推荐