tailieunhanh - Patterns in JavaTM, Volume 3 Java Enterprise Java Enterprise Design Patterns phần 4
Nếu phương pháp cam kết quản lý giao dịch được gọi là tín hiệu Hình tiết kiệm nhà nước cho việc phục hồi trong tương lai Một đối tượng RedeliveryAgent sử dụng một TreeMap để duy trì một bộ sưu tập của các đối tượng trả tàu theo thứ tự, trong đó trả tàu của họ dự kiến . | 142 Chapter Six Having a globally unique identifier allows an object to move between different environments and still retain its unique identity. Having a globally unique identifier allows objects in other environments to refer to that object. The Object Identifier pattern increases the time and memory required to create objects. Even if two different environments are designed using the object ID they may not be able to share uniquely identified objects if the implementation details are different. IMPLEMENTATION Representation of Environment IDs The representation for environment IDs must allow for a sufficiently large number of identifiers to allow every environment that needs a unique environment to have one. A variable-length representation such as a string has no practical limit to the number of environment IDs it can represent. However variable-length representations take more time to compare and manipulate than fixed-length representations. The drawback to fixed-length representations is that the total number of IDs they can represent is determined at design time. It cannot be easily changed later. An int may be sufficiently large for many applications. However if it is possible that there will ever be a need for more environment IDs than can be represented by an int you should use a larger representation. Representing the Object-Specific Portion of an ID The issues regarding the representation of an object ID are similar. The object-specific portion of an object ID must be able to represent as many IDs as there will ever be objects created in an environment. Because there is generally a need to generate the IDs frequently and cheaply the usual representation is an integer that can be generated by a counter of the appropriate number of bits. Both the anticipated rate of object creation and the lifetime of the environment should be considered when deciding on the number of bits to represent the object-specific portion of an object ID. For a distributed game a
đang nạp các trang xem trước