Fully scalable Object Model

Source: Internet
Author: User

Many applications now use plug-in systems, which define several interfaces. developers can use these interfaces to write plug-ins and then register plug-ins with the application system. From the perspective of software design, this is the Extensible object model. The plug-in can be expanded at will, but the application system using the plug-in remains unchanged. Therefore, it is a one-sided extensible object model. Here, the word one-sided is not derogatory, but only uses this model as needed.

If the application subject that calls the plug-in is extended in this extensible model, it can be called a fully scalable object model.

Implementing a scalable object model is complicated. It involves abstract thinking about module functions and object-oriented programming ideas. Here we use the object model of the file system to demonstrate it.

First, the software functions are abstracted. The main functions of the file system include:
1. The file system consists of files and directories. Each file and directory uses a name.
2. A directory can contain several subdirectories and files to form a tree list of files.
3. You can add or delete subdirectories or files under a directory, and modify the directory name or file name.
4. You can obtain a list of all subdirectories or files in a directory. You can obtain subdirectories or files with the specified name.
5. Files can be read or written to binary data for operationCompositionObject.
There are also several other features.

Obviously, all file systems should implement the above basic functions, so it is easy to design the following three objects

Xfilesystembase is the main object or top-level object of the file system. It is used to support the running of the entire file system model.
Xdirectorybase abstract directory object.
Xfilebase abstract file object.

These three objects abstract the general functions of the file system, construct the object model of the file system, and implement some routines.

After the object model of the abstract file system is established, we first expand the file system of the operating system, mainly using the system. the modules in the IO namespace are extended for xfilesystembase, xdirectorybase, and xfilebase. Three new types of stdfilesystem, stddirectory, and stdfile are generated.

Someone may ask, isn't it very convenient to directly use the system. Io namespace? In fact, many design patterns are used to expand the compilationCodeIt took a lot of time to construct the object model at the initial stage. Once the model was created, it would be easy to implement software modules with similar functions and avoid code copying and duplication. In the long run, this is very worthwhile. However, rational use of the design model is required. It should be used rationally based on the current needs and the foreseeable future.

Some information systems need to establish functions similar to this type of file system, but are not based on the operating system's standard file system, but on the database. Therefore, we have derived a database-based file system model from an abstract file system. Here we have implemented three types of dbfilesystem, dbdirectory, and dbfile. Dbfilesystem uses a standard database connection object to obtain raw data. Dbdirectory and dbfile call the internal methods provided by dbfilesystem to obtain object data.

In such an application system, if xfilesystembase is used to access the file system, you can point the xfilesystem object to stdfilesystem or dbfilesystem as needed, so that the application system can access the standard file system, you can also access the file system stored in the database. You can switch between the two without affecting other functions of the application system. Enhanced software flexibility.

Because this file system is fully scalable, You can implement file systems based on WebService and FTP, and then the application system can support file system models such as webserver and FTP.

Tens of thousands of lines of code is spent in the xdesignerlib graphics designer middleware I launched to construct a fully scalable designer Document Object Model, the extension of this Document Object Model is similar to the abstract file system here, but the interface is more abundant.

This abstract File System associates with virtual technology, sometimes software Virtual Hardware or other software. For example, the Virtual CD software virtualizes a CD Based on the CD image file stored in the hard disk. Virtual Disk software virtualizes a disk using memory, which can multiply the operation speed when disk files are frequently read/written. Microsoft's underlying operating system defines general file system interfaces, and application software can implement this general file system interface to virtualize various CD and hard disks.

Similarly, the general interface of the file system is defined here, and then stdfilesystem and dbfilesystem use this universal interface to virtualize the file system.

Abstract file systems, standard file systems, and database file systems are provided here.Source codeAnd the demo database. The code is not strictly tested. Http://files.cnblogs.com/xdesigner/xfilesystem.rar.

 

Yuan Yongfu (http://www.xdesigner.cn)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.