[Reproduced] JIVE design ideas

xiaoxiao2021-03-06  118

As the foundation of the forum, the designer has established a series of interfaces to represent the operation of the basic objects needed by the forum system (note is the operation of the basic object rather than the basic object, so the interface mode is used instead of abstract base classes. This has greater flexibility in the specific implementation, which is for example, because it is an interface, there is no specified type of the main identifier of the ForumID, and if the database implementation is used, then the LONG type will be the appropriate selection, and if it is XML file is implemented, then the implementation may want to use String mode tags, conversion when needed), mainly expressed authorization, filter, forum, theme, message, user, user group, and several Manage the manager of these objects, on the basis of these abstractions, gives the corresponding proxy for permission management. As a system that requires permission authentication and management, use this way to hide this permission authentication, because these proxy implements those interfaces, so they can use these Proxy classes like using the interface, they are encapsulated internally. A corresponding specific example, completely handles the actual operation to the example, just verify the permissions before the corresponding method of the call, so that the implementation class of these abstract interfaces can be worried, and the final operation is achieved. The separation of permissions is not aware of this change. Another feature that is worth mentioning is that the cache function can use the cache function to greatly improve the performance of the system in most cases. The cache is the cacheable interface. There is only one way: getSize, returns the size of the object that needs to be cached, this size should be good reflecting the size of the object to be cached (the reason for the size is the greatest, "FROUMMESSAGE and FORUMTHREAD, Because the difference between the specific instances of these two objects will be very large, the difference between the examples of objects, user, groups is not very large), and another very important class of cache functions is longcache. Because in the implementation of the forum, those cache classes are actually packaged for longcache, and this class itself encapsulates three collection classes to complete their specific features, a HashMap and two LinkedList, represents the collection of cache objects, caching The recent access order of the object and the order of joining the cache, and the standard JDK's collection class is that longHashmap is the LONG type as its key, and the standard collection framework uses Object as Key, in addition, join the cache object to the cache When the Add method encapsulates the object again into a longcacheObject object, because HashMap is disorder, and the cache mechanism wants to implement the most frequent access principle, so it will be accessed in the cache. Modify the data in the LINKEDLIST representative of the recent access order, mention the most recent access location of the object, and if the object is not encapsulated (mainly the location in the list), then it won't know it In the LINKEDLIST representing the nearest access order, although it can be obtained by traversing, the overhead of this is very large, the meaning of the cache function will be lost, and the object is encapsulated into the longcachebject, and the information on the front and rear nodes is saved to LongcacheObject. In this way, the time overhead that modifies the data in the LINKEDLIST that represents the nearest access order will be constant levels.

转载请注明原文地址:https://www.9cbs.com/read-98256.html

New Post(0)