《外文翻译-Ajax的应用.docx》由会员分享,可在线阅读,更多相关《外文翻译-Ajax的应用.docx(9页珍藏版)》请在三一办公上搜索。
1、附录1TheapplicationofAjaxSpendafewminutesusingyourapplicationyouselected(browserexcept),writeitdowntowhatuserinteraction,andthenimmediatelyback.Forthesakeofbrevity,Igiveanexampleofelectronicform,however,pointsinvolvedhereisgeneralenoughforvariouscases,thetexteditor.Well,westarted.Firstinthespreadsheet
2、toinputsomeequalities,payattentionto,caninteractinseveralways:editdata,browsingthedatausingthekeyboardandmouse,alsocanusethemousetodragtoreorganizethedata.Idotheseoperations,theprogramgavemefeedback.Whenmovingthemouse,thecursorchangesshape;whenthemousestopsabove,buttonbright;selectedtextcanchangecol
3、or.Whenawindowordialogboxisselected,andusuallyisnotthesame,etc.Thesearetheso-calledrichuinteraction.Ofcourse,therearestillsomeroomforimprovement,butthisisagoodstart.OK,aspreadsheetisarichclientprogram7Absolutelynot.Inaspreadsheetorsimilardesktopapplications,businesslogicanddatamodelisruninaclosedenv
4、ironment.Inthisenvironment,theyclearlyunderstandeachother,andcanvisiteachother,andtheenvironmentoutsideofthings,isunknowntothem.Whatistheclient?Itisaseparateprocessofmutualcommunicationprogram,whichisusuallyrunontheserver.Ingeneral,theserverisalwaysbiggerthantheclient,ability,dispositionisbetter,bec
5、ausetheserverisusuallystoredmultitudeinformation.Theclientprogramenablestheenduserscanviewandmodifytheinformation,whenmultipleclientsconnectedtothesameserver,canshareinformationbetweenthem.Showsasimpleclient/serverarchitecture.Inthenlayerarchitectureinthemodem,theserveroftenandfurthertheback-endserv
6、er(suchasadatabase)communication,soCallednIniddlewarenIayeralsoplaysaroleofclientandserver.EndofourAjaxapplicationinthechain,itisonlyastheclient,therefore,fortheconvenienceofdiscussion,wecanpulthewholensystemasalabeledasblackboxserver.SpreadsheetapplicationsIonlyneedtomanageitsownsavedasmallamountof
7、datainmemoryorinthelocalfilesystem.Ifthedesignofwellstructure,couplingformdataanditcanbeveryloose,butIcan,tpassanetworktosplitorSharethemthroughnetwork.Inthissense,theapplicationofelectronicformisnotaclient.ThecorrespondingWebbrowserisatypicalclient,whichcommunicatewiththeWebserver,therequestpage.Th
8、ebrowserhasabundantfunctions,usedtomanageuserbrowsingbehavior,thecommonfunctionofthebackbutton,thehistorylistandtabbedbrowsingmultipledocumentsetc.ButwhenweputthesitespecificWebpagesasanapplication,thesegeneralbrowsingfunctionactuallyandapplicationis,atbest,suchasspreadsheetsandWindowsbegantherelati
9、onshipbetweenbuttonorthewindowlist.WeconsidertheapplicationofmodernWeb.Forthesakeofsimplicity,wechoseAearthpeopleknowonlinebookstore.OpentheAmazonsiteinthebrowser,becausebeforeIvisited,itwillshowmeafriendlygreeting,Somerecommendedbibliography,andmypurchasehistoryinformation.Clickonanyoneoftherecomme
10、ndedbibliography,willgotoanotherpage(atthistime,thepagetorefresh,withinafewsecondsIwhatalsodontsee).Thenewpageistheinformationrelevanttothebookreview:otherbooks,second-handbooks,offerthesameauthor,andotherbooksIread.Inshort,appearstobeveryrich,highdegreeofassociatedinformationinfrontofme.Butforme,in
11、teractivewayistoclickonthehyperlink,andthenfillinsomeforms.Suppose1atthekeyboardaccidentallyfellasleep,wakeupseconddays,ifnotrefreshthepage,IdontknowuHarryPorterseriesofbookshavebeenpublished,norwillmylistfromonepagetoanotherpage,ifIwanttoseemorethingstoo,becauseIcannotchangethelocalcontentareapages
12、ize.IseemtobeinthecriticismoftheAmazoninterface,butitisnotthecase,Ijusttookitasanexample.Infact,inthetraditionalWebdevelopmentoftheshackles,theyhavedoneverywell.Butcomparedtothespreadsheet,andtheinteractionmodelisundoubtedlytoolimited.WhyWebistheapplicationofmodemstillhavesomanyIimitationsTThecurren
13、tsituationhassomereasonabletechnicalreasons,wehavetoconsidernow.TheblueprintfortheInternetisallthecomputerintheworldareconnected,formingahugecomputingresources.Ifthelocaldataandremoteinvocationequated,thenboththeanalysisofproteincomponentsorcracksignalsfromouterspace,usersneednotconsiderthephysicall
14、ocationofthemachines,therestofthecomputationonlypleasure.Butunfortunately,thelocalcallandremoteinvocationissomethingtotallydifferent.Underthecurrentleveloftechnology,thenetworkcommunicationisstillacostlythings(thatistosay,isusuallyveryslow,butunreliable).Intheabsenceofanetworkcalledthesituation,meth
15、odandfunctionofdifferentdataandtheiroperationsarelocatedinthesamelocalmemory,totransferdataandreturntheresultsobtainedareverydirect.Inaremotecall,communicationinthenetworkatbothendsofthetwosidestosendandreceivedatarequiresalotofcomputationatthebottom.Comparedwiththedatabackandforthontheline,thesecal
16、culationsrequiremoretimeconsuming.Thetransmissionofabinarydata,togothroughmanystepsofcodinganddecoding,errorchecking,failure,packetretransmissionsplitandreorganization,dataintoOand1binarysignal,throughtheline(orwirelessconnectiontotheotherparty).Inthelocal,callthefunctioncallrequestisencodedasanobje
17、ct,thentheobjectisserializedasaseriesofbytes,theapplicationlayerprotocol(usuallyHTTP)viathephysicaltransmissionmedium(suchascoppercable,opticalfiberorradio)sendout.Ontheremotemachine,theapplicationlayerprotocoldecoding,thebytedeserializethedataobtained,tocreateacopyoftherequestedobject.Thenthedatamo
18、delisappliedtotheobjectandgeneratesaresponseobject.Inordertomaketheresponseobjectispassedtothecallbackfunctionlocal,allserializationdeserializationoperation,andthetransportlayerwillbebackagain.Finally,theresponseobjectispassedtothefunctioncalllocal.Thisinteractiveprocessisverycomplex,butfortunately,
19、itcanbedone.Modernprogrammingenvironmentssuchas.NETJavaandMicrosoftframeworkarebuiltwiththisability.However,theexecutionofremotecalls,alltheseoperationswillstillbeintheinternalexecution.IfWewereusingtheremoteinvocation,performancewillbeaffected.Thatistosay,aremotecallisunlikelytohaveefficiencyandloc
20、alcall.Whatisworse,theinstabilityofnetworkmakestheefficiencylossisunpredictable,itisdifficultto.Incontrast,alocalcalltorunonthelocalmemory,willundoubtedlyhaveanadvantagemoreatthispoint.Andsoon,saidremotecallhalfaday,betweenthisandtheavailabilityofsoftware?Theansweris,arelationship.Asuccessfulcompute
21、ruserinterfacemustbeabletoatleastlevelsimulationWeexperienceintherealworld.Oneofthebasicrulesofinteractionis,whenwepush,prickorpokeaboutsomething,itwillimmediatelyresponse.Responsetimeaslongasalittlebitoutalittle,willmakepeopleconfused,distracted,toshiftthefocusfromthetaskathandtotheuserinterface.Re
22、motecallsacrossthenetwork,needtoperformadditionaloperationsingreatquantities,theytendtoputthesystemtoslowdown,theuserperceiveddelay.Indesktopapplications,onlywhentheusabilitydesignisverybad,willappearthiskindofmakesusersfeelfullofbug,unresponsivetotheuserinterface,butintheapplicationofnetwork,whatdo
23、notgetalargenumberofsuchinterface.Becausethenetworkdelayisunpredictable,thiskindofinterfaceproblemsoftencomeandgolikeashadow,itisdifficulttocarryouttheapplicationresponsetest.Inotherwords,thenetworkdelayistheresultofacommoncauseofthepracticalapplicationoftheinteraction.Userinterfacedevelopersfornetw
24、orkdelaycanonlyassumetheworst.Saysimply,istotrytomaketheuserinterfaceandnetworkactivitiesunrelatedto.Programmershavealreadycreatedatrulyeffectiveandprovensolutions,tosolvethisproblem.TosellaGuan,letusintotherealworld.InthemorningIwilldo,averyimportantistowakemykidsgotoschool.Icanstandontheedgeoftheb
25、edtheytossup,chasethemupanddressed,butthismethodisverytimeconsuming,ittakesmealotofpreciousmorningtimeIwanttowakeupthechildren,havealookoutthewindow,oftenneglectedtofeedthecat.Afterthechildrenwouldaskmetobreakfast.Astheserverprocess,thechildrenalwaysgetupslowly.IfIfollowthesynchronousinteractionpatt
26、ern,willtheyallday.However,aslongastheymumbleIwokeup,Icangotodootherthings,needtocomebackwhentheyhavealook.Incomputerterms,Ineedtodoisforeverychildtoestablishanasynchronousprocessinaseparatethread.Afterthestart,thechildrenwillwakeupintheirownthreads,theparentthreadunnecessarysynchronizationwait,they
27、afterwardswillinformme(whichisoftenaskedmetoeat).Intheprocesstheywakeup,Idontneedinteractionandthey,whentheyhadbeenupanddressedmyself,becauseIhavereasontobelievethattheywilldososoon.Foranyuserinterface,whichisalongestablishedpractice,namelytoCreateasynchronousthread,letitinthebackgroundwhoneedtocalc
28、ulatealongtimetask,sothattheusercancontinuetodootherthings.Whenstartingthisthread,itisnecessarytoblocktheuseroperation,butafterashortperiodoftimecanbeaccepted,willrelievecongestion.Becauseoftheexistenceofnetworkdelay,usingasynchronousmodeisagoodpracticetohandleanytime-consumingremotecall.Infact,then
29、etworklatencyproblemsandsolutionsrelatedtolong-standing.lntheoldclient/servermode,whenthepoordesignoftheclientprogrammetthehighloadoftheserver,theuserinterfacewillappeardelayintolerable.EvenintodaysInternetera,whentoswitchthepage,ifthebrowserhalfthethingsnotto,sothissituationmightbeduetonetworkdelay
30、causedby.Theexistingtechnicalconditions,wehavenowaytoremovethenetworkdelay,butatleastonestrategy,thatistheuseofasynchronousprocessingremotecalls,isn,tit?Worse,forWebdeveloperstodosothereisaproblem:HTTPprotocolisa,requestresponse1modeoftheprotocol.Thatistosay,theclientrequestsadocument,theserverorare
31、turntothisdocumentortelltheclientcannotfindthedocumentorallowsaclienttoanotherplacetofind,alsocantellwhichtheclientcanusethelocalcache,andsoon.Tomakealongstoryshort,requestresponseumodeoftheprotocolisaone-waycommunicationprotocol.Theclientinitiatesaconnectiontotheserver,buttheservercannotinitiatesac
32、onnectiontotheclient.EvenwhenthenextClientjnitiatethecommunicationrequest,forgetfuloftheservercantrememberthisclientiswho(HTTPisaconnectionless).MostWebdeveloperstousemodemprogramminglanguage,forexample,Java,PHPo*.NET,theyarefamiliarwiththeusersession(usersession)concept,thisisinfacttheapplicationse
33、rverforaremedycantmaintainaconnectionstateoftheHTTPprotocol.HTTPfortheinitialdesigngoalwell,usingsomecleverprocessing,itcanadapttothebeginningofthedesigndidnotconsidertheoccasion.Butthekeyfeaturesoftheasynchronouscallbackschemeofourclientis,willreceivetwonotice,isatimeinthethreadcreation,theotherisa
34、timeintheendofthethread.ThestandardHTTPandthetraditionalWebapplicationmodelcannotprovidethese.ThetraditionalWebapplicationlikeAmazon,isbuiltontheconceptofthepage.Showtheuseradocument,whichincludesvariouslinksandform,theusercanaccessfurthermoredocumentation.Thisinteractionmodelcansupportcomplexdatase
35、tsonalargescale(likeAmazonandothersiteshavedemonstrated),whichprovidestheuserexperienceisenoughtomeettheneedsofbusiness.Intenyears,thisinteractionmodellaidadeepimprintinourviewoftheapplicationofInternetbusiness.WYSIWYGinterface(WYSIWYG)Webauthoringtools,makingthesitemoreeasilytobeunderstoodasastacko
36、fpages.TheframeworkofWebserverusingthestatediagramconversiononthepagemodeling.nointroduction,thetraditionalWebapplicationthathasbeenfirmlyboundinapagerefreshoperation,asiftherefreshisbehooveandinevitable,triedprocessingschemeforanyasynchronousnever.Ofcourse,nodoubt,thetraditionalWebapplicationmustno
37、tnothingisright.Afterall,Amazoninthisinteractionmodeltocreateasuccessfulcommercialapplications.ButthisappliestothewayAmazondoesnotnecessarilyapplytoallpeople.Whydoyousaythat?Tounderstandthis,weneedtostudytheusermodel(usagepattern).AgeneraldiscussionofthebicycleandSUV(SUV)meritsmeaningless.Becausethe
38、yhavetheirownadvantagesanddisadvantages-comfort,speed,fuelconsumptionorpersonalidentity.Onlydiscussedinparticularusemode,thiscomparisonisonlymeaningful.Forexample,istointherushhourthroughthecenterofthecity,ortotakethewholefamily,oldandyoungtogoonvacation,orjusttofindashelterfromtherain.Inasimilarsit
39、uationlikethis,canwehaveadefiniteobjectinviewtocompare.Fortheuserinterface,itisthesamewith.SoftwareusabilityexpertAlanCooperhaswrittenalotofgoodarticlesaboutusagepatterns,hedefinestwomainuses:transient(transient)andexclusive(sovereign).Transientapplicationsmayuseoccasionallyeveryday,butalwaysasaseco
40、ndaryactivity,withasudden.Thecontrastissovereignapplications,exclusivecontinueduseofapplicationtodealwiththeuserforseveralhoursaday.Manyapplicationshaveanaturalmonopolyortransientproperties.Forexample,awordprocessingsoftwarewritingisasovereignapplication,possibleapplicationsalsouseseveraltransient,s
41、uchasfilemanagement(fileopenandembedthisfunctionwilloftenclosethewindow),dictionaryorspellcheckingtools(manywordprocessingprogramisalsoembeddedinthesefunctions),andcolleaguescontactemailandchattool.Forsoftwaredevelopers,texteditor,debuggerorIDE(integrateddevelopmentenvironment)istheexclusive.Soverei
42、gnapplicationsoftenusemorefrequently.Youknow,agooduserinterfaceisnotvisible.Themeasureofagoodscaleusedfrequently,iswhentheuserinterfacehasobviouspause,itaffectstheuserprocess.Forexample,fromadirectorytoanotherdirectoryfileto2secondpause,!canacceptwithpleasure;butifthetwosecondsistheplaceinmyisfullof
43、passionforpaintingsoftwaretocreateanimage,ormtryingtodebugaverydifficulttodealwiththegenerationofcodecertainly,thismakesmefeelveryuncomfortable.Amazonisatransientapplication,eBay,GoogleandmostlargepublicWebapplicationsaretransientapplications.Sincethedateofbirth,theexpertshadpredictedthatthetraditio
44、naldesktopapplicationsunderWebimpact.Overthepasttenyears,thesehavenotoccurred,why7BasedontheWebpageprogramfortransientapplicationsisenough,butitisfarfromenoughforasovereignapplication.ThestartingofmodernWebbrowsersanditsoriginalpoint(adocumentfromaremoteserver)hasnotmatter,betweenthemlikeaSwissArmyk
45、nifeandneolithichuntingtools,itisaworldofdifference.Avarietyofinteractivecomponents,scriptsandplug-ins,theseyearscouldnotsuppressthecrazydevelopment,almostforcedonceagaintocreateanewbrowsingexperience.toprehistorictimesVisitbrowsenIn1993,netscapefoundedbeforetheMarcAndreessen(founderofnetscape)arelo
46、bbyingTimBemers-Lee(founderofWeb,theW3Cleader)etal.,citedgoodintoapicturelabelisHTML.Afewyearsago,afewpioneersbegantotreatJavaScriptasaseriousprogramminglanguage.Butonthewhole,morepeoplestilluseitandthosewhomockwarningboxmonkeytricksandclicktowinawardsadvertisingaClasstogether.ThebrowserwarsbroughtJ
47、avaScriptamisunderstood,sickchildren,Ajaxcanbeviewedashisrehabilitationcenter.Aslongastheproperguidance,andthentoframeitwithappropriate,JavaScriptwilllikelybecometheInternetmodelcitizen.ltcanreallyenhancethepracticabilityofWebapplication,andwithoutforcinguserstoinstalladditionalsoftware,orforcinguse
48、rstoabandonhisbelovedbrowser.Toobtainmaturetoolsarewidelyunderstoodcanhelpusachievethisgoal.Thebackofthebookdesignpatternisonesuchtoolmentioned.Thepromotionandpopularizationofanewtechnology,isnotonlythetechnicalmatters,butalsosocialbehavior.Oncethetechnologyismature,thepeoplealsoneedtounderstandhowt
49、ouseit.Thisstepisoftenbyusingittodoourveryfamiliarthingsstart.Forexample,earlybicyclecalledTrojanwheelorpedalinghorse,onhisfeettreadthereactionforcetomoveforward.Asthistechnologyisgraduallyacceptedbythepublic,theninventorswouldinventanewwaytouse,addthepedal,brake,achainwheelandtire.Eachtimetheinventioncreation,madethebikeintheshadowofmorepalehorse,thatcompletelydisappeared.ThesameprocessalsooccursinthefieldofWebdevelopment.ThetechnologybehindtheAjaxhavetheabilitytoW