基于web的商场餐饮管理系统设计与实现old外文翻译_第1页
基于web的商场餐饮管理系统设计与实现old外文翻译_第2页
基于web的商场餐饮管理系统设计与实现old外文翻译_第3页
基于web的商场餐饮管理系统设计与实现old外文翻译_第4页
基于web的商场餐饮管理系统设计与实现old外文翻译_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、From:Thinking in java Author:Bruce EckelIf Java is, in fact, yet another computrogramming language, you mayquestion why it is so important and why it is being promoted asay.revolutionary st obvious if youre Although Java isn computrogramming. The answer isnt immediacoming from a traditional programm

2、ing very useful for solving traditionalstand-alone will solveprogramming problems, it is also important because it programming problems on the World Wide Web.1. C provided provided browser, containsnt-side programmingThe Webs initial server-browser designfor by the whichsimpleeractive content, serve

3、r. The serv would simplybut theeractivity was compley ntroduced sic pages for the cret and display them. Basic HTMLmechanisms for data gathering: text-entry boxes, checkboxes, radio boxes, lists and drop-down lists, as well as a buttont the thecan only be programmed to reset the data data on the for

4、m back to the server. Thi Common Gatewayerface (CGI) providedon the form or “submit”bmispasses throughon all Web servers. The textwithhe submisls CGI what to do with it. The most common actionis to run a program located on the server in a directoryts typically called “cgi-bin.” (If you watch the add

5、ress window at the top of yourbrowser when you push a button on a Wge, you can sometimes see“cgi-bin” within all the gobbledygook there.) These programs can bewrittenost languages. Perl is a common choice because it is designedfor text manipulation and isreted, so it can be installed on anyserver re

6、gardless of prosor or operating system. Manyerful Websites today are built strictly on CGI, and you can in fact do nearly anything with it. However, Web sites built on CGI programs can ralye overly complicated to maain, and there is also the problem ofresponse time. The response of a CGI program dep

7、ends on how much data mustbe sent, as well as the load on both the server and theernet. (On topof this, starting a CGI program tends to be slow.) The initial designersof the Web did not foresee how raly this bandwidth would be exhaustedfor the kinds of applications people developed. For exle, any so

8、rt ofdynamic graphing is nearly imsible to perform with consistency becausea GIF file must be created and moved from theserver to the cnt foreach verof the graph. And youve no doubd direct experience withan input form. You presssomething as simple as validating the data onthe submit button on a page

9、; the data is shipped back to the server; theserver starts a CGI programt discovers an error, formats an HTML pageinforming you of the error, and then sends the page back to you; you mustthen back up a page and try again. Not only is this slow, its inelegant.Java and theernetThe solution is cnt-side

10、 programming. Most machinest run Webbrowsers areerful engines capable ofng vast work, and with theoriginal sic HTML approach they are sitting there, just idly waitingfor the server to dish up the next page. Cnt-side programming meanst the Web browser is harnessed to do whatever work it can, and the

11、result for the user is a much speedier and moreeractive experience at yourWeb site. The problem with discuss of cnt-side programming ist they arent very different from discuss of programming ingeneral. The parameters are almost the same, but the platform is different:a Web browser is like a limited

12、operating system.he end, you muststill program, and this accounts for the dizzying array of problems andsolutions produced by cnt-side programming. The rest of this sectionprovides an overview of the i programming.es and approaches in cnt-side2.Plug-insOne of the most significant steps forward in cn

13、t-sideprogramming is the development of the plug-in. This is a way for a programmer to add new functionality to the browser by downloading a pieceof codet plugs itselfo the appropriate spothe browser. Itls the browser “from now on you canperform this new activity.” (Youneed to download the plug-in o

14、nly once.) Some fast anderful behavioris added to browsers via plug-ins, but writing a plug-in is notask, and isnt something youd want to do as part of the prorivials ofbuilding a particular site. The value of the plug-in for cnt-sideprogramming is language and addt it allows an expert programmer to

15、 develop a newt language to a browser without the permisof thet allowsbrowser manufacturer. Thus, plug-ins provide a “back door”the creation of new cnt-side programming languages (although not alllanguages are implemented as plug-ins).3.Scripting languagesPlug-ins resulted in an exploofscripting lan

16、guages. Wiscripting language you embed the source codefor your cnt-side program directlyo the HTML page, and the plug-int page isretst language is automatically activated while the HTMLbeing displayed. Scripting languages tend to be reasonably easyto understand and, because they are simply textt is

17、part of an HTMLpage, they load very quickly as part of the single server hit requiredto procuret page. The trade-off ist your code is exedfor ng noteveryone to see (and steal). amazingly sophisticated things too much of a hardship. This poGenerally, however, you arentwith scripting languages so this

18、 iss outt the scripting languages usedinside Web browsers are reallyended to solve specific types ofproblems, primarily the creation of richer and moreeractive graphicalusererfa(GUIs). However, a scripting language might solve 80 percent of the problems encountered in cnt-side programming. Yourprobl

19、ems might very well fit compley withhat 80 percent, and sincescripting languages clow easier and faster development, you shouldprobably consider a scripting language before looking at a more involvedsolution such as Java or ActiveX programming.The most commonlydiscussed browser scripting languages a

20、re JavaScript (which has nothingto do with Java; its namedt way just to grab some of Javas marketingmomentum), VBScript (which looks like Visual Basic), and 4Tcl/Tk, which comes from the popular cross-platform GUI-building language. There areothers out there, and no doubt more in development. probab

21、ly the most commonly supported. It comes builtJavaScript is o both Netsc addition, thereNavigator and theernet Explorer (IE). Inare probably more JavaScript books availablen there are for the otherbrowser languages, and some tools automatically create pages usingJavaScript. However, if youre already

22、 fluent in Visual Basic or Tcl/Tk,youll be more productive using those scripting languages rather learning a new one. (Youll have your hands full dealing with then Webies already.)4.JavaIf a scripting language can solve 80 percent ofthecnt-side programming problems, what about the other 20 percentth

23、e“really hard stuff?” The most popular solution today is Java. Not onlyis it aerful programming language built to be secure, cross-platform,andernational, but Java is being continually extended to providelanguage features and librariesegantly handle problemst aredifficult database ac allows craditio

24、nal programming languages, such as multithreading,s, network programming, and nt-side programming via thedistributed computing. Javaapplet.An applet is amini-programt will run only under aWeb browser. The applet isdownloaded automatically as part of a Wge (just as, forexle, agraphic is automatically

25、 downloaded). When the applet i executes a program. This is part of its beautyit providesivated it you wiway to automatically distribute the cnt software from the server atthe time the user needs the cnt software, and no sooner. The user getsthe latest verof the cnt software withoutfail and without

26、is designed, thedifficult reinstallation. Because of the programmer needs to create only a singleway Java program,andt programautomatically works will computersve browsers with built-inJavareters. (This safely includes the vast majority of machines.)Since Java is a full-fledged programming language,

27、 you can do as much workassible on the cnt before and after making requests of theserver.For exle, you wont need to send a request form across theernetto discovert youve gotten a date or some otharameter wrong, andyour c nt computer can quickly do the work of plotting data instead of waiting for the

28、 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 teral network traffic and load on servers can be reduced,preventing the entireernet from slowing down.One advantage a Javaapple source applets over a scripted program is

29、t its in compiled form, so thecode isnt available to the cnt. On the other hand, a Javacan bepiled without too much trouble, but hiding your codeis often not an important ie. Two other factors can be important. Asyou will see laterhis book, a compiled Java applet can comprise manymodules and take mu

30、ltiple server “hits” (acses) to download. (In Java1.1 and higher this is minimized by Java archives, called JAR files,tallow all the required modules to be packaged together and compressed for a single download.) A scripted program will just beegratedo theWge as part of its text (and will generally

31、be smaller and reduceserver hits). This could be important to the responsiveness of your Web site. Another factor is the all-important learning curve. Regardless ofwhat youve heard, Java is norivial language to learn. If yourea Visual Basic programmer, moving to VBScript will be your fastest solutio

32、n, and since it will probably solve most typical c nt/server problems you might be hard pressed to justify learning Java. If youreexperienced wiscripting language you will certainly benefit fromlooking at JavaScript or VBScript before committing to Java, since they might fit your needs handily and y

33、oull be more productive sooner.to run its applets with.5.ActiveXTo some degree, the competitor to Java issActiveX, although it takes a comple originally a Windows-only solution, via an independent consortium toy different approach. ActiveX was although it is now being developed e cross-platform. Eff

34、ectively,ActiveX says “if your program connects to 6ivironment just so,it can be droppedo a Wge and run under a browsert supportsActiveX.” (IE directly supportiveX and Netscdoes so using aplug-in.) Thus, ActiveX does not constrain you to a particular language.If, for exle, youre already an experienc

35、ed Windows programmer usinga language such as C+, Visual Basic, or Borlands Delphi, you can createActiveX components wilmost no changes to your programming knowledge.ActiveX also provides a path for the use of legacy code in your Wges.6.SecurityAutomatically downloading and running programs acrossth

36、eernet can sound like a-builders dream. ActiveX espellybrings up the thorny ie of security in cnt-side programming. If youclick 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 t

37、hese are benign; GIF files cant 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, whichprevents it from writing to disk or acsing memory outside the sandbox.ActiveX is at the opite end of the spectr

38、um. Programming wictiveXis like programming Windowsyou can do anything you want. So if you clickon a paget downloads an ActiveX component,t component might causedamage to the files on your disk. Of course, programst you load ontoyour computert are not restricted to running inside a Web browser cando

39、 the same thing.es downloaded from Bulletin-Board Systems (s)have long been a problem, but the speed of theernetlifies thedifficulty.The solution seems to be “digital signatures,” wherebycode is verified to show who the author is. This is based on the ideataworks because its creator can be anonymous

40、, so if you remove theanonymity individuals will be forced to be responsible for their actions. This seems like a good plan because it allows programs to be muorefunctional, and I however, a program has an unit will eliminate malicious mischief. If, entional destructive bugit will still causeproblem

41、s.The Java approach is to prevent these problems from occurring,via the sandbox. The Javaretert lives on your local Web browserexamines 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 ofe

42、s). Applets are generally considered tobe safe, and since this is essential for reliable cnt/server systems,any bugshe Java languaget allowes are raly repaired.(Its worth notingt the browser software actually enforthesesecurity restrictions, and some browsers allow you to select differentsecurity le

43、vels to provide varying degrees of acs to your system.) Youmight be skeptical of this rather draconian restriction against writing files to your local disk. For exle, you may want to build a localdatabase or save data for later use offline. The initial viseemedto be butt eventually everyould get onl

44、ine to do anything important,t was soon seen to be impractical (although low-cost “ernetapplian” might someday satisfy the needs of a significant segment ofusers). The solution is the “signed applet”t uses public-keyencryption to verifyt an applet doescome from where it claimsit does. A signed apple

45、t can still trash your disk, but the theory is since you can now hold the applet creator accountable they wont vicious things. Java provides a framework for digital signatures sot do tyou will eventually be able to allow an applet to step outside the sandbox if nesary. Digital signatures have missed

46、 an important ie, whichis the speedt people move around on theernet. If you download abuggy program and it does something untoward, how long will it be beforeyou discover the damage? It could be days or evenks. By then, how willyou track down the programts done it? And what good will it do youatt po

47、?7.ernet vs.ranetThe Web is the most general solution to thecnt/serverproblem, so it makes senset you can use the sametechnology tosolve a subset of the problem, in particular the classiccnt/serverproblemwithinacompany.Withtraditional8cnt/server approaches you have the problem of multiple types of c

48、ntcomputers, as well as the difficulty of installing new cnt software,both of which are handily solved with Web browsers and cnt-sideprogramming. When Web technology is used for an information networktis restricted to a particular company, it is referred to as anranet. ranets provide much greater se

49、curityn theernet, since you canphysically control ac of training, it seemss to the servers within your company.ermst once people understand teral concept ofa browser its much easier for them to deal with differenhe waypages seems diviand applets look, so the learning curve for new kinds of systems t

50、o be reduced. The security problem brings us to one of thest seems to be automatically forming in the world ofcnt-side programming. If your program is running on theernet, youdont know what platform it will be working under, and you want to be extra carefult you dont disseminate buggy code. You need

51、 somethingcross-platform and secure, like a scripting language or Java.If of beyoure running on anranet,monOn anyou might have a different set t your machines could allconstras. Its notel/Windows platforms.ranet, youre responsible for thequality of your own code and can repair bugs when theyre disco

52、vered.In addition, you might already have a body of legacy codet youvebeen using in a more traditional cnt/server approach, whereby you mustphysically install cnt programs every time you do an upgrade. The time wasted in installing upgrades is the most compelling reason to move tobrowsers, because u

53、pgrades are invisible and automatic. If youare theninvolved in such anranet, the mossible approach to take isshortest patht allows you to use your existing code base, rathertrying to recode your programs in a new language.When faced with this programming problem, ysis. Consider thebewildering array

54、of solutions to the cnt-sidethe best constra solution.plan of attack is a cost-benefits of your problem and what would be the shortest path to your Since cnt-side programming is still programming, itsalways a good idea to take the fastest development approach for your particular situation. This is a

55、n aggressive stance to prepare for inevitable encounters with the problems of program development.8.Server-side programmingThis whole discushas ignored theie of server-side programming. Whappens when you make a requestof a server? Most of the time the request is simply “send me this file.”Your brows

56、er thenrets the file in some appropriate fashion: as anHTML page, a graphic image, a Java applet, a script program, etc. A morecomplicated request to a server generally involves a database tranion.A common scenario involves a request for a complex database search, whichthe server then formats (Of co

57、urse, if the co an HTML page and sends to you as the result.ns moreelligence via Java or a scriptinglanguage, the raw dan be sent and formatted at the cnt end, whichwill be faster and less load on the server.) Or you might want to registeryour will proname in a database when you join a group or plac

58、e an order, whichinvolve changes tot database. These database requests must besed via some code on the server side, which is generally referredto as server-side programming. Traditionally, server-side programming has been performed using Perl and CGI scripts, but more sophisticatedsystems have been

59、appearing. These include Java-based Web serverstallow you to perform all your server-side programming in Java by writing what are called servlets. Servlets and their offspring, JSPs, are two ofthe most compelling reasonst companies who develop Web sites aremoving to Java, espelly because they elimin

60、ate the problems of dealingwith differently abled browsers.9. separate arena: applicationsMuch of the brouhaha over Java hasbeen over applets. Java is actually a general-pure programming heory. And as ways to solvelanguaget can solve any type of problemeastpoed out previously, there might be more ef

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论