Ice分布式程序設(shè)計(jì) 畢業(yè)論文外文翻譯_第1頁(yè)
Ice分布式程序設(shè)計(jì) 畢業(yè)論文外文翻譯_第2頁(yè)
Ice分布式程序設(shè)計(jì) 畢業(yè)論文外文翻譯_第3頁(yè)
Ice分布式程序設(shè)計(jì) 畢業(yè)論文外文翻譯_第4頁(yè)
Ice分布式程序設(shè)計(jì) 畢業(yè)論文外文翻譯_第5頁(yè)
已閱讀5頁(yè),還剩8頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Ice Distributed ProgrammingHYPERLINK /ice.htmlInternet Communications Engine (Ice) is a modern distributed computing platform with support for HYPERLINK /icecpp.htmlC+, HYPERLINK /icedotnet.html.NET, HYPERLINK /icej.htmlJava, HYPERLINK /icepy.htmlPython, HYPERLINK /iceobjc.htmlObjective-C, HYPERLINK

2、 /iceruby.htmlRuby, HYPERLINK /icephp.htmlPHP, and HYPERLINK /iceas.htmlActionScript. Ice is used in mission-critical projects by companies all over the world.Ice is easy to learn, yet provides a powerful network infrastructure and vast array of features for demanding technical applications.Ice is f

3、ree software, available with full source, and released under the terms of GNU HYPERLINK /licenses/old-licenses/gpl-2.0.htmlGeneral Public License (GPL). HYPERLINK /licensing.htmlCommercial licenses. AAn Overview of the Ice Platform:The Ice Approach: Flexible and SimpleIce provides a communication so

4、lution that is simple to understand and easy to program with. Yet, despite its simplicity, Ice is flexible enough to accommodate even the most demanding and mission-critical applications.Cutting-Edge TechnologyIce was designed and implemented by HYPERLINK /about.htmlindustry experts with many years

5、of distributed computing experience. ZeroCs class-leading technology is flexible, easy to use, robust, and provides superior performance and scalability.Programming LanguagesIce allows you to write your distributed applications in HYPERLINK /icecpp.htmlC+, HYPERLINK /icej.htmlJava, HYPERLINK /icedot

6、net.htmlC# (and other .NET languages, such as Visual Basic), HYPERLINK /icepy.htmlPython, HYPERLINK /iceruby.htmlRuby, HYPERLINK /icephp.htmlPHP, and HYPERLINK /iceas.htmlActionScript. With HYPERLINK /icetouch/index.htmlIce Touch, your application can include Objective-C components that run on the i

7、Phone, iPad, and iPod touch, while Ice for Java can also be used to build Ice applications for HYPERLINK /android.htmlAndroid. HYPERLINK /icee/index.htmlIce-E allows you to deploy C+ components on resource-constrained devices running Gumsticks or Windows Mobile Professional. (HYPERLINK /icee/index.h

8、tmlIce-E applications must be written in HYPERLINK /icecpp.htmlC+.) This makes Ice the platform of choice for heteregeneous distributed systems that span multiple operating systems and programming languages.APIsIce provides a set of APIs that emphasize simplicity and ease of use. All APIs are thread

9、-safe and exception-safe, and the C+ APIs make it very difficult to leak or corrupt memory. This shortens development time, decreases testing effort, and reduces time to market.The APIs for the various programming languages (apart from a very small number of exceptions) are identical: for example, i

10、f you know the API for Java, you also know the API for C+ and C# (and any other supported programming language). For systems written in more than one language, this reduces the learning curve and allows reuse of design patterns and implementation techniques.Advanced Technology Ice is much more than

11、just a remote procedure call mechanism. For example, Ice supports synchronous as well as asynchronous calls, co-exists with firewalls due to its support for bidirectional connections, allows messages to be batched for efficiency, and permits sophisticated control of threads and resource allocation.

12、See HYPERLINK /features.htmlIce Features for more detailed information.Fault Tolerance and Load Balancing Ice allows you to create systems that are fault tolerant. Multiple instances of a server can be deployed on different machines, with transparent fail-over if a machine crashes or is disconnected

13、 from the network. This not only makes applications resilient against failures, but also increases performance because Ice allows you to balance the load of a distributed system over several servers. Once a system takes advantage of load balancing, it is easy to scale it to higher loads simply by ad

14、ding more serversPerformance and ScalabilityIce was designed from the ground up for applications that require the utmost in performance and scalability. At the network level, Ice uses an efficient binary protocol that minimizes bandwidth consumption. Ice uses little CPU and memory, and its highly ef

15、ficient internal data structures do not impose arbitrary size limitations. This allows applications to scale to tens of thousands of clients with ease.Ice is fast. So fast that, as a rule, it imposes no discernable overhead on a distributed application. Data can be transmitted at whatever speed is s

16、upported by the network, so Ice does not create any performance bottleneck. Our HYPERLINK /articles/IcePerformanceWhitePaper.pdfPerformance and Scalability white paper provides a comparison with other popular distributed computing solutions.Realistic Feature SetIce was developed to meet the demands

17、of real-world distributed systems and it incorporates extensive customer feedback. Ice provides realistic features that are actually useful (as opposed to theorectical features that were considered possibly useful by a committee). ServicesFor realistic distributed systems, even the most sophisticate

18、d remote procedure call mechanism is useless without additional infrastructure. Ice provides a rich set of HYPERLINK /services.htmlservices, such as event distribution, firewall traversal with authentication and filtering, automatic persistence, automatic application deployment and monitoring, and a

19、utomatic software distribution and patching. All services can be replicated for fault tolerance, so they do not introduce a single point of failure. Use of these services greatly reduces development time because they eliminate the need to create distribution infrastructure as part of application dev

20、elopment. Our HYPERLINK /services.htmlIce Services page provides an overview of the different services.SecurityIce is inherently secure and suitable for use over insecure public networks. Traffic can be encrypted with SSL, and a variety of authentication mechanisms ensure that only authorized client

21、s can access a system. Ice can work with existing firewalls: a single port is sufficient to provide secure access for an unlimited number of clients to an unlimited number of servers. Web IntegrationYou can use Ice to integrate a distributed system with the web. Ice for Java allows you to run an Ice

22、 client as an applet inside a browser, and Ice for PHP makes it easy to populate web content with data collected from back-end servers. In addition, HYPERLINK /labs/silverlight/index.htmlIce for Silverlight allows you to run Ice clients directly in a browser.First-Class Documentation and SupportZero

23、C prides itself on the industry-leading quality of its HYPERLINK /Ice-Manual.htmldocumentation and HYPERLINK /Slice-Reference.htmlAPI reference. The documentation is arranged into topics by language mapping and programing task, so you can easily locate a section of interest. The indexed and searchab

24、le text is available online and as a HYPERLINK /Ice-Manual.pdfdownload suitable for off-line viewing or printing. The documentation includes many code examples that illustrate how to implement different features, making it easy for programmers to learn implementation techniques and acquire know-how.

25、 Beyond tutorial and reference material, the documentation covers many non-trivial topics that are relevant for real-world application development.Language Support:The programming languages used in todays development projects are often determined by a number of factors, including application require

26、ments, developer backgrounds, organizational policies, and compatibility with third-party tools. We designed Ice to be a practical distributed computing platform for real developers writing real applications. That goal drives everything we do at ZeroC, and it is the reason why HYPERLINK /ice.htmlIce

27、 supports such a broad spectrum of programming languages. Whether your project uses one language or several, Ice will enable your components to communicate with each other naturally, efficiently and transparently.The Ice API was carefully designed to conform with the standards and practices of each

28、programming language while maintaining a consistency that minimizes the learning curve of a developer working in multiple languages. As you will see from the sample code shown on the language pages, the Ice API is easy to learn and just as easy to use.Ice currently offers language mappings for the f

29、ollowing programming languages:HYPERLINK /icecpp.htmlC+The Ice language mapping for C+ combines raw speed with an elegant design that enhances productivity and virtually eliminates memory leaks. See HYPERLINK /icecpp.htmlIce for C+ for more information on the C+ mapping and a code example.HYPERLINK

30、/icej.htmlJavaJavas portability and wealth of tools is an attractive complement to Ice, and support for Android allows Ice applications to run on devices in Googles ecosystem. See HYPERLINK /icej.htmlIce for Java for more information on the Java mapping and a code example. HYPERLINK /icedotnet.html.

31、NETCompatible with both Microsoft and Mono, developers can utilize Ice to integrate their .NET applications. Embedded and mobile devices that use the .NET Compact Framework can also employ Ice. See HYPERLINK /icedotnet.htmlIce for .NET for more information on the C# mapping and a code example.HYPERL

32、INK /icepy.htmlPythonIce for Python provides seamless access to Ice resources from this popular scripting language. See HYPERLINK /icepy.htmlIce for Python for more information on the Python mapping and a code example.HYPERLINK /icephp.htmlPHPDynamic web applications can extend their reach to distri

33、buted objects using Ice for PHP. See HYPERLINK /icephp.htmlIce for PHP for more information on the PHP mapping and a code example.HYPERLINK /iceobjc.htmlObjective-CWith support for the iPhone, iPod touch, Cocoa, and OS X, developers can use HYPERLINK /icetouch/index.htmlIce Touch to integrate Apples

34、 mobile devices. See HYPERLINK /iceobjc.htmlIce Touch for Objective-C for more information on the Objective-C mapping and a code example.Object landscapes and lifetimesTechnically, OOP is just about abstract data typing, inheritance, and polymorphism, but other issues can be at least as important. T

35、he remainder of this section will cover these issues. One of the most important factors is the way objects are created and destroyed. Where is the data for an object and how is the lifetime of the object controlled? There are different philosophies at work here. C+ takes the approach that control of

36、 efficiency is the most important issue, so it gives the programmer a choice. For maximum run-time speed, the storage and lifetime can be determined while the program is being written, by placing the objects on the stack (these are sometimes called automatic or scoped variables) or in the static sto

37、rage area. This places a priority on the speed of storage allocation and release, and control of these can be very valuable in some situations. However, you sacrifice flexibility because you must know the exact quantity, lifetime, and type of objects while youre writing the program. If you are tryin

38、g to solve a more general problem such as computer-aided design, warehouse management, or air-traffic control, this is too restrictive. The second approach is to create objects dynamically in a pool of memory called the heap. In this approach, you dont know until run-time how many objects you need,

39、what their lifetime is, or what their exact type is. Those are determined at the spur of the moment while the program is running. If you need a new object, you simply make it on the heap at the point that you need it. Because the storage is managed dynamically, at run-time, the amount of time requir

40、ed to allocate storage on the heap is significantly longer than the time to create storage on the stack. (Creating storage on the stack is often a single assembly instruction to move the stack pointer down, and another to move it back up.) The dynamic approach makes the generally logical assumption

41、that objects tend to be complicated, so the extra overhead of finding storage and releasing that storage will not have an important impact on the creation of an object. In addition, the greater flexibility is essential to solve the general programming problem. Java uses the second approach, exclusiv

42、elyHYPERLINK ./././Documents and Settings/gg/Local Settings/Temp/e/TIJ303.htm l fn8#fn8. Every time you want to create an object, you use the new keyword to build a dynamic instance of that object. Theres another issue, however, and thats the lifetime of an object. With languages that allow objects

43、to be created on the stack, the compiler determines how long the object lasts and can automatically destroy it. However, if you create it on the heap the compiler has no knowledge of its lifetime. In a language like C+, you must determine programmatically when to destroy the object, which can lead t

44、o memory leaks if you dont do it correctly (and this is a common problem in C+ programs). Java provides a feature called a garbage collector that automatically discovers when an object is no longer in use and destroys it. A garbage collector is much more convenient because it reduces the number of i

45、ssues that you must track and the code you must write. More important, the garbage collector provides a much higher level of insurance against the insidious problem of memory leaks (which has brought many a C+ project to its knees).附錄2(中文翻譯)Ice分布式程序設(shè)計(jì)互聯(lián)網(wǎng)通訊引擎(Ice)是一個(gè)現(xiàn)代的分布式計(jì)算平臺(tái)支持C+,.NET、Java、Python、ob

46、jective - c, Ruby、PHP和 ActionScript。 ICE被用在關(guān)鍵任務(wù)項(xiàng)目世界各地的公司。ICE很容易學(xué),但提供了一個(gè)強(qiáng)大的網(wǎng)絡(luò)基礎(chǔ)設(shè)施和大量的特性要求技術(shù)的應(yīng)用程序。ICE是免費(fèi)軟件,具有完整的源文件,并釋放的條款下GNU通用公共許可證(GPL)。商業(yè)許可證可以為客戶希望使用封閉源碼軟件的ICE。ICE簡(jiǎn)介:ICE的方法:靈活和簡(jiǎn)單ICE提供通信解決方案,很容易理解和容易計(jì)劃。然而,盡管它的簡(jiǎn)單性,ICE足夠靈活,可以適應(yīng)甚至最要求和關(guān)鍵任務(wù)的應(yīng)用程序。尖端技術(shù):ICE的設(shè)計(jì)和實(shí)現(xiàn)由行業(yè)專家基于由于多年的分布式計(jì)算的經(jīng)驗(yàn)。ZeroC的class-leading技術(shù)是靈

47、活、易于使用的、健壯的、提供出色的性能和可伸縮性。編程語(yǔ)言:ICE可以讓你寫(xiě)你的分布式應(yīng)用程序的C + +,JAVA,C中(以及其他 .NET語(yǔ)言,如Visual Basic)的Python和Ruby,PHP中,和ActionScript。隨著ICE觸,您的應(yīng)用程序可以包括Objective-C的元件在iPhone,iPad和iPod touch上運(yùn)行,而CIE的Java也可以用來(lái)建立ICE.應(yīng)用為Android,ICE- E使您能夠部署在資源有限的設(shè)備運(yùn)行Gumsticks或Windows Mobile專業(yè)的C + +組件。 (ICE-E的應(yīng)用程序必須寫(xiě)在C+),這使得ICE hetereg

48、eneous跨越多個(gè)操作系統(tǒng)和編程語(yǔ)言的分布式系統(tǒng)的首選平臺(tái)。APIS:ICE提供一系列的API,強(qiáng)調(diào)簡(jiǎn)潔和易用性。所有的API是線程安全和異常安全的,和C+ API使得它很難泄漏或損壞的內(nèi)存。這縮短開(kāi)發(fā)時(shí)間,降低測(cè)試工作,并縮短上市時(shí)間。ICE的各種編程語(yǔ)言的API(除了非常小的例外)是相同的:例如,如果你知道的Java的API,你也知道API為c+、c(以及任何其他支持的編程語(yǔ)言)。一種以上的語(yǔ)言編寫(xiě)的系統(tǒng),這縮短了學(xué)習(xí)曲線,并允許重復(fù)使用的設(shè)計(jì)模式和實(shí)現(xiàn)技術(shù)。先進(jìn)的技術(shù):ICE是遠(yuǎn)遠(yuǎn)不僅僅是一個(gè)遠(yuǎn)程過(guò)程調(diào)用機(jī)制。例如,ICE以及支持同步異步調(diào)用,由于它支持雙向連接與防火墻共存,允許將郵件

49、批處理效率,并允許線程和資源分配的復(fù)雜的控制。容錯(cuò)和負(fù)載平衡:ICE允許你創(chuàng)建系統(tǒng)容錯(cuò)。透明故障服務(wù)器的多個(gè)實(shí)例可以部署在不同的機(jī)器上如果一臺(tái)機(jī)器崩潰或從網(wǎng)絡(luò)上斷開(kāi)。這不僅使應(yīng)用程序?qū)收系膹椥?,而且還提高了性能,因?yàn)镮CE可以讓你來(lái)平衡幾臺(tái)服務(wù)器的分布式系統(tǒng)負(fù)載。一旦系統(tǒng)需要負(fù)載均衡的優(yōu)點(diǎn),它很容易擴(kuò)展到更高的負(fù)載只需添加更多的服務(wù)器。性能和可伸縮性:ICE需要最大性能和可擴(kuò)展性的應(yīng)用。ICE在網(wǎng)絡(luò)層,使用高效的二進(jìn)制協(xié)議,最大限度地減少帶寬消耗。ICE用很少的CPU和內(nèi)存,其高效的內(nèi)部數(shù)據(jù)結(jié)構(gòu)不施加任意大小的限制。這允許應(yīng)用程序輕松地?cái)U(kuò)展到數(shù)以萬(wàn)計(jì)的客戶。ICE是快速的。如此之快,作為一項(xiàng)

50、規(guī)則,對(duì)分布式應(yīng)用程序沒(méi)有可辨別的開(kāi)銷(xiāo)??梢栽谟删W(wǎng)絡(luò)支持的任何速度傳送數(shù)據(jù),因此ICE不會(huì)產(chǎn)生任何性能瓶頸。我們的性能和可伸縮性白皮書(shū)提供了與其他流行的分布式計(jì)算解決方案的比較?,F(xiàn)實(shí)特寫(xiě)集:ICE被開(kāi)發(fā),以滿足現(xiàn)實(shí)世界的分布式系統(tǒng)的需求,它集成了廣泛的客戶反饋。 ICE提供逼真的特點(diǎn),實(shí)際上是有用的(而不是由一個(gè)委員會(huì)被認(rèn)為可能有用的理論分析功能)。服務(wù):對(duì)于真實(shí)的分布式系統(tǒng),即使最成熟的遠(yuǎn)程過(guò)程調(diào)用機(jī)制是無(wú)用的沒(méi)有額外的基礎(chǔ)設(shè)施。ICE提供一組豐富的服務(wù),例如事件分布、防火墻和身份驗(yàn)證和過(guò)濾的遍歷,自動(dòng)持久性,應(yīng)用程序自動(dòng)部署和監(jiān)控、自動(dòng)軟件分布和修補(bǔ)。所有的服務(wù)可以被復(fù)制的容錯(cuò),所以他們不

51、引入一個(gè)單點(diǎn)故障。使用這些服務(wù)大大減少開(kāi)發(fā)時(shí)間,因?yàn)樗麄儾辉傩枰獎(jiǎng)?chuàng)建分銷(xiāo)基礎(chǔ)應(yīng)用程序開(kāi)發(fā)的一部分。我們的ICE服務(wù)頁(yè)面提供不同服務(wù)的概述。安全:ICE在本質(zhì)上是安全的,適合使用非安全的公共網(wǎng)絡(luò)。交通可通過(guò)SSL加密,多種身份驗(yàn)證機(jī)制確保只有授權(quán)的客戶可以訪問(wèn)系統(tǒng)。ICE能配合現(xiàn)有防火墻:一個(gè)單獨(dú)的端口是足以提供安全接入為無(wú)限的客戶數(shù)量無(wú)限的服務(wù)器。Web集成:您可以使用ICE來(lái)集成分布式系統(tǒng)網(wǎng)絡(luò)。ICE對(duì)于Java允許您運(yùn)行一個(gè)ICE客戶端applet那樣在一個(gè)瀏覽器,和ICE使得它很容易為PHP web內(nèi)容采集的數(shù)據(jù)填充從后端服務(wù)器。此外,ICE對(duì)Silverlight允許您運(yùn)行ICE客戶直

52、接在瀏覽器中。一流的文檔和支持:ZeroC而著稱業(yè)界領(lǐng)先的質(zhì)量文檔和API參考。 文檔被安排為主題的語(yǔ)言映射和編程任務(wù),所以您可以很容易地找到感興趣的部分。索引和搜索的文本都可以在線閱讀和下載適合離線觀看或印刷。該文檔包含許多代碼示例,演示如何實(shí)現(xiàn)不同的功能,方便程序員學(xué)習(xí)實(shí)現(xiàn)技術(shù)和獲得知識(shí)。指南和參考資料之外,文檔還包含了許多優(yōu)秀的話題以及相關(guān)的真實(shí)世界的應(yīng)用程序開(kāi)發(fā)。語(yǔ)言支持:使用的編程語(yǔ)言在今天的開(kāi)發(fā)項(xiàng)目通常是由多種因素決定的,包括應(yīng)用程序的需求,開(kāi)發(fā)人員的背景、組織策略和兼容性與第三方工具。我們?cè)O(shè)計(jì)的ICE是一個(gè)實(shí)用的分布式計(jì)算平臺(tái)真正的開(kāi)發(fā)人員編寫(xiě)真實(shí)應(yīng)用。這個(gè)目標(biāo)驅(qū)動(dòng)在ZeroC我

53、們所做的一切,這就是為什么ICE支持如此廣泛的編程語(yǔ)言。無(wú)論您的項(xiàng)目使用一種語(yǔ)言或幾個(gè),ICE將會(huì)使你的組件彼此通信自然、高效和透明的。ICE API進(jìn)行了精心設(shè)計(jì),以符合標(biāo)準(zhǔn)和實(shí)踐每種編程語(yǔ)言的一致性,同時(shí)維護(hù)一個(gè)最小化的學(xué)習(xí)曲線在多種語(yǔ)言工作的開(kāi)發(fā)人員。正如您將看到的示例代碼顯示在頁(yè)面的語(yǔ)言,ICE層API很容易學(xué)習(xí)和使用一樣簡(jiǎn)單。ICE目前提供的語(yǔ)言映射為下面的編程語(yǔ)言: HYPERLINK /icecpp.htmlC+ICE語(yǔ)言映射為c+結(jié)合了原始速度與一個(gè)優(yōu)雅的設(shè)計(jì),提高了生產(chǎn)效率,基本上消除內(nèi)存泄漏。HYPERLINK /icej.htmlJavaJava的可移植性和財(cái)富的工具是一

54、個(gè)有吸引力的補(bǔ)充的ICE,ICE和支持Android允許應(yīng)用程序運(yùn)行在谷歌的生態(tài)系統(tǒng)設(shè)備上。HYPERLINK /icedotnet.html.NET.NET同時(shí)兼容微軟和Mono,開(kāi)發(fā)人員可以利用ICE的整合他們。網(wǎng)絡(luò)應(yīng)用程序。嵌入式和移動(dòng)設(shè)備的使用。凈緊湊的框架還可以使用ICE。HYPERLINK /icepy.htmlPythonICE層Python提供了無(wú)縫地訪問(wèn)ICE資源從這個(gè)流行的腳本語(yǔ)言。HYPERLINK /icephp.htmlPHP動(dòng)態(tài)web應(yīng)用程序可以擴(kuò)大到分布式對(duì)象為PHP使用ICE。HYPERLINK /iceobjc.htmlObjective-C支持iPhone、

55、iPod touch, Cocoa,OS X操作系統(tǒng),開(kāi)發(fā)人員可以使用ICE應(yīng)用到蘋(píng)果的移動(dòng)設(shè)備。 對(duì)象的創(chuàng)建和存在時(shí)間從技術(shù)角度說(shuō),OOP(面向?qū)ο蟪绦蛟O(shè)計(jì))只是涉及抽象的數(shù)據(jù)類型、繼承以及多形性,但另一些問(wèn)題也可能顯得非常重要。本節(jié)將就這些問(wèn)題進(jìn)行探討。最重要的問(wèn)題之一是對(duì)象的創(chuàng)建及破壞方式。對(duì)象需要的數(shù)據(jù)位于哪兒,如何控制對(duì)象的“存在時(shí)間”呢?針對(duì)這個(gè)問(wèn)題,解決的方案是各異其趣的。C+認(rèn)為程序的執(zhí)行效率是最重要的一個(gè)問(wèn)題,所以它允許程序員作出選擇。為獲得最快的運(yùn)行速度,存儲(chǔ)以及存在時(shí)間可在編寫(xiě)程序時(shí)決定,只需將對(duì)象放置在堆棧(有時(shí)也叫作自動(dòng)或定域變量)或者靜態(tài)存儲(chǔ)區(qū)域即可。這樣便為存儲(chǔ)空

56、間的分配和釋放提供了一個(gè)優(yōu)先級(jí)。某些情況下,這種優(yōu)先級(jí)的控制是非常有價(jià)值的。然而,我們同時(shí)也犧牲了靈活性,因?yàn)樵诰帉?xiě)程序時(shí),必須知道對(duì)象的準(zhǔn)確的數(shù)量、存在時(shí)間、以及類型。如果要解決的是一個(gè)較常規(guī)的問(wèn)題,如計(jì)算機(jī)輔助設(shè)計(jì)、倉(cāng)儲(chǔ)管理或者空中交通控制,這一方法就顯得太局限了。第二個(gè)方法是在一個(gè)內(nèi)存池中動(dòng)態(tài)創(chuàng)建對(duì)象,該內(nèi)存池亦叫“堆”或者“內(nèi)存堆”。若采用這種方式,除非進(jìn)入運(yùn)行期,否則根本不知道到底需要多少個(gè)對(duì)象,也不知道它們的存在時(shí)間有多長(zhǎng),以及準(zhǔn)確的類型是什么。這些參數(shù)都在程序正式運(yùn)行時(shí)才決定的。若需一個(gè)新對(duì)象,只需在需要它的時(shí)候在內(nèi)存堆里簡(jiǎn)單地創(chuàng)建它即可。由于存儲(chǔ)空間的管理是運(yùn)行期間動(dòng)態(tài)進(jìn)行的,

57、所以在內(nèi)存堆里分配存儲(chǔ)空間的時(shí)間比在堆棧里創(chuàng)建的時(shí)間長(zhǎng)得多(在堆棧里創(chuàng)建存儲(chǔ)空間一般只需要一個(gè)簡(jiǎn)單的指令,將堆棧指針向下或向下移動(dòng)即可)。由于動(dòng)態(tài)創(chuàng)建方法使對(duì)象本來(lái)就傾向于復(fù)雜,所以查找存儲(chǔ)空間以及釋放它所需的額外開(kāi)銷(xiāo)不會(huì)為對(duì)象的創(chuàng)建造成明顯的影響。除此以外,更大的靈活性對(duì)于常規(guī)編程問(wèn)題的解決是至關(guān)重要的。C+允許我們決定是在寫(xiě)程序時(shí)創(chuàng)建對(duì)象,還是在運(yùn)行期間創(chuàng)建,這種控制方法更加靈活。大家或許認(rèn)為既然它如此靈活,那么無(wú)論如何都應(yīng)在內(nèi)存堆里創(chuàng)建對(duì)象,而不是在堆棧中創(chuàng)建。但還要考慮另外一個(gè)問(wèn)題,亦即對(duì)象的“存在時(shí)間”或者“生存時(shí)間”(Lifetime)。若在堆棧或者靜態(tài)存儲(chǔ)空間里創(chuàng)建一個(gè)對(duì)象,編譯

58、器會(huì)判斷對(duì)象的持續(xù)時(shí)間有多長(zhǎng),到時(shí)會(huì)自動(dòng)“破壞”或者“清除”它。程序員可用兩種方法來(lái)破壞一個(gè)對(duì)象:用程序化的方式?jīng)Q定何時(shí)破壞對(duì)象,或者利用由運(yùn)行環(huán)境提供的一種“垃圾收集器”特性,自動(dòng)尋找那些不再使用的對(duì)象,并將其清除。當(dāng)然,垃圾收集器顯得方便得多,但要求所有應(yīng)用程序都必須容忍垃圾收集器的存在,并能默許隨垃圾收集帶來(lái)的額外開(kāi)銷(xiāo)。但這并不符合C+語(yǔ)言的設(shè)計(jì)宗旨,所以未能包括到C+里。但Java確實(shí)提供了一個(gè)垃圾收集器(Smalltalk也有這樣的設(shè)計(jì);盡管Delphi默認(rèn)為沒(méi)有垃圾收集器,但可選擇安裝;而C+亦可使用一些由其他公司開(kāi)發(fā)的垃圾收集產(chǎn)品)。9JWKffwvG#tYM*Jg&6a*CZ7

59、H$dq8KqqfHVZFedswSyXTy#&QA9wkxFyeQ!djs#XuyUP2kNXpRWXmA&UE9aQGn8xp$R#͑GxGjqv$UE9wEwZ#QcUE%&qYpEh5pDx2zVkum&gTXRm6X4NGpP$vSTT#&ksv*3tnGK8!z89AmYWpazadNu#KN&MuWFA5uxY7JnD6YWRrWwcvR9CpbK!zn%Mz849GxGjqv$UE9wEwZ#QcUE%&qYpEh5pDx2zVkum&gTXRm6X4NGpP$vSTT#&ksv*3tnGK8!z89AmYWpazadNu#KN&MuWFA5uxGjqv$UE9wEwZ

60、#QcUE%&qYpEh5pDx2zVkum&gTXRm6X4NGpP$vSTT#&ksv*3tnGK8!z89AmYWpazadNu#KN&MuWFA5uxY7JnD6YWRrWwcvR9CpbK!zn%Mz849GxGjqv$UE9wEwZ#QcUE%&qYpEh5pDx2zVkum&gTXRm6X4NGpP$vSTT#&ksv*3tnGK8!z89AmUE9aQGn8xp$R#͑GxGjqv$UE9wEwZ#QcUE%&qYpEh5pDx2zVkum&gTXRm6X4NGpP$vSTT#&ksv*3tnGK8!z89AmYWpazadNu#KN&MuWFA5uxY7JnD6YWR

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論