外文翻译-Ajax的应用.docx
附录1TheapplicationofAjaxSpendafewminutesusingyourapplicationyouselected(browserexcept),writeitdowntowhatuserinteraction,andthenimmediatelyback.Forthesakeofbrevity,Igiveanexampleofelectronicform,however,pointsinvolvedhereisgeneralenoughforvariouscases,thetexteditor.Well,westarted.Firstinthespreadsheettoinputsomeequalities,payattentionto,caninteractinseveralways:editdata,browsingthedatausingthekeyboardandmouse,alsocanusethemousetodragtoreorganizethedata.Idotheseoperations,theprogramgavemefeedback.Whenmovingthemouse,thecursorchangesshape;whenthemousestopsabove,buttonbright;selectedtextcanchangecolor.Whenawindowordialogboxisselected,andusuallyisnotthesame,etc.Thesearetheso-called"richuinteraction.Ofcourse,therearestillsomeroomforimprovement,butthisisagoodstart.OK,aspreadsheetisarichclientprogram7Absolutelynot.Inaspreadsheetorsimilardesktopapplications,businesslogicanddatamodelisruninaclosedenvironment.Inthisenvironment,theyclearlyunderstandeachother,andcanvisiteachother,andtheenvironmentoutsideofthings,isunknowntothem.Whatistheclient?Itisaseparateprocessofmutualcommunicationprogram,whichisusuallyrunontheserver.Ingeneral,theserverisalwaysbiggerthantheclient,ability,dispositionisbetter,becausetheserverisusuallystoredmultitudeinformation.Theclientprogramenablestheenduserscanviewandmodifytheinformation,whenmultipleclientsconnectedtothesameserver,canshareinformationbetweenthem.Showsasimpleclient/serverarchitecture.Inthenlayerarchitectureinthemodem,theserveroftenandfurthertheback-endserver(suchasadatabase)communication,soCallednIniddlewarenIayeralsoplaysaroleofclientandserver.EndofourAjaxapplicationinthechain,itisonlyastheclient,therefore,fortheconvenienceofdiscussion,wecanpulthewholensystemasalabeledas"blackboxserver".SpreadsheetapplicationsIonlyneedtomanageitsownsavedasmallamountofdatainmemoryorinthelocalfilesystem.Ifthedesignofwellstructure,couplingformdataanditcanbeveryloose,butIcan,tpassanetworktosplitorSharethemthroughnetwork.Inthissense,theapplicationofelectronicformisnotaclient.ThecorrespondingWebbrowserisatypicalclient,whichcommunicatewiththeWebserver,therequestpage.Thebrowserhasabundantfunctions,usedtomanageuserbrowsingbehavior,thecommonfunctionofthebackbutton,thehistorylistandtabbedbrowsingmultipledocumentsetc.ButwhenweputthesitespecificWebpagesasanapplication,thesegeneralbrowsingfunctionactuallyandapplicationis,atbest,suchasspreadsheetsandWindowsbegantherelationshipbetweenbuttonorthewindowlist.WeconsidertheapplicationofmodernWeb.Forthesakeofsimplicity,wechose"Aearthpeopleknow"onlinebookstore.OpentheAmazonsiteinthebrowser,becausebeforeIvisited,itwillshowmeafriendlygreeting,Somerecommendedbibliography,andmypurchasehistoryinformation.Clickonanyoneoftherecommendedbibliography,willgotoanotherpage(atthistime,thepagetorefresh,withinafewsecondsIwhatalsodon'tsee).Thenewpageistheinformationrelevanttothebookreview:otherbooks,second-handbooks,offerthesameauthor,andotherbooksIread.Inshort,appearstobeveryrich,highdegreeofassociatedinformationinfrontofme.Butforme,interactivewayistoclickonthehyperlink,andthenfillinsomeforms.Suppose1atthekeyboardaccidentallyfellasleep,wakeupseconddays,ifnotrefreshthepage,Idon'tknowuHarryPorter"seriesofbookshavebeenpublished,norwillmylistfromonepagetoanotherpage,ifIwanttoseemorethingstoo,becauseIcannotchangethelocalcontentareapagesize.IseemtobeinthecriticismoftheAmazoninterface,butitisnotthecase,Ijusttookitasanexample.Infact,inthetraditionalWebdevelopmentoftheshackles,theyhavedoneverywell.Butcomparedtothespreadsheet,andtheinteractionmodelisundoubtedlytoolimited.WhyWebistheapplicationofmodemstillhavesomanyIimitationsTThecurrentsituationhassomereasonabletechnicalreasons,wehavetoconsidernow.TheblueprintfortheInternetisallthecomputerintheworldareconnected,formingahugecomputingresources.Ifthelocaldataandremoteinvocationequated,thenboththeanalysisofproteincomponentsorcracksignalsfromouterspace,usersneednotconsiderthephysicallocationofthemachines,therestofthecomputationonlypleasure.Butunfortunately,thelocalcallandremoteinvocationissomethingtotallydifferent.Underthecurrentleveloftechnology,thenetworkcommunicationisstillacostlythings(thatistosay,isusuallyveryslow,butunreliable).Intheabsenceofanetworkcalledthesituation,methodandfunctionofdifferentdataandtheiroperationsarelocatedinthesamelocalmemory,totransferdataandreturntheresultsobtainedareverydirect.Inaremotecall,communicationinthenetworkatbothendsofthetwosidestosendandreceivedatarequiresalotofcomputationatthebottom.Comparedwiththedatabackandforthontheline,thesecalculationsrequiremoretimeconsuming.Thetransmissionofabinarydata,togothroughmanystepsofcodinganddecoding,errorchecking,failure,packetretransmissionsplitandreorganization,dataintoOand1binarysignal,throughtheline(orwirelessconnectiontotheotherparty).Inthelocal,callthefunctioncallrequestisencodedasanobject,thentheobjectisserializedasaseriesofbytes,theapplicationlayerprotocol(usuallyHTTP)viathephysicaltransmissionmedium(suchascoppercable,opticalfiberorradio)sendout.Ontheremotemachine,theapplicationlayerprotocoldecoding,thebytedeserializethedataobtained,tocreateacopyoftherequestedobject.Thenthedatamodelisappliedtotheobjectandgeneratesaresponseobject.Inordertomaketheresponseobjectispassedtothecallbackfunctionlocal,allserializationdeserializationoperation,andthetransportlayerwillbebackagain.Finally,theresponseobjectispassedtothefunctioncalllocal.Thisinteractiveprocessisverycomplex,butfortunately,itcanbedone.Modernprogrammingenvironmentssuchas.NETJavaandMicrosoftframeworkarebuiltwiththisability.However,theexecutionofremotecalls,alltheseoperationswillstillbeintheinternalexecution.IfWewereusingtheremoteinvocation,performancewillbeaffected.Thatistosay,aremotecallisunlikelytohaveefficiencyandlocalcall.Whatisworse,theinstabilityofnetworkmakestheefficiencylossisunpredictable,itisdifficultto.Incontrast,alocalcalltorunonthelocalmemory,willundoubtedlyhaveanadvantagemoreatthispoint.Andsoon,saidremotecallhalfaday,betweenthisandtheavailabilityofsoftware?Theansweris,arelationship.AsuccessfulcomputeruserinterfacemustbeabletoatleastlevelsimulationWeexperienceintherealworld.Oneofthebasicrulesofinteractionis,whenwepush,prickorpokeaboutsomething,itwillimmediatelyresponse.Responsetimeaslongasalittlebitoutalittle,willmakepeopleconfused,distracted,toshiftthefocusfromthetaskathandtotheuserinterface.Remotecallsacrossthenetwork,needtoperformadditionaloperationsingreatquantities,theytendtoputthesystemtoslowdown,theuserperceiveddelay.Indesktopapplications,onlywhentheusabilitydesignisverybad,willappearthiskindofmakesusersfeelfullofbug,unresponsivetotheuserinterface,butintheapplicationofnetwork,whatdonotgetalargenumberofsuchinterface.Becausethenetworkdelayisunpredictable,thiskindofinterfaceproblemsoftencomeandgolikeashadow,itisdifficulttocarryouttheapplicationresponsetest.Inotherwords,thenetworkdelayistheresultofacommoncauseofthepracticalapplicationoftheinteraction.Userinterfacedevelopersfornetworkdelaycanonlyassumetheworst.Saysimply,istotrytomaketheuserinterfaceandnetworkactivitiesunrelatedto.Programmershavealreadycreatedatrulyeffectiveandprovensolutions,tosolvethisproblem.TosellaGuan,letusintotherealworld.InthemorningIwilldo,averyimportantistowakemykidsgotoschool.Icanstandontheedgeofthebedtheytossup,chasethemupanddressed,butthismethodisverytimeconsuming,ittakesmealotofpreciousmorningtimeIwanttowakeupthechildren,havealookoutthewindow,oftenneglectedtofeedthecat.Afterthechildrenwouldaskmetobreakfast.Astheserverprocess,thechildrenalwaysgetupslowly.IfIfollowthesynchronousinteractionpattern,willtheyallday.However,aslongastheymumble"Iwokeup',Icangotodootherthings,needtocomebackwhentheyhavealook.Incomputerterms,Ineedtodoisforeverychildtoestablishanasynchronousprocessinaseparatethread.Afterthestart,thechildrenwillwakeupintheirownthreads,theparentthreadunnecessarysynchronizationwait,theyafterwardswillinformme(whichisoftenaskedmetoeat).Intheprocesstheywakeup,Idon'tneedinteractionandthey,whentheyhadbeenupanddressedmyself,becauseIhavereasontobelievethattheywilldososoon.Foranyuserinterface,whichisalongestablishedpractice,namelytoCreateasynchronousthread,letitinthebackgroundwhoneedtocalculatealongtimetask,sothattheusercancontinuetodootherthings.Whenstartingthisthread,itisnecessarytoblocktheuseroperation,butafterashortperiodoftimecanbeaccepted,willrelievecongestion.Becauseoftheexistenceofnetworkdelay,usingasynchronousmodeisagoodpracticetohandleanytime-consumingremotecall.Infact,thenetworklatencyproblemsandsolutionsrelatedtolong-standing.lntheoldclient/servermode,whenthepoordesignoftheclientprogrammetthehighloadoftheserver,theuserinterfacewillappeardelayintolerable.Evenintoday'sInternetera,whentoswitchthepage,ifthebrowserhalfthethingsnotto,sothissituationmightbeduetonetworkdelaycausedby.Theexistingtechnicalconditions,wehavenowaytoremovethenetworkdelay,butatleastonestrategy,thatistheuseofasynchronousprocessingremotecalls,isn,tit?Worse,forWebdeveloperstodosothereisaproblem:HTTPprotocolisa,requestresponse'1modeoftheprotocol.Thatistosay,theclientrequestsadocument,theserverorareturntothisdocumentortelltheclientcannotfindthedocumentorallowsaclienttoanotherplacetofind,alsocantellwhichtheclientcanusethelocalcache,andsoon.Tomakealongstoryshort,"requestresponseumodeoftheprotocolisaone-waycommunicationprotocol.Theclientinitiatesaconnectiontotheserver,buttheservercannotinitiatesaconnectiontotheclient.EvenwhenthenextClientjnitiatethecommunicationrequest,forgetfuloftheservercan'trememberthisclientiswho(HTTPisaconnectionless).MostWebdeveloperstousemodemprogramminglanguage,forexample,Java,PHPo*.NET,theyarefamiliarwiththeusersession(usersession)concept,thisisinfacttheapplicationserverforaremedycan'tmaintainaconnectionstateoftheHTTPprotocol.HTTPfortheinitialdesigngoalwell,usingsomecleverprocessing,itcanadapttothebeginningofthedesigndidnotconsidertheoccasion.Butthekeyfeaturesoftheasynchronouscallbackschemeofourclientis,willreceivetwonotice,isatimeinthethreadcreation,theotherisatimeintheendofthethread.ThestandardHTTPandthetraditionalWebapplicationmodelcannotprovidethese.ThetraditionalWebapplicationlikeAmazon,isbuiltontheconceptofthepage.Showtheuseradocument,whichincludesvariouslinksandform,theusercanaccessfurthermoredocumentation.Thisinteractionmodelcansupportcomplexdatasetsonalargescale(likeAmazonandothersiteshavedemonstrated),whichprovidestheuserexperienceisenoughtomeettheneedsofbusiness.Intenyears,thisinteractionmodellaidadeepimprintinourviewoftheapplicationofInternetbusiness.WYSIWYGinterface(WYSIWYG)Webauthoringtools,makingthesitemoreeasilytobeunderstoodasastackofpages.TheframeworkofWebserverusingthestatediagramconversiononthepagemodeling.nointroduction,thetraditionalWebapplicationthathasbeenfirmlyboundinapagerefreshoperation,asiftherefreshisbehooveandinevitable,triedprocessingschemeforanyasynchronousnever.Ofcourse,nodoubt,thetraditionalWebapplicationmustnotnothingisright.Afterall,Amazoninthisinteractionmodeltocreateasuccessfulcommercialapplications.ButthisappliestothewayAmazondoesnotnecessarilyapplytoallpeople.Whydoyousaythat?Tounderstandthis,weneedtostudytheusermodel(usagepattern).AgeneraldiscussionofthebicycleandSUV(SUV)meritsmeaningless.Becausetheyhavetheirownadvantagesanddisadvantages-comfort,speed,fuelconsumptionorpersonalidentity.Onlydiscussedinparticularusemode,thiscomparisonisonlymeaningful.Forexample,istointherushhourthroughthecenterofthecity,ortotakethewholefamily,oldandyoungtogoonvacation,orjusttofindashelterfromtherain.Inasimilarsituationlikethis,canwehaveadefiniteobjectinviewtocompare.Fortheuserinterface,itisthesamewith.SoftwareusabilityexpertAlanCooperhaswrittenalotofgoodarticlesaboutusagepatterns,hedefinestwomainuses:transient(transient)andexclusive(sovereign).Transientapplicationsmayuseoccasionallyeveryday,butalwaysasasecondaryactivity,withasudden.Thecontrastissovereignapplications,exclusivecontinueduseofapplicationtodealwiththeuserforseveralhoursaday.Manyapplicationshaveanaturalmonopolyortransientproperties.Forexample,awordprocessingsoftwarewritingisasovereignapplication,possibleapplicationsalsouseseveraltransient,suchasfilemanagement(fileopenandembedthisfunctionwilloftenclosethewindow),dictionaryorspellcheckingtools(manywordprocessingprogramisalsoembeddedinthesefunctions),andcolleaguescontactemailandchattool.Forsoftwaredevelopers,texteditor,debuggerorIDE(integrateddevelopmentenvironment)istheexclusive.Sovereignapplicationsoftenusemorefrequently.Youknow,agooduserinterfaceisnotvisible.Themeasureofagoodscaleusedfrequently,iswhentheuserinterfacehasobviouspause,itaffectstheuserprocess.Forexample,fromadirectorytoanotherdirectoryfileto2secondpause,!canacceptwithpleasure;butifthetwosecondsistheplaceinmyisfullofpassionforpaintingsoftwaretocreateanimage,ormtryingtodebugaverydifficulttodealwiththegenerationofcodecertainly,thismakesmefeelveryuncomfortable.Amazonisatransientapplication,eBay,GoogleandmostlargepublicWebapplicationsaretransientapplications.Sincethedateofbirth,theexpertshadpredictedthatthetraditionaldesktopapplicationsunderWebimpact.Overthepasttenyears,thesehavenotoccurred,why7BasedontheWebpageprogramfortransientapplicationsisenough,butitisfarfromenoughforasovereignapplication.ThestartingofmodernWebbrowsersandit'soriginalpoint(adocumentfromaremoteserver)hasnotmatter,betweenthemlikeaSwissArmyknifeandneolithichuntingtools,itisaworldofdifference.Avarietyofinteractivecomponents,scriptsandplug-ins,theseyearscouldnotsuppressthecrazydevelopment,almostforcedonceagaintocreateanewbrowsingexperience.toprehistorictimesVisitbrowsenIn1993,netscapefoundedbeforetheMarcAndreessen(founderofnetscape)arelobbyingTimBemers-Lee(founderofWeb,theW3Cleader)etal.,citedgoodintoapicturelabelisHTML.Afewyearsago,afewpioneersbegantotreatJavaScriptasaseriousprogramminglanguage.Butonthewhole,morepeoplestilluseitandthosewhomockwarningbox"monkeytricksandclicktowinawards"advertisingaClasstogether.ThebrowserwarsbroughtJavaScriptamisunderstood,sickchildren,Ajaxcanbeviewedashisrehabilitationcenter.Aslongastheproperguidance,andthentoframeitwithappropriate,JavaScriptwilllikelybecometheInternetmodelcitizen.ltcanreallyenhancethepracticabilityofWebapplication,andwithoutforcinguserstoinstalladditionalsoftware,orforcinguserstoabandonhisbelovedbrowser.Toobtainmaturetoolsarewidelyunderstoodcanhelpusachievethisgoal.Thebackofthebookdesignpatternisonesuchtoolmentioned.Thepromotionandpopularizationofanewtechnology,isnotonlythetechnicalmatters,butalsosocialbehavior.Oncethetechnologyismature,thepeoplealsoneedtounderstandhowtouseit.Thisstepisoftenbyusingittodoourveryfamiliarthingsstart.Forexample,earlybicyclecalled"Trojanwheel"or"pedalinghorse,onhisfeettreadthereactionforcetomoveforward.Asthistechnologyisgraduallyacceptedbythepublic,theninventorswouldinventanewwaytouse,addthepedal,brake,achainwheelandtire.Eachtimetheinventioncreation,madethebikeintheshadowofmorepalehorse,thatcompletelydisappeared.ThesameprocessalsooccursinthefieldofWebdevelopment.ThetechnologybehindtheAjaxhavetheabilitytoW