设计 任务书 文档 开题 答辩 说明书 格式 模板 外文 翻译 范文 资料 作品 文献 课程 实习 指导 调研 下载 网络教育 计算机 网站 网页 小程序 商城 购物 订餐 电影 安卓 Android Html Html5 SSM SSH Python 爬虫 大数据 管理系统 图书 校园网 考试 选题 网络安全 推荐系统 机械 模具 夹具 自动化 数控 车床 汽车 故障 诊断 电机 建模 机械手 去壳机 千斤顶 变速器 减速器 图纸 电气 变电站 电子 Stm32 单片机 物联网 监控 密码锁 Plc 组态 控制 智能 Matlab 土木 建筑 结构 框架 教学楼 住宅楼 造价 施工 办公楼 给水 排水 桥梁 刚构桥 水利 重力坝 水库 采矿 环境 化工 固废 工厂 视觉传达 室内设计 产品设计 电子商务 物流 盈利 案例 分析 评估 报告 营销 报销 会计
 首 页 机械毕业设计 电子电气毕业设计 计算机毕业设计 土木工程毕业设计 视觉传达毕业设计 理工论文 文科论文 毕设资料 帮助中心 设计流程 
垫片
您现在所在的位置:首页 >>文科论文 >> 文章内容
                 
垫片
   我们提供全套毕业设计和毕业论文服务,联系微信号:biyezuopin QQ:2922748026   
Asynchronous tasks in web applications: Implementation and impact on user experience
文章来源:www.biyezuopin.vip   发布者:毕业作品网站  
n “make  requests” to that object, asking it to perform operations on itself. In theory, you can take any conceptual component in the problem you’re trying to solve (dogs, buildings, services, etc.) and represent it as an object in your program.

2. A program is a bunch of objects telling each other what to do by sending messages. To make a request of an object, you “send a message” to that object. More concretely, you can think of a message as a request to call a method that belongs to a particular object.

3. Each object has its own memory made up of other objects. Put another way, you create a new kind of object by making a package containing existing objects. Thus, you can build complexity into a program while hiding it behind the simplicity of objects.

4. Every object has a type. Using the parlance, each object is an instance of a class, in which “class” is synonymous with “type.” The most important distinguishing characteristic of a class is “What messages can you send to it?”

5. All objects of a particular type can receive the same messages. This is actually a loaded statement,  as you will see later. Because an object of type “circle” is also an object of type “shape,” a circle is guaranteed to accept shape messages. This means you can write code that talks to shapes and automatically handle anything that fits the description of a shape. This substitutability is one of the powerful concepts in OOP.

Booch offers an even more succinct description of an object:

An object has state, behavior and identity.  This means that an object can have internal data (which gives it state), methods (to produce behavior), and each object can be uniquely distinguished from every other object—to put this in a concrete sense, each object has a unique address in memory.

Aristotle was probably the first to begin a careful study of the concept of type; he spoke of “the class of fishes and the class of birds.” The idea that all objects, while being unique, are also part of a class of objects that have characteristics and behaviors in common was used directly in the first object-oriented language, Simula-67, with its fundamental keyword class that introduces a new type into a program.

Simula, as its name implies, was created for developing simulations such as the classic “bank teller problem.” In this, you have a bunch of tellers, customers, accounts, transactions, and units of money—a lot of “objects.” Objects that are identical except for their state during a program’s execution are grouped together into “classes of objects” and that’s where the keyword class came from. Creating abstract data types (classes) is a fundamental concept in object-oriented programming. Abstract data types work almost exactly like built-in types: You can create variables of a type (called objects or instances in object-oriented parlance) and manipulate those variables (called sending messages or requests; you send a message and the object figures out what to do with it). The members (elements) of each class share some commonality: every account has a balance, every teller can accept a deposit, etc. At the same time, each member has its own state: each account has a different balance, each teller has a name. Thus, the tellers, customers, accounts, transactions, etc., can each be represented with a unique entity in the computer program. This entity is the object, and each object belongs to a particular class that defines its characteristics and behaviors.

So, although what we really do in object-oriented programming is create new data types, virtually all object-oriented programming languages use the “class” keyword. When you see the word “type” think “class” and vice versa.  Since a class describes a set of objects that have identical characteristics (data elements) and behaviors (functionality), a class is really a data type because a floating point number, for example, also has a set of characteristics and behaviors. The difference is that a programmer defines a class to fit a problem rather than being forced to use an existing data type that was designed to represent a unit of storage in a machine. You extend the programming language by adding new data types specific to your needs. The programming system welcomes the new classes and gives them all the care and type-checking that it gives to built-in types.

The object-oriented approach is not limited to building simulations. Whether or not you agree that any program is a simulation of the system you’re designing, the use of OOP techniques can easily reduce a large set of problems to a simple solution.   Once a class is established, you can make as many objects of that class as you like, and then manipulate those objects as if they are the elements that exist in the problem you are trying to solve. Indeed, one of the challenges of object-oriented programming is to create a one-to-one mapping between the elements in the problem space and objects in the solution space.

But how do you get an object to do useful work for you? There must be a way to make a request of the object so that it will do something, such as complete a transaction, draw something on the screen, or turn on a switch. And each object can satisfy only certain requests. The requests you can make of an object are defined by its interface, and the type is what determines the interface.

The interface establishes what requests you can make for a particular object. However, there must be code somewhere to satisfy that request. This, along with the hidden data, comprises the implementation. From a procedural programming standpoint, it’s not that complicated. A type has a method associated with each possible request, and when you make a particular request to an object, that method is called. This process is usually summarized by saying that you “send a message” (make a request) to an object, and the object figures out what to do with that message (it executes code).

Here, the name of the type/class is Light, the name of this particular Light object is lt, and the requests that you can make of a Light object are to turn it on, turn it off, make it brighter, or make it dimmer. You create a Light object by defining a “reference” (lt) for that object and calling new to request a new object of that type. To send a message to the object, you state the name of the object and connect it to the message request with a period (dot). From the standpoint of the user of a predefined class, that’s pretty much all there is to programming with objects.

The preceding diagram follows the format of the Unified Modeling Language (UML). Each class is represented by a box, with the type name in the top portion of the box, any data members that you care to describe in the middle portion of the box, and the methods (the functions that belong to this object, which receive any messages you send to that object) in the bottom portion of the box. Often, only the name of the class and the public methods are shown in UML design diagrams, so the middle portion is not shown. If you’re interested only in the class name, then the bottom portion doesn’t need to be shown, either  1.3 An object provides services.

While you’re trying to develop or understand a program design, one of the best ways to think about objects is as “service providers.” Your program itself will provide services to the user, and it will accomplish this by using the services offered by other objects. Your goal is to produce (or even better, locate in existing code libraries) a set of objects that provide the ideal services to solve your problem.

A way to start doing this is to ask “if I could magically pull them out of a hat, what objects would solve my problem right away?” For example, suppose you are creating a bookkeeping program. You might imagine some objects that contain pre-defined bookkeeping input screens, another set of objects that perform bookkeeping calculations, and an object that handles printing of checks and invoices on all different kinds of printers. Maybe some of these objects already exist, and for the ones that don’t, what would they look like? What services would those objects provide, and what objects would they need to fulfill their obligations? If you keep doing this, you will eventually reach a point where you can say either “that object seems simple enough to sit down and write” or “I’m sure that object must exist already.” This is a reasonable way to decompose a problem into a set of objects.

Thinking of an object as a service provider has an additional benefit: it helps to improve the cohesiveness of the object. High cohesion is a fundamental quality of software design: It means that the various aspects of a software component (such as an object, although this could also apply to a method or a library of objects) “fit together” well. One problem people have when designing objects is cramming too much functionality into one object. For example, in your check printing module, you may decide you need an object that knows all about formatting and printing. You’ll probably discover that this is too much for one object, and that what you need is three or more objects. One object might be a catalog of all the possible check layouts, which can be queried for information about how to print a check. One object or set of objects could be a generic printing interface that knows all about different kinds of printers (but nothing about bookkeeping—this one is a candidate for buying rather than writing yourself). And a third object could use the services of the other two to accomplish the task. Thus, each object has a cohesive set of services it offers. In a good object-oriented design, each object does one thing well, but doesn’t try to do too much. As seen here, this not only allows the discovery of objects that might be purchased (the printer interface object), but it also produces the possibility of an object that might be reused somewhere else (the catalog of check layouts).

Treating objects as service providers is a great simplifying tool, and it’s very useful not only during the design process, but also when someone else is trying to understand your code or reuse an object—if they can see the value of the object based on what service it provides, it makes it much easier to fit it into the design.

,

In web applications, most of the tasks is done in a "to prevent the user from long time waiting for the" way. In Google search this example, reduce the waiting time is essential to the user experience. A solution to the asynchronous task is to create a thread in user submission (to handle asynchronous task), but it can not solve the need to certain time interval repeat operation tasks, or at a specified time running task everyday situations.

Let us from a database of examples of statements to have a look the task scheduling can do to help improve the system design. The report may be perplexing, depending on the user for data types, and if they need from one or more database collect large amounts of data. The user may take a long time to run such an "on-demand" report. Therefore, we extend this report example add task scheduling mechanism, so that the user can be arranged in any they need time to generate a report, and in the PDF or other format in email transmission. Users can make report on every day in the morning 2:22, the system is running at low load; also can choose to only run at a specific time at a time. By the addition of task scheduling in report application, we can add a useful function for the product, and improve the user experience.

Fortunately, there is a powerful open source solutions can let us in a standard way in the application of web (or any Java application) in the implementation of task scheduling. The following example shows the application of web, how to use Quartz to create a task scheduling framework. This example also uses the Struts Action framework plug-in, so that in the web application startup initialization task scheduling mechanism. Struts is the most common MVC framework, familiar to most developers. Of course, in addition to many frameworks can help the realization of MVC model in Web application.

Startup initialization task scheduler we first need to do is create a Struts plugin, let it create task scheduler we in the container startup. In the following example, we choose Tomcat as the web application container, but these examples in other container should also can run. We want to create a Struts plug-in class, and adding a few lines of code in struts-config.xml in order to make it work. This plugin has two configurable parameters: startOnLoad specifies whether to start the task scheduler immediately in the container startup, and startupDelay specifies the waiting time before starting the task scheduler. Start delay is very useful, because we may need to perform some of the more important initialization steps. In addition, you can also use the listener mechanism, in a more complicated way to notify SchedulerPlugIn when to start Quartz Scheduler.

We want to create a Struts plug-in interface list of org.apache.struts.action.PlugIn class SchedulerPlugIn. Struts will appear in the order according to the configuration file initializes each plug-in. Special attention should be paid to the init () method in the code, we initialize the required Quartz objects, and Scheduler. The task information we will submit to a org.quartz.Scheduler object, which will be discussed in the subsequent. The Scheduler object by Quartz servlet according to its initial configuration, the ActionServlet class as the Struts initialization.

JDK provides a number of class library for programmers, and in order to keep the library reusability, scalability and flexibility, which use a lot of design patterns, this paper will introduce to use JDK I/O package in the Decorator mode, and using this model, the realization of a new output stream class.

Decorator mode Decorator mode or wrapper (Wrapper), its main purpose is to add some additional responsibilities to an object dynamically. Compared with the subclass, it has more flexibility. Sometimes, we need an object and not the whole class to add some new functions, for example, add a scrollbar functionality to a text area. We can use the inheritance mechanism to achieve this function, but this method is not flexible enough, we can not control the text area and the scroll bar mode and time. And when the text area need to add more features, such as the border, you need to create a new class, and when the combined use of these functions will undoubtedly caused an explosion required. We can use a more flexible approach, is to make text area into a scroll bar. The scrollbar class is equivalent to a decorative text area. This decoration (scroll) must and decorated component (text) inherited from the same interface, so that users don't need to care, decoration, because it is transparent. Decoration will forward the user request to the appropriate component (that is, call the appropriate method), and may do some extra action in the forwarding and (such as add scroll). By this method, we can according to different combinations of text region nested decoration, so as to add any more function. The method of adding functions will not object this dynamic caused an explosion, also has more flexibility.

The above method is the Decorator model, which dynamically add new functionality by adding decorative objects. Component components and decorative public class, which defines the methods of subclasses must implement the. ConcreteComponent is a specific component class, you can add new features by adding decoration to it. Decorator is all the decoration of public class, which defines the method, all the decoration must achieve at the same time, it also holds a reference to Component, in order to transmit user's request to the Component, and possibly in forwarding requests and perform some additional action. ConcreteDecoratorA and ConcreteDecoratorB are specific decoration, can use them to decorate the concrete Component.

JDK Decorator Java IO package provides the java.io package using Decorator mode to realize all kinds of input and output stream package. The following example of java.io.OutputStream and its subclasses, used to discuss the Decorator mode in IO system. The OutputStream is an abstract class, it is all the output stream public class.

It implements OutputStream in write (int b) method, so we can be used to create objects of output current, output and complete the specific format. It is equivalent to the Decorator model in the ConcreteComponent class. Similarly, it is also inherit from OutputStream. However, the constructor is very special, need to pass a OutputStream reference to it, and it will save a reference to this object. And if there is no specific OutputStream objects, we will not be able to create FilterOutputStream. Because out can be a reference to the FilterOutputStream type, can also be a reference to the ByteArrayOutputStream and other specific output stream class, so the use of multi-layer nested manner, we can add a variety of decoration for ByteArrayOutputStream. The FilterOutputStream class is equivalent to the Decorator model in the Decorator class, the write (int b) method is a simple call incoming flow write (int b) method, and not to do more, so there is no nature convection for decoration, so its subclasses must override this method, to to achieve the purpose of decoration.

BufferedOutputStream and DataOutputStream are two subclass of FilterOutputStream, which corresponds to the Decorator mode of ConcreteDecorator, and the output of the incoming flow of the different decoration. Taking BufferedOutputStream as an example:

This class provides a cache mechanism, when the cache capacity reached the number of bytes written to the output stream will only. First, it inherited FilterOutputStream, and covers the parent class write (int b) method, in the call to the output stream to write data checks the cache is full, if not full, don't write. So as to realize the new function is added to the output stream object dynamic purpose.

Below, will use the Decorator mode, write a new output current is IO. Write a new output flow to understand the structure and principle of OutputStream and its subclasses, we can write a new output stream, to add the new function. This part will give a new output flow example, it will filter to be symbolic space output statement. Such as the need to output "Java IO OutputStream", the output is filtered for "javaioOutputStream".

In the java.io package, not only the OutputStream uses the Decorator design pattern, InputStream, Reader, Writer are used in this model. As a flexible, extensible class library, many design patterns are used in JDK, such as in the Swing package in the MVC model, RMI Proxy model etc.. Research on the JDK mode can not only deepen the understanding of the model, but also to a more thorough understanding of the structure and composition of the library.

Protocol adaptor and connector

Program MBean server depends on the protocol adaptor and connector and run the proxy Java virtual machine management for communication applications. The protocol adapter provides a registered in a management component of MBean server by specific protocol view. For example, a HTML adapter can be management component all registered displayed on a Web page. A different protocol, provides a different view. The connector must also provide management application on one side of the interface to make agent and manage application communication, namely according to different protocols, the connector must provide the remote interface similar to encapsulate the communication process. When a remote application using this interface, you can through the network transparent and agent to interact with, and ignore the protocol itself. Adaptor and connector for the MBean server and management applications can communicate. Therefore, an agent to be managed, it must provide at least one protocol adapter or connector. Facing various management application, the agent can contain a variety of different protocol adaptor and connector.

The current has been achieved and will achieve the protocol adaptor and connector includes: 1) RMI 2 SNMP protocol adapter connector) 3) IIOP protocol adapter 4) HTML protocol adapter 5) HTTP connector

Proxy service

Agent service can management component for registered to perform administrative functions. Through the introduction of intelligent management, JMX can help us build a strong management solutions. Agent service itself is a management component, can also be a MBean server control. The JMX specification defines the proxy service are:

1) dynamic class loading, and instantiate a new class by management program services, also can make in library local network.

2) monitoring service -- monitoring management component property value changes, and the notification to all listeners these changes.

3) time - time to send a message or as a scheduler using.

4) the relationship between service - definition and maintain the relationship management between components.

1 dynamic class loading dynamic class loading is obtained by m-let (management applet) services to do so, it can be seen from the network on any URL download and instantiate the management component, and then registered to the MBean server. In a M-let service process, first of all is to download a m-let file, the file is a XML file, the contents of the file identifies all information management component, such as component name, in the MBean server object that uniquely identifies the component name. Then according to the contents of this document, the m-let service to complete the remaining tasks. This process is the instantiation:

2 monitoring services through the use of monitoring service, management component property value will be regular monitoring, which is always in a specific scope. Change when monitoring the attribute value exceeded expectations defined scope, a specific notification will be issued. The current JMX specification defines three monitor:

1) counter monitor, monitor counter type attribute value, usually as integer, and only according to a certain law of increasing.

2) measurement monitor, monitoring measurement type attribute value, usually for real, value can be increased or reduced.

3) string monitor, monitor the string type attribute value. Each monitor is a standard management component, the need to provide services, can be created by management component corresponding or remote management applications dynamically and configuration register.

3 time business hours service can be issued a circular in the formulation of the date and time, can also be periodic regular notice, rely on management application configuration. The time service is also a management component, it can help the management application procedures for the establishment of a configuration of the memorandum, so as to realize intelligent management service.

4 the relationship between service JMX specification defines the relationship model between the management component. A relationship is N dimensional relationship between management component user defined. Relation model is defined as follows:

1) the role of some terms: is is a member of a relationship between the identity, it contains a character value.

2) role information: describe a role in a relationship.

3) relationship types: composed of character information, to create and sustain a relationship as template.

4) relationship: the relationship management among members, and must meet the requirements of a relationship type.

5) role value: in a relationship in the current list management component can satisfy the given role.

6) the relationship between service: is a management component, can contact and maintain consistency between all types of relationship and relationship instances. In the relationship between services, relationship management between components by instance relationship type is determined to maintain. Only registered to the MBean server and can be the name of the object identifier management component can become a member of a relationship. The relationship between service never directly -- management component of it, in order to facilitate the search it only provides the name of the object. The relationship between service can create, locking is not reasonable relationship types similarly, creating unreasonable relations will be locked. Correction role value also should obey the consistency check. Because the relationship is defined between the management component registration contact, so when the management component which is unloaded, will change a relationship. The relationship between service will automatically change

the role value. All the relationship instance operations such as create, update, delete and so on will make the relationship between service issued a notice, notification will provide information about the operation. Only model JMX relationship to ensure management component all meet the design character of it, that is to say, does not permit a management component appears in many relationships at the same time.

Distributed service layer

At present, the SUN and there is no specific norms given this layer, only a brief description is given below.

This layer specifies the implementation of JMX application management platform interface. This layer defines the management interface and component can operate on the agent layer. These components can be:

1) provides an interface for managing application, so it through a connector can be transparent and agent layer or JMX management resources interact.

2) mapping through various protocols (such as SNMP, HTML etc.), provides a JMX agent and all the management component view.

3) distribution management information, in order to construct a distributed system, there will be JMX agent management information management platform to the large number of release.

4) management information collected a number of JMX proxy client and screening are of interest to the user according to the needs of management of user information and the formation of terminal users to the appropriate logical view.

5) provides security assurance.

Through the joint management application layer and a management agent and his equipment layer, can provide a complete network management solutions to our. This solution brings some advantages of the one and only for us: light, according to the needs of the deployment, dynamic services, and security.

The Java Server Pages( JSP) is a kind of according to web of the script plait distance technique, similar carries the script language of Java in the server of the Netscape company of server- side JavaScript( SSJS) and the Active Server Pages(ASP) of the Microsoft. JSP compares the SSJS and ASP to have better can expand sex, and it is no more exclusive than any factory or some one particular server of Web. Though the norm of JSP is to be draw up by the Sun company of, any factory can carry out the JSP on own system.

If Java is, in fact, yet another computer programming language, you may question why it is so important and why it is being promoted as a revolutionary step in computer programming. The answer isn’t immediately obvious if you’re coming from a traditional programming perspective. Although Java is very useful for solving traditional stand-alone programming problems, it is also important because it will solve programming problems on the World Wide Web.

The Web’s initial server-browser design provided for interactive content, but the interactivity was completely provided by the server. The server produced static pages for the client browser, which would simply interpret and display them. Basic HTML contains simple mechanisms for data gathering: text-entry boxes, check boxes, radio boxes, lists and drop-down lists, as well as a button that can only be programmed to reset the data on the form or “submit” the data on the form back to the server.

This submission passes through the Common Gateway Interface (CGI) provided on all Web servers. The text within the submission tells CGI what to do with it. The most common action is to run a program located on the server in a directory that’s typically called “cgi-bin.” (If you watch the address window at the top of your browser when you push a button on a Web page, you can sometimes see “cgi-bin” within all the gobbledygook there.) These programs can be written in most languages. Perl is a common choice because it is designed for text manipulation and is interpreted, so it can be installed on any server regardless of processor or operating system. Many powerful Web sites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI programs can rapidly become overly complicated to maintain, and there is also the problem of response time. The response of a CGI program depends on how much data must be sent, as well as the load on both the server and the Internet. (On top of this, starting a CGI program tends to be slow.)

The initial designers of the Web did not foresee how rapidly this bandwidth would be exhausted for the kinds of applications people developed. For example, any sort of dynamic graphing is nearly impossible to perform with consistency because a GIF file must be created and moved from the server to the client for each version of the graph. And you’ve no doubt had direct experience with something as simple as validating the data on an input form. You press the submit button on a page; the data is shipped back to the server; the server starts a CGI program that discovers an error, formats an HTML page informing you of the error, and then sends the page back to you; you must then back up a page and try again. Not only is this slow, it’s inelegant.

The solution is client-side programming. Most machines that run Web browsers are powerful engines capable of doing vast work, and with the original static HTML approach they are sitting there, just idly waiting for the server to dish up the next page. Client-side programming means that the Web browser is harnessed to do whatever work it can, and the result for the user is a much speedier and more interactive experience at your Web site.  The problem with discussions of client-side programming is that they aren’t very different from discussions of programming in general. The parameters are almost the same, but the platform is different: a Web browser is like a limited operating system. In the end, you must still program, and this accounts for the dizzying array of problems and solutions produced by client-side programming. The rest of this section provides an overview of the issues and approaches in client-side programming.

One of the most significant steps forward in client-side programming is the development of the plug-in. This is a way for a programmer to add new functionality to the browser by downloading a piece of code that plugs itself into the appropriate spot in the browser. It tells the browser “from now on you can perform this new activity.” (You need to download the plug-in only once.) Some fast and powerful behavior is added to browsers via plug-ins, but writing a plug-in is not a trivial task, and isn’t something you’d want to do as part of the process of building a particular site. The value of the plug-in for client-side programming is that it allows an expert programmer to develop a new language and add that language to a browser without the permission of the browser manufacturer. Thus, plug-ins provide a “back door” that allows the creation of new client-side programming languages (although not all languages are implemented as plug-ins).

Plug-ins resulted in an explosion of scripting languages. With a scripting language you embed the source code for your client-side program directly into the HTML page, and the plug-in that interprets that language is automatically activated while the HTML page is being displayed. Scripting languages tend to be reasonably easy to understand and, because they are simply text that is part of an HTML page, they load very quickly as part of the single server hit required to procure that page. The trade-off is that your code is exposed for everyone to see (and steal).

Generally, however, you aren’t doing amazingly sophisticated things with scripting languages so this is not too much of a hardship. This points out that the scripting languages used inside Web browsers are really intended to solve specific types of problems, primarily the creation of richer and more interactive graphical user interfaces (GUIs). However, a scripting language might solve 80 percent of the problems encountered in client-side programming.

Your problems might very well fit completely within that 80 percent, and since scripting languages can allow easier and faster development, you should probably consider a scripting language before looking at a more involved solution such as Java or ActiveX programming. The most commonly discussed browser scripting languages are JavaScript (which has nothing to do with Java; it’s named that way just to grab some of Java’s marketing momentum), VBScript (which looks like Visual Basic), and Tcl/Tk, which comes from the popular cross-platform GUI-building language. There are others out there, and no doubt more in development.

JavaScript is probably the most commonly supported. It comes built into both Netscape Navigator and the Microsoft Internet Explorer (IE). In addition, there are probably more JavaScript books available than there are for the other browser languages, and some tools automatically create pages using JavaScript. However, if you’re already fluent in Visual Basic or Tcl/Tk, you’ll be more productive using those scripting languages rather than learning a new one. (You’ll have your hands full dealing with the Web issues already.

If a scripting language can solve 80 percent of the client-side programming problems, what about the other 20 percent—the “really hard stuff?” The most popular solution today is Java. Not only is it a powerful programming language built to be secure, cross-platform, and international, but Java is being continually extended to provide language features and libraries that elegantly handle problems that are difficult in traditional programming languages, such as multithreading, database access, network programming, and distributed computing. Java allows client-side programming via the applet.

An applet is a mini-program that will run only under a Web browser. The applet is downloaded automatically as part of a Web page (just as, for example, a graphic is automatically downloaded). When the applet is activated it executes a program. This is part of its beauty—it provides you with a way to automatically distribute the client software from the server at the time the user needs the client software, and no sooner. The user gets the latest version of the client software without fail and without difficult reinstallation. Because of the way Java is designed, the programmer needs to create only a single program, and that program automatically works with all computers that have browsers with built-in Java interpreters. (This safely includes the vast majority of machines.) Since Java is a full-fledged programming language, you can do as much work as possible on the client before and after making requests of the server. For example, you won’t need to send a request form across the Internet to discover that you’ve gotten a date or some other parameter wrong, and your client computer can quickly do the work of plotting data instead of waiting for the server to make a plot and ship a graphic image back to you. Not only do you get the immediate win of speed and responsiveness, but the general network traffic and load on servers can be reduced, preventing the entire Internet from slowing down. One advantage a Java applet has over a scripted program is that it’s in compiled form, so the source code isn’t available to the client. On the other hand, a Java applet can be decompiled without too much trouble, but hiding your code is often not an important issue. Two other factors can be important. As you will see later in this book, a compiled Java applet can comprise many modules and take multiple server “hits” (accesses) to download. (In Java 1.1 and higher this is minimized by Java archives, called JAR files, that allow all the required modules to be packaged together and compressed for a single download.)

A scripted program will just be integrated into the Web page as part of its text (and will generally be smaller and reduce server hits). This could be important to the responsiveness of your Web site. Another factor is the all-important learning curve. Regardless of what you’ve heard, Java is not a trivial language to learn. If you’re a Visual Basic programmer, moving to VBScript will be your fastest solution, and since it will probably solve most typical client/server problems you might be hard pressed to justify learning Java. If you’re experienced with a scripting language you will certainly benefit from looking at JavaScript or VBScript before committing to Java, since they might fit your needs handily and you’ll be more productive sooner.to run its applets withi

To some degree, the competitor to Java is Microsoft’s ActiveX, although it takes a completely different approach. ActiveX was originally a Windows-only solution, although it is now being developed via an independent consortium to become cross-platform. Effectively, ActiveX says “if your program connects to its environment just so, it can be dropped into a Web page and run under a browser that supports ActiveX.” (IE directly supports ActiveX and Netscape does so using a plug-in.) Thus, ActiveX does not constrain you to a particular language. If, for example, you’re already an experienced Windows programmer using a language such as C++, Visual Basic, or Borland’s Delphi, you can create ActiveX components with almost no changes to your programming knowledge. ActiveX also provides a path for the use of legacy code in your Web pages.

Automatically downloading and running programs across the Internet can sound like a virus-builder’s dream. ActiveX especially brings up the thorny issue of security in client-side programming. If you click on a Web site, you might automatically download any number of things along with the HTML page: GIF files, script code, compiled Java code, and ActiveX components. Some of these are benign; GIF files can’t do any harm, and scripting languages are generally limited in what they can do. Java was also designed to run its applets within a “sandbox” of safety, which prevents it from writing to disk or accessing memory outside the sandbox.

ActiveX is at the opposite end of the spectrum. Programming with ActiveX is like programming Windows—you can do anything you want. So if you click on a page that downloads an ActiveX component, that component might cause damage to the files on your disk. Of course, programs that you load onto your computer that are not restricted to running inside a Web browser can do the same thing. Viruses downloaded from Bulletin-Board Systems (BBSs) have long been a problem, but the speed of the Internet amplifies the difficulty.

The solution seems to be “digital signatures,” whereby code is verified to show who the author is. This is based on the idea that a virus works because its creator can be anonymous, so if you remove the anonymity individuals will be forced to be responsible for their actions. This seems like a good plan because it allows programs to be much more functional, and I suspect it will eliminate malicious mischief. If, however, a program has an unintentional destructive bug it will still cause problems.

The Java approach is to prevent these problems from occurring, via the sandbox. The Java interpreter that lives on your local Web browser examines the applet for any untoward instructions as the applet is being loaded. In particular, the applet cannot write files to disk or erase files (one of the mainstays of viruses). Applets are generally considered to be safe, and since this is essential for reliable client/server systems, any bugs in the Java language that allow viruses are rapidly repaired. (It’s worth noting that the browser software actually enforces these security restrictions, and some browsers allow you to select different security levels to provide varying degrees of access to your system.) You might be skeptical of this rather draconian restriction against writing files to your local disk. For example, you may want to build a local database or save data for later use offline. The initial vision seemed to be that eventually everyone would get online to do anything important, but that was soon seen to be impractical (although low-cost “Internet appliances” might someday satisfy the needs of a significant segment of users). The solution is the “signed applet” that uses public-key encryption to verify that an applet does indeed come from where it claims it does. A signed applet can still trash your disk, but the theory is that since you can now hold the applet creator accountable they won’t do vicious things. Java provides a framework for digital signatures so that you will eventually be able to allow an applet to step outside the sandbox if necessary. Digital signatures have missed an important issue, which is the speed that people move around on the Internet. If you download a buggy program and it does something untoward, how long will it be before you discover the damage? It could be days or even weeks. By then, how will you track down the program that’s done it? And what good will it do you at that point?

The Web is the most general solution to the client/server problem, so it makes sense that you can use the same technology to solve a subset of the problem, in particular the classic client/server problem within a company. With traditional client/server approaches you have the problem of multiple types of client computers, as well as the difficulty of installing new client software, both of which are handily solved with Web browsers and client-side programming. When Web technology is used for an information network that is restricted to a particular company, it is referred to as an intranet. Intranets provide much greater security than the Internet, since you can physically control access to the servers within your company. In terms of training, it seems that once people understand the general concept of a browser it’s much easier for them to deal with differences in the way pages and applets look, so the learning curve for new kinds of systems seems to be reduced.

The security problem brings us to one of the divisions that seems to be automatically forming in the world of client-side programming. If your program is running on the Internet, you don’t know what platform it will be working under, and you want to be extra careful that you don’t disseminate buggy code. You need something cross-platform and secure, like a scripting language or Java.

If you’re running on an intranet, you might have a different set of constraints. It’s not uncommon that your machines could all be Intel/Windows platforms. On an intranet, you’re responsible for the quality of your own code and can repair bugs when they’re discovered. In addition, you might already have a body of legacy code that you’ve been using in a more traditional client/server approach, whereby you must physically install client programs every time you do an upgrade. The time wasted in installing upgrades is the most compelling reason to move to browsers, because upgrades are invisible and automatic. If you are involved in such an intranet, the most sensible approach to take is the shortest path that allows you to use your existing code base, rather than trying to recode your programs in a new language.

When faced with this bewildering array of solutions to the client-side programming problem, the best plan of attack is a cost-benefit analysis. Consider the constraints of your problem and what would be the shortest path to your solution. Since client-side programming is still programming, it’s always a good idea to take the fastest development approach for your particular situation. This is an aggressive stance to prepare for inevitable encounters with the problems of program development.

This whole discussion has ignored the issue of server-side programming. What happens when you make a request of a server? Most of the time the request is simply “send me this file.” Your browser then interprets the file in some appropriate fashion: as an HTML page, a graphic image, a Java applet, a script program, etc. A more complicated request to a server generally involves a database transaction. A common scenario involves a request for a complex database search, which the server then formats into an HTML page and sends to you as the result. (Of course, if the client has more intelligence via Java or a scripting language, the raw data can be sent and formatted at the client end, which will be faster and less load on the server.) Or you might want to register your name in a database when you join a group or place an order, which will involve changes to that database. These database requests must be processed via some code on the server side, which is generally referred to as server-side programming. Traditionally, server-side programming has been performed using Perl and CGI scripts, but more sophisticated systems have been appearing. These include Java-based Web servers that allow you to perform all your server-side programming in Java by writing what are called servlets. Servlets and their offspring, JSPs, are two of the most compelling reasons that companies who develop Web sites are moving to Java, especially because they eliminate the problems of dealing with differently abled browsers.

Much of the brouhaha over Java has been over applets. Java is actually a general-purpose programming language that can solve any type of problem—at least in theory. And as pointed out previously, there might be more effective ways to solve most client/server problems. When you move out of the applet arena (and simultaneously release the restrictions, such as the one against writing to disk) you enter the world of general-purpose applications that run standalone, without a Web browser, just like any ordinary program does. Here, Java’s strength is not only in its portability, but also its programmability. As you’ll see throughout this book, Java has many features that allow you to create robust programs in a shorter period than with previous programming languages. Be aware that this is a mixed blessing. You pay for the improvements through slower execution speed (although there is significant work going on in this area—JDK 1.3, in particular, introduces the so-called “hotspot” performance improvements). Like any language, Java has built-in limitations that might make it inappropriate to solve certain types of programming problems. Java is a rapidly evolving language, however, and as each new release comes out it becomes more and more attractive for solving larger sets of problems.

All programming languages provide abstractions. It can be argued that the complexity of the problems you’re able to solve is directly related to the kind and quality of abstraction. By “kind” I mean, “What is it that you are abstracting?” Assembly language is a small abstraction of the underlying machine. Many so-called “imperative” languages that followed (such as FORTRAN, BASIC, and C) were abstractions of assembly language. These languages are big improvements over assembly language, but their primary abstraction still requires you to think in terms of the structure of the computer rather than the structure of the problem you are trying to solve. The programmer must establish the association between the machine model (in the “solution space,” which is the place where you’re modeling that problem, such as a computer) and the model of the problem that is actually being solved (in the “problem space,” which is the place where the problem exists). The effort required to perform this mapping, and the fact that it is extrinsic to the programming language, produces programs that are difficult to write and expensive to maintain, and as a side effect created the entire “programming methods” industry.

The alternative to modeling the machine is to model the problem you’re trying to solve. Early languages such as LISP and APL chose particular views of the world (“All problems are ultimately lists” or “All problems are algorithmic,” respectively). PROLOG casts all problems into chains of decisions. Languages have been created for constraint-based programming and for programming exclusively by manipulating graphical symbols. (The latter proved to be too restrictive.) Each of these approaches is a good solution to the particular class of problem they’re designed to solve, but when you step outside of that domain they become awkward.

The object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space. This representation is general enough that the programmer is not constrained to any particular type of problem. We refer to the elements in the problem space and their representations in the solution space as “objects.” (You will also need other objects that don’t have problem-space analogs.) The idea is that the program is allowed to adapt itself to the lingo of the problem by adding new types of objects, so when you read the code describing the solution, you’re reading words that also express the problem. This is a more flexible and powerful language abstraction than what we’ve had before. Thus, OOP allows you to describe the problem in terms of the problem, rather than in terms of the computer where the solution will run. There’s still a connection back to the computer: each object looks quite a bit like a little computer—it has a state, and it has operations that you can ask it to perform. However, this doesn’t seem like such a bad analogy to objects in the real world—they all have characteristics and behaviors.

Alan Kay summarized five basic characteristics of Smalltalk, the first successful object-oriented language and one of the languages upon which Java is based. These characteristics represent a pure approach to object-oriented programming:

1. Everything is an object. Think of an object as a fancy variable; it stores data, but you ca   全套毕业设计论文现成成品资料请咨询微信号:biyezuopin QQ:2922748026     返回首页 如转载请注明来源于www.biyezuopin.vip  

                 

打印本页 | 关闭窗口
本类最新文章
Mechatronics and Influence Resear DEPRESSION DETEC
Facial Expressio DEPRESSION DETEC Visually Interpr
| 关于我们 | 友情链接 | 毕业设计招聘 |

Email:biyeshejiba@163.com 微信号:biyezuopin QQ:2922748026  
本站毕业设计毕业论文资料均属原创者所有,仅供学习交流之用,请勿转载并做其他非法用途.如有侵犯您的版权有损您的利益,请联系我们会立即改正或删除有关内容!