Conception of Programmable Application

类别:软件工程 点击:0 评论:0 推荐:
 

W

hat is the Programmable Application

Programmable Application is an application that has a built-in script mechanism with which users can type in their commands to implement functionalities provided by the application.

In our daily life, we can often see this kind of application. Just take the Microsoft Word as an example, when we click Start->Programs, get into the Microsoft Office group, and then start the Word, we can type anything we want there, further more, we can record a macro, run a macro or even open the Visual Basic editor anytime and anywhere we want. We can say Word is a Programmable Application and the Visual Basic (actually it is the Visual Basic for Application) here is a built-in script for this application. One thing needs to be explained here is that, Visual Basic for Application is not only a built-in script for Word, but also other software in Microsoft Office.

Why we should make our application programmable

Generally speaking, we make our application programmable just for the new features and advantages, which were provided by this new application architecture. These features and advantages include:

a.  Flexibility

Flexibility is the first and the most important feature that was provided by the programmability. As we know, most application is made up of several modules. These modules provide specialized functionality and fit together to implement the business logic of the whole application. For example, a student management system can consist of student registration module, course management module, score management module, student information management and so on. Following figure illustrates the structure of these applications.

Application

 

Module 1

Module 2

Module 3

 

 

 

 

Figure 2.a.1 Common Application Structure

This kind of application can meet most users’ requirements, but maybe some users have their own special requirement, for example, in student management system, some users do not need the student information management, but they want the certification management to be integrated into the system. In common application structure, we can neither add a module to the system, nor remove a module from the system, so we say that the common application structure doesn’t have the flexibility.

To make the application flexible, we can use the plug-in technology. This kind of technology is mainly implemented by using the Dynamic Link Library (DLL). In this scenario, modules are compiled into individual DLLs, which have the same interface[1]. After we registered these DLLs in the system, the application can easily find them and load them when it starts. We can also get some DLLs unregistered if we don’t need them. Such kind of application structure can be illustrated by the following figure.

 

 

 

Figure 2.a.2 Flexible Application Structure (DLL-Based)

However, this structure is not the best choice, because it is hard to implement and maintain. Users who use this application must know much about the DLLs and system programming. Data exchange between modules could be a big problem for system analysts.

Built-in script can also provide the application with flexibility, and it is very easy to use. In programmable application, what you need to do is, key in the script code, compile it, and run the compiled code, the application will do all the things that you want to do. You can also define your module by using the script, and you can even remove your module by deleting the script that you’ve just written. With the introduction of built-in script, data exchange is no longer a problem in the implementation of the application. Following is the structure of programmable application.

Application

 

 

 

Programming Environment

Libraries and APIs

Built-in script

Compiler / Interpreter

Module 1

Module 2

Module 3

 

  

 

Figure 2.a.3 Flexible Application Structure (Programmable)

b.  Batch processing

Batch processing is another feature that comes with the programmability. Let’s take the student management system mentioned above for example, if we want to register a new student, we should first click the registration option on the menu, and a popup window will be displayed on the screen to let us input the name of the student, the gender, the date of birth and other related information. After we confirmed all the information, we should click “Register” button on the window to post the registration information to the system. We follow these steps to register only one student at a time, if we want several students to be registered, we have to repeat these boring steps.

Image that our student management system is programmable, we can define our commands (scripts) in the system, and we can define a command called “RegStudent”, which is used to register new students. All relevant information can be passed to the RegStudent command as parameter. If we want to register a student by using the command, what we want to type in may be similar to this:

RegStudent SunnyChen, Male, 09/23/80, ComputerScienceDept

 

 

Figure 2.b.1 RegStudent Command

The command above tells the compiler (or interpreter) to register a student whose name is SunnyChen to the system. Other information such as gender, date of birth, department, is passed to the RegStudent command as parameter, just like the first parameter (the name of the student) “SunnyChen”.

If we want to register several students, we just need to add more commands to the script. When we run the script, all the commands will be executed. For example, if we want to register three students whose names are SunnyChen, Tom and Jane, we can key in the following commands:

RegStudent SunnyChen, Male, 09/23/80, ComputerScienceDept

RegStudent Tom, Male, 03/22/81, CommunicationTechDept

RegStudent Jane, Female, 05/10/80, LanguageDept

 

 

 

 

Figure 2.b.2 RegStudent Commands

When we run the script above, the system will know what we want to do, and will get these three students registered.

Compared to the student management system that doesn’t support the programmability, we can register more than one student at a time by running the script. Such kind of processing is known as the batch processing.

c.  The ability of Operation Copying

Programmable Application can support Operation Copying, with which we are able to copy the operation from one system to another, this because operations are written in script, and the script can be copied. We can copy the three RegStudent commands above to another system and register the three students there, instead of getting these students registered one by one manually.

 

 

How to make my application programmable

To make our application programmable, we must know much about the computer system, from hardware to software. Programmable application can provide new features to users, and it is very convenient for users to use, but it is really very difficult for the developers to implement.

From the paragraphs above, you can infer that the compile principle may be the most important thing in implementing the programmable application. Compile principle is really important, but before the implementation of the compiler, we must be expert in data structure and computer algorithm, because these two subjects are the bases of compile principle. For example, the grammar tree in the grammar analysis phrase can be represented by the tree structure, and the DAG-related issues in the code optimizing process can be solved by the introduction of graphic theory.

Another thing that we must know is which architecture should be used to implement such a programmable application. This mostly depends on the developer. Usually, we can just design a compiler to compile the script to the native code that can be easily understood by the system, it is the best choice when the system performance is considered to be the most important thing. However, if we want to make our script run on other application systems, or other platforms, we can’t directly compile the script to the native code, because the native code may not be supported by other platforms. What we want to do is, just compile the script to the intermediary code, and then design an interpreter to interpret the intermediary code. The following figure illustrates the architecture of this script mechanism.

Programming Environment

Libraries and APIs

Built-in scripts

Compiler

Intermediary Code

Compile

Interpreter

 

 
Figure 3.1 Architecture of platform-free programming environment

 

With the introduction of this architecture, we can make our script run on every system or platform. We just need to design one compiler to compile the script, and implement interpreters on each system or platform to interpret the intermediary code. Further more, we can define various forms of the built-in script[2] and design a compiler for each of it.

 
Figure 3.2 Architecture of platform-free programming environment (Multi-language)

 

 

[1] With this common interface, the application can easily locate the entry of Dynamic Link Library and load it when the application starts.

[2] These various forms of the built-in script can be known as different languages

本文地址:http://com.8s8s.com/it/it33201.htm