网上书店管理系统外文资料翻译中文版

合集下载

在线图书管理系统外文文献原文及译文

在线图书管理系统外文文献原文及译文

毕业设计说明书英文文献及中文翻译班姓 名:学 院:专指导教师:2014 年 6 月软件学院 软件工程An Introduction to JavaThe first release of Java in 1996 generated an incredible amount of excitement, not just in the computer press, but in mainstream media such as The New York Times, The Washington Post, and Business Week. Java has the distinction of being the first and only programming language that had a ten-minute story on National Public Radio. A $100,000,000 venture capital fund was set up solely for products produced by use of a specific computer language. It is rather amusing to revisit those heady times, and we give you a brief history of Java in this chapter.In the first edition of this book, we had this to write about Java: “As a computer language, Java’s hype is overdone: Java is certainly a good program-ming language. There is no doubt that it is one of the better languages available to serious programmers. We think it could potentially have been a great programming language, but it is probably too late for that. Once a language is out in the field, the ugly reality of compatibility with existing code sets in.”Our editor got a lot of flack for this paragraph from someone very high up at Sun Micro- systems who shall remain unnamed. But, in hindsight, our prognosis seems accurate. Java has a lot of nice language features—we examine them in detail later in this chapter. It has its share of warts, and newer additions to the language are not as elegant as the original ones because of the ugly reality of compatibility.But, as we already said in the first edition, Java was never just a language. There are lots of programming languages out there, and few of them make much of a splash. Java is a whole platform, with a huge library, containing lots of reusable code, and an execution environment that provides services such as security, portability across operating sys-tems, and automatic garbage collection.As a programmer, you will want a language with a pleasant syntax and comprehensible semantics (i.e., not C++). Java fits the bill, as do dozens of other fine languages. Some languages give you portability, garbage collection, and the like, but they don’t have much of a library, forcing you to roll your own if you want fancy graphics or network- ing or database access. Well, Java has everything—a good language, a high-quality exe- cution environment, and a vast library. That combination is what makes Java an irresistible proposition to so many programmers.SimpleWe wanted to build a system that could be programmed easily without a lot of eso- teric training and which leveraged t oday’s standard practice. So even though wefound that C++ was unsuitable, we designed Java as closely to C++ as possible in order to make the system more comprehensible. Java omits many rarely used, poorly understood, confusing features of C++ that, in our experience, bring more grief than benefit.The syntax for Java is, indeed, a cleaned-up version of the syntax for C++. There is no need for header files, pointer arithmetic (or even a pointer syntax), structures, unions, operator overloading, virtual base classes, and so on. (See the C++ notes interspersed throughout the text for more on the differences between Java and C++.) The designers did not, however, attempt to fix all of the clumsy features of C++. For example, the syn- tax of the switch statement is unchanged in Java. If you know C++, you will find the tran- sition to the Java syntax easy. If you are used to a visual programming environment (such as Visual Basic), you will not find Java simple. There is much strange syntax (though it does not take long to get the hang of it). More important, you must do a lot more programming in Java. The beauty of Visual Basic is that its visual design environment almost automatically pro- vides a lot of the infrastructure for an application. The equivalent functionality must be programmed manually, usually with a fair bit of code, in Java. There are, however, third-party development environments that provide “drag-and-drop”-style program development.Another aspect of being simple is being small. One of the goals of Java is to enable the construction of software that can run stand-alone in small machines. The size of the basic interpreter and class support is about 40K bytes; adding the basic stan- dard libraries and thread support (essentially a self-contained microkernel) adds an additional 175K.This was a great achievement at the time. Of course, the library has since grown to huge proportions. There is now a separate Java Micro Edition with a smaller library, suitable for embedded devices.Object OrientedSimply stated, object-oriented design is a technique for programming that focuses on the data (= objects) and on the interfaces to that object. To make an analogy with carpentry, an “object-oriented” carpenter would be mostly concerned with the chair he was building, and secondari ly with the tools used to make it; a “non-object- oriented” carpenter would think primarily of his tools. The object-oriented facilities of Java are essentially those of C++.Object orientation has proven its worth in the last 30 years, and it is inconceivable that a modern programming language would not use it. Indeed, the object-oriented features of Java are comparable to those of C++. The major difference between Java and C++ lies in multiple inheritance, which Java has replaced with the simpler concept of interfaces, and in the Java metaclass model (which we discuss in Chapter 5). NOTE: If you have no experience with object-oriented programming languages, you will want to carefully read Chapters 4 through 6. These chapters explain what object-oriented programming is and why it is more useful for programming sophisticated projects than are traditional, procedure-oriented languages like C or Basic.Network-SavvyJava has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP. Java applications can open and access objects across the Net via URLs with the same ease as when accessing a local file system.We have found the networking capabilities of Java to be both strong and easy to use. Anyone who has tried to do Internet programming using another language will revel in how simple Java makes onerous tasks like opening a socket connection. (We cover net- working in V olume II of this book.) The remote method invocation mechanism enables communication between distributed objects (also covered in V olume II).RobustJava is intended for writing programs that must be reliable in a variety of ways.Java puts a lot of emphasis on early checking for possible problems, later dynamic (runtime) checking, and eliminating situations that are error-prone. The single biggest difference between Java and C/C++ is that Java has a pointer model that eliminates the possibility of overwriting memory and corrupting data.This feature is also very useful. The Java compiler detects many problems that, in other languages, would show up only at runtime. As for the second point, anyone who has spent hours chasing memory corruption caused by a pointer bug will be very happy with this feature of Java.If you are coming from a language like Visual Basic that doesn’t explicitly use pointers, you are probably wondering why this is so important. C programmers are not so lucky. They need pointers to access strings, arrays, objects, and even files. In Visual Basic, you do not use pointers for any of these entities, nor do you need to worry about memory allocation for them. On the other hand, many data structures are difficult to implementin a pointerless language. Java gives you the best of both worlds. You do not need point- ers for everyday constructs like strings and arrays. You have the power of pointers if you need it, for example, for linked lists. And you always have complete safety, because you can never access a bad pointer, make memory allocation errors, or have to protect against memory leaking away.Architecture NeutralThe compiler generates an architecture-neutral object file format—the compiled code is executable on many processors, given the presence of the Java runtime sys- tem. The Java compiler does this by generating bytecode instructions which have nothing to do with a particular computer architecture. Rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on the fly.This is not a new idea. More than 30 years ago, both Niklaus Wirth’s original implemen- tation of Pascal and the UCSD Pascal system used the same technique.Of course, interpreting bytecodes is necessarily slower than running machine instruc- tions at full speed, so it isn’t clear that this is even a good idea. However, virtual machines have the option of translating the most frequently executed bytecode sequences into machine code, a process called just-in-time compilation. This strategy has proven so effective that even Microsoft’s .NET platform relies on a virt ual machine.The virtual machine has other advantages. It increases security because the virtual machine can check the behavior of instruction sequences. Some programs even produce bytecodes on the fly, dynamically enhancing the capabilities of a running program.PortableUnlike C and C++, there are no “implementation-dependent” aspects of the specifi- cation. The sizes of the primitive data types are specified, as is the behavior of arith- metic on them.For example, an int in Java is always a 32-bit integer. In C/C++, int can mean a 16-bit integer, a 32-bit integer, or any other size that the compiler vendor likes. The only restriction is that the int type must have at least as many bytes as a short int and cannot have more bytes than a long int. Having a fixed size for number types eliminates a major porting headache. Binary data is stored and transmitted in a fixed format, eliminating confusion about byte ordering. Strings are saved in a standard Unicode format. The libraries that are a part of the system define portable interfaces. For example,there is an abstract Window class and implementations of it for UNIX, Windows, and the Macintosh.As anyone who has ever tried knows, it is an effort of heroic proportions to write a pro- gram that looks good on Windows, the Macintosh, and ten flavors of UNIX. Java 1.0 made the heroic effort, delivering a simple toolkit that mapped common user interface elements to a number of platforms. Unfortunately, the result was a library that, with a lot of work, could give barely acceptable results on different systems. (And there were often different bugs on the different platform graphics implementations.) But it was a start. There are many applications in which portability is more important than user interface slickness, and these applications did benefit from early versions of Java. By now, the user interface toolkit has been completely rewritten so that it no longer relies on the host user interface. The result is far more consistent and, we think, more attrac- tive than in earlier versions of Java.InterpretedThe Java interpreter can execute Java bytecodes directly on any machine to which the interpreter has been ported. Since linking is a more incremental and lightweight process, the development process can be much more rapid and exploratory.Incremental linking has advantages, but its benefit for the development process is clearly overstated. Early Java development tools were, in fact, quite slow. Today, the bytecodes are translated into machine code by the just-in-time compiler.MultithreadedThe benefits of multithreading are better interactive responsiveness and real-time behavior.If you have ever tried to do multithreading in another language, you will be pleasantly surprised at how easy it is in Java. Threads in Java also can take advantage of multi- processor systems if the base operating system does so. On the downside, thread imple- mentations on the major platforms differ widely, and Java makes no effort to be platform independent in this regard. Only the code for calling multithreading remains the same across machines; Java offloads the implementation of multithreading to the underlying operating system or a thread library. Nonetheless, the ease of multithread- ing is one of the main reasons why Java is such an appealing language for server-side development.Java程序设计概述1996年Java第一次发布就引起了人们的极大兴趣。

书店销售管理信息系统-参考译文_孙凯

书店销售管理信息系统-参考译文_孙凯

外文资料翻译—译文部分管理信息系统(Management Information System,简称MIS)(摘自O’Brien, J (1999). Management Information Systems – Managing Information Technology in theInternetworked Enterprise. Boston: Irwin McGraw-Hill)1 MIS定义2 MIS的特性3 MIS的划分4 MIS的开发4.1 MIS的开发原则4.2 MIS的开发方式4.3 MIS的开发策略4.4 MIS的开发方法5 相关条目MIS定义所谓MIS(管理信息系统--Management Information System)系统,是一个由人、计算机及其他外围设备等组成的能进行信息的收集、传递、存贮、加工、维护和使用的系统。

它是一门新兴的科学,其主要任务是最大限度的利用现代计算机及网络通讯技术加强企业信息管理,通过对企业拥有的人力、物力、财力、设备、技术等资源的调查了解,建立正确的数据,加工处理并编制成各种信息资料及时提供给管理人员,以便进行正确的决策,不断提高企业的管理水平和经济效益。

目前,企业的计算机网络已成为企业进行技术改造及提高企业管理水平的重要手段。

随着我国与世界信息高速公路的接轨,企业通过计算机网络获得信息必将为企业带来巨大的经济效益和社会效益,企业的办公及管理都将朝着高效、快速、无纸化的方向发展。

MIS系统通常用于系统决策,例如,可以利用MIS系统找出目前迫切需要解决的问题,并将信息及时反馈给上层管理人员,使他们了解当前工作发展的进展或不足。

换句话说,MIS 系统的最终目的是使管理人员及时了解公司现状,把握将来的发展路径。

MIS的特性完善的MIS具有以下四个标准:确定的信息需求、信息的可采集与可加工、可以通过程序为管理人员提供信息、可以对信息进行管理。

图书管理系统外文翻译

图书管理系统外文翻译

VC database with ADO access to all Raiders1, ADO OverviewADO is Microsoft for the latest and most powerful data access paradigm designed OLE DB is an easy to use application layer interfaces. ADO allows you to write applications through OLE. DB provider to access and manipulate the data in the database server. ADO The main advantage is ease of use, speed, memory and disk less expenditure remains small. ADO in critical applications using the least network traffic, and front-end and data sources used the least number of layers, all of which are to provide a lightweight, high-performance interface. Is called ADO, is a familiar metaphor, OLE Automation interface.OLE DB is a set of "Component Object Model" (COM) interface, a new database low-level interface that encapsulates the ODBC functions, and in a uniform way to access information stored in different data sources. OLE DB is Microsoft UDA (Universal Data Access) technology base strategy. OLE DB data source provided for any high-performance access to these data sources including relational and non-relational databases, e-mail and file systems, text and graphics, custom business objects, and more. In other words, OLE DB is not limited to ISAM, Jet and even relational data source, it can handle any type of data, regardless of their format and storage methods. In practice, this diversity means to access resides in Excel spreadsheets, text files, e-mail / directory service or e-mail server, such as Microsoft Exchange in the data. However, OLE DB application programming interface is intended to provide the best variety of application functions, it does not meet the requirements of simplicity. You need to be an API to connect applications and OLE DB bridge, which is ActiveX Data Objects (ADO).Second, the use of VC ADO (developed as follows:)1, the introduction of ADO libraryUse ADO in the works before the stdafx.h header file # import symbols with the introduction of direct introduction of ADO libraries to enable the compiler to compile correctly. Code is as follows:With the introduction of ADO library files # import# Import "c: program filescommon filessystemadomsado15.dll" no_namespaces rename ("EOF" adoEOF ")This line statement used in the project statement ADO, but ADO does not use the name space, and in order to avoid constant conflict, the constant EOF renamed adoEOF. Now no need to add another header file, you can use ADO interface to the.2, initialize OLE / COM library environmentImportant to note that, ADO COM library is a set of dynamic libraries, which means that the application before calling the ADO, you must initialize the OLE / COM library environment. In the MFC application, where a better approach is the application's InitInstance member functionof the main class is initialized OLE / COM library environment.BOOL CMyAdoTestApp:: InitInstance ()(if (! AfxOleInit ())// initialize the COM library which is(AfxMessageBox ("OLE Initialization Error!");return FALSE;)... ...)3, ADO Interface DescriptionADO library consists of three basic interfaces: _ConnectionPtr interfaces, _CommandPtr interface and _RecordsetPtr interfaces._ConnectionPtr Interface to return a record set or a null pointer. Often use it to create a data connection or perform a non-SQL statement that returns no results, such as a stored procedure. Use _ConnectionPtr Interface returns a recordset is not a good use. To return records for the operation is usually achieved with _RecordserPtr. The use of _ConnectionPtr operation to obtain a number of records may traverse all the records, but does not need to use _RecordserPtr._CommandPtr Interface returns a recordset. It provides a simple way to implement a stored procedure that returns a recordset and SQL statements. Using _CommandPtr interface, you can use the global _ConnectionPtr interface can also be used directly in the _CommandPtr interfaces in connection string. If you only implement one or more data access operation, which is a better choice. But if you want frequent access to the database, and to return many records set, then you should use the global _ConnectionPtr interface to create a data connection, and then use _CommandPtr interface to execute stored procedures and SQL statements._RecordsetPtr Is a recordset object. Compared with the above two objects, it provides a record set more control features, such as record locking, cursor control. Interface with _CommandPtr as it does not necessarily have to use an already created data connection, you can connect using a connection string instead of a pointer member variable assigned to _RecordsetPtr the connection, let it create a data connection. If you want to use multiple record sets, the best method is the same as with the Command object has already created a data connection using the global _ConnectionPtr Interface, And then use _RecordsetPtr SQL statement stored procedures and implementation.4, using _ConnectionPtr Interface_ConnectionPtr Is primarily a connection interface, made with the database. Its own direct connection string can be written, you can also point to an ODBC DSN._ConnectionPtr PConn;if (FAILED (pConn.CreateInstance ("ADODB.Connection")))(AfxMessageBox ("Create Instance failed!");return;)CString strSRC;strSRC = "Driver = SQL Server; Server =";strSRC + = "suppersoft";strSRC + = "; Database =";strSRC + = "mydb";strSRC + = "; UID = SA; PWD =";CString strSQL = "Insert into student (no, name, sex, address) values (3,''aaa'','' male'','' beijing'')";_variant_t varSRC (strSRC);_variant_t varSQL (strSQL);_bstr_t bstrSRC (strSRC);if (FAILED (pConn-> Open (bstrSRC ,"","",- 1)))(AfxMessageBox ("Can not open Database!");pConn.Release ();return;)COleVariant vtOptional ((long) DISP_E_PARAMNOTFOUND, VT_ERROR);pConn-> Execute (_bstr_t (strSQL), & vtOptional, -1);pConn.Release ();AfxMessageBox ("ok!");5, using _RecordsetPtr interface (to connect to SQL Server as an example)_RecordsetPtr PPtr;if (FAILED (pPtr.CreateInstance ("ADODB.Recordset")))(AfxMessageBox ("Create Instance failed!");return FALSE;)CString strSRC;strSRC = "Driver = SQL Server; Server =";strSRC + = "210.46.141.145";strSRC + = "; Database =";strSRC + = "mydb";strSRC + = "; UID = sa; PWD =";strSRC + = "sa";CString strSQL = "select id, name, gender, address from personal";_variant_t varSRC (strSRC);_variant_t varSQL (strSQL);if (FAILED (pPtr-> Open (varSQL, varSRC, adOpenStatic, adLockOptimistic, adCmdText))) (AfxMessageBox ("Open table failed!");pPtr.Release ();return FALSE;)while (! pPtr-> GetadoEOF ())(_variant_t varNo;_variant_t varName;_variant_t varSex;_variant_t varAddress;varNo = pPtr-> GetCollect ("id");varName = pPtr-> GetCollect ("name");varSex = pPtr-> GetCollect ("gender");varAddress = pPtr-> GetCollect ("address");CString strNo = (char *) _bstr_t (varNo);CString strName = (char *) _bstr_t (varName);CString strSex = (char *) _bstr_t (varSex);CString strAddress = (char *) _bstr_t (varAddress);strNo.TrimRight ();strName.TrimRight ();strSex.TrimRight ();strAddress.TrimRight ();int nCount = m_list.GetItemCount ();int nItem = m_list.InsertItem (nCount, _T (""));m_list.SetItemText (nItem, 0, strNo);m_list.SetItemText (nItem, 1, strName);m_list.SetItemText (nItem, 2, strSex);m_list.SetItemText (nItem, 3, strAddress);pPtr-> MoveNext ();)pPtr-> Close ();pPtr.Release ();6, using _CommandPtr Interface_CommandPtr Returns a Recordset object interfaces, and provides more control recordset, the following code sample using _CommandPtr interface methods:Code: access to data using _CommandPtr Interface_CommandPtr PCommand;_RecordsetPtr PRs;pCommand.CreateInstance (__uuidof (Command));pCommand-> ActiveConnection = pConn;pCommand-> CommandText = "select backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar.gz xml2dict-read-only from student ";pCommand-> CommandType = adCmdText;pCommand-> Parameters-> Refresh ();pRs = pCommand-> Execute (NULL, NULL, adCmdUnknown);_variant_t varValue = pRs-> GetCollect ("name");Cstring strValue = (char *) _bstr_t (varValue);7, about data type conversion because COM objects are cross-platform, it uses a generic way to handle all types of data, Cstring classes and COM objects are not compatible, we need a set of API to convert the COM object and C + + types of data. _vatiant_t and _bstr_t are two such objects. They provide a common way to convert C + + COM object and t he type of data.。

商城购物系统设计中英文对照外文翻译文献

商城购物系统设计中英文对照外文翻译文献

商城购物系统设计中英文对照外文翻译文献Abstract: Servlet programs run on the server side, ___ CGI-like technologies, Java Servlet has higher efficiency, easier to use, more powerful ns, better portability, and more cost savings.Keywords: ___, Servlet, HTTP service1.1 n of ServletServlets are Java programs that run on web or n servers. It is a middleware that connects requests from web browsers or other HTTP client programs and databases or ns on HTTP servers. The work of the servlet is to perform the tasks of the Simeon, as shown in Figure 1.1.Figure 1.1 The role of web middleware(1) Read explicit data ______ by end users in HTML forms on the page. However, data may also come from applets or custom HTTP client programs. (2) Read implicit request data sent by the browserFigure 1.1 shows a single arrow from the client to the web server, but in fact, there are two types of data transmitted from the client to the web server, which are explicit data entered by the user in the form and background HTTP n. Both types of data are important. HTTP n includes cookies, media types recognized by browsers, ___.(3) Generate resultsThis process may require accessing a database, performing RMI or EJB calls, calling web services, or directly calculating the corresponding response. The actual data may be stored in a nal database. The database may not understand HTTP or may not be able to return results in HTML form, so web browsers ___ with the database. Even if it can do this, for security reasons, we do not want it to do so. Similar ___, we need the web middleware to extract input data from the HTTP stream, communicate with the n, and embed the results into the document.(4) ___) to usersThis document can be sent in us formats, including text (HTML or XML), binary (GIF graphics), ___ underlying formats, such as gzip. However, HTML is the most commonly used formatso far, so one of the important tasks of Servlet and JSP is to wrap the results in HTML.(5) Send implicit HTTP response data to users总之,动态构建网页可以根据具体情况灵活地生成页面,从而满足客户的需求。

管理信息系统外文翻译

管理信息系统外文翻译

毕业设计(论文)外文资料翻译系 :专 业:姓 名:学 号:外文出处: Madiha shah procedia-social and附 件 :1.外文资料翻译译文;2.外文原文(用外文写)附件1:外文资料翻译译文管理信息系统(MIS)对学校的影响-----文献报告Madiha Shah Malaysia. Malaya大学马来西亚摘要鉴于其快捷和有效性,教育管理信息技术的使用已迅速增加。

在其发展的初始阶段,管理信息系统(MIS)的主要目的和使用是改善学校办公室活动的效率。

它是用于存储的学生和全体职工的数据。

最重要的的是重要数据录入和整理,而不是在数据传输或分析。

管理信息的价值当时被人们公认。

在集成阶段,全盘回顾文献,其强调积极影响学校管理和管理信息系统管理,包括更好的可访问性信息,更有效的管理,学校资源更高的利用率同时也减少了工作量,更好的时间管理,提高报告的质量。

对于信息管理系统,大量的抑制剂的使用在文献中很明显,其中最重要的是缺乏时间,缺乏信心或能力,缺乏培训,缺乏高层管理人员的支持,缺乏技术支持等。

管理信息系统可以提供所需的信息通知计划、决策和评估方面相关的管理员和教师。

管理信息系统改变了学校管理领域的领导、决策、工作负载、人力资源管理、沟通、责任,规划等方方面面。

这些系统可以帮助学校管理者在决定学校的目标,制定战略计划,分配资源,评估员工的绩效以及组织时更加顺利。

关键词: 管理信息系统、MIS 、学校管理、学校管理。

1、介绍电脑被视为有潜力在教学、学习和学校的管理方面做出重大的贡献。

信息和介绍通信技术(ICT)进入到学校包括硬件、软件、网络和员工发展的广泛的投资被认为是值得的前提。

如果有证据表明,它使在学校的表现和产生相应的影响有效性(Condie et al .,2007)真实存在。

利用信息技术在教育管理就会由于其效率和迅速增加有效性。

学校管理人员花大量的时间用于解决复杂的分配问题(如人员分配、资源分配、时间安排)和监控学校的操作已经有了更好的选择旨运用发展该技术。

图书管理系统外文资料翻译

图书管理系统外文资料翻译

图书管理系统外文资料翻译在当今数字化时代,图书管理系统在图书馆、学校、企业和各类研究机构中扮演着至关重要的角色。

为了更好地了解和掌握这一领域的先进技术和理念,对相关外文资料的翻译工作显得尤为重要。

图书管理系统是一个复杂但高效的信息化工具,它旨在优化图书的存储、检索、借阅和归还等流程。

外文资料通常包含了最新的研究成果、技术创新以及国际上的最佳实践案例,对于提升我国图书管理系统的水平具有极大的参考价值。

翻译图书管理系统的外文资料并非易事,需要译者具备多方面的能力和知识。

首先,译者需要精通相关的专业术语。

图书管理系统涉及到数据库管理、信息技术、图书馆学等多个领域的专业词汇,如“cataloguing”(编目)、“metadata”(元数据)、“circulation control”(流通控制)等。

准确理解和翻译这些术语对于传达原文的准确信息至关重要。

其次,译者要对图书管理系统的工作原理和流程有深入的了解。

只有这样,才能在翻译过程中准确把握原文的逻辑和含义,避免出现理解上的偏差。

例如,对于描述图书借阅流程的段落,译者需要清楚各个环节的先后顺序和相互关系,才能将其清晰地翻译出来。

此外,良好的语言表达能力也是必不可少的。

译文应该通顺流畅,符合目标语言的语法和表达习惯,让读者能够轻松理解。

同时,译者还需要注意保持原文的风格和语气,尽量忠实反映作者的意图。

在翻译过程中,还可能会遇到一些特殊的挑战。

例如,不同国家和地区的图书管理系统可能存在差异,某些概念和做法在国内可能没有对应的情况。

这时,译者需要在忠实原文的基础上,进行适当的解释和说明,以便读者能够理解。

另外,外文资料中的图表、公式和代码等内容也需要准确翻译。

对于图表,要确保标题和注释的翻译清晰准确;对于公式,要遵循数学符号的翻译规范;对于代码,要保证语法和逻辑的正确性。

为了提高翻译质量,译者通常会采用多种翻译方法和技巧。

直译是最常见的方法,适用于一些简单明了的语句和术语。

jsp网上商城系统毕业设计答辩外文文献及译文

jsp网上商城系统毕业设计答辩外文文献及译文

毕业设计说明书英文文献及中文翻译学生姓名:学号:学院:专业:指导教师:Struts——an open-source MVC implementationBy: Malcolm Davis.Source: Struts--an open-source MVC implementation[J].IBM Systems JournalThis article introduces Struts, a Model-View-Controller implementation that uses servlets and JavaServer Pages (JSP) technology. Struts can help you control change in your Web project and promote specialization. Even if you never implement a system with Struts,you may get some ideas for your future servlets and JSP page implementation.IntroductionKids in grade school put HTML pages on the Internet. However, there is a monumental difference between a grade school page and a professionally developed Web site. The page designer (or HTML developer) must understand colors, the customer, product flow, page layout, browser compatibility, image creation, JavaScript, and more. Putting a great looking site together takes a lot of work, and most Java developers are more interested in creating agreat looking object interface than a user interface. Java Server Pages (JSP) technology provides the glue between the page designer and the Java developer.If you have worked on a large-scale Web application, you understand the term change.Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data. Struts is an MVC implementation that uses Servlets 2.2 and JSP 1.1 tags, from the J2EE specifications, as part of the implementation. Y ou may never implement a system with Struts, but looking at Struts may give you some ideas on your future Servlets and JSP implementations.Model-View-Controller (MVC)JSP tags solved only part of our problem. We still have issues with validation, flow control, and updating the state of the application. This is where MVC comes to the rescue.MVC helps resolve some of the issues with the single module approach by dividing theproblem into three categories:• ModelThe model contains the core of the application's functionality. The model encapsulates thestate of the application. Sometimes the only functionality it contains is state. It knows nothing about the view or controller.• View• The view provides the presentation of the model. It is the look of the application. The view can access the model getters, but it has no knowledge of the setters. In addition, it knows nothing about the controller. The view should be notified when changes to the model occur. ControllerThe controller reacts to the user input. It creates and sets the model.MVC Model 2The Web brought some unique challenges to software developers, most notably the stateless connection between the client and the server. This stateless behavior made it difficult for the model to notify the view of changes. On the Web, the browser has to re-query the server to discover modification to the state of the application.Another noticeable change is that the view uses different technology for implementation than the model or controller. Of course, we could use Java (or PERL, C/C++ or what ever) code to generate HTML. There are several disadvantages to that approach:• Java programmers should develop services, not HTML.• Changes to layout would require changes to code.• Customers of the service should be able to create pages to meet their specific needs.• The page designer isn't able to have direct involvement in page development.• HTML embedded into code is ugly.For the Web, the classical form of MVC needed to change.MVC Model 2 Struts, an MVC 2 implementation Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. This definition implies that Struts is a framework, rather than a library, but Struts also contains an extensive tag library and utility classes that work independently of the framework.• Client browserAn HTTP request from the client browser creates an event. The Web container will respond with an HTTP response.• ControllerThe Controller receives the request from the browser, and makes the decision where to send the request. With Struts, the Controller is a command design pattern implemented as a servlet. The struts-config.xml file configures the Controller.• Business logicThe business logic updates the state of the model and helps control the flow of the application.With Struts this is done with an Action class as a thin wrapper to the actual business logic.• Model stateThe model represents the state of the application. The business objects update the application state. ActionForm bean represents the Model state at a session or request level, and not at a persistent level. The JSP file reads information from the ActionForm bean using JSP tags.• ViewThe view is simply a JSP file. There is no flow logic, no business logic, and no model information -- just tags. Tags are one of the things that make Struts unique compared to other frameworks like V elocity.Struts detailsDisplayed in Figure 6 is a stripped-down UML diagram of the org.apache.struts.action package and shows the minimal relationships among ActionServlet (Controller), ActionForm (Form State), and Action (Model Wrapper).The ActionServlet classDo you remember the days of function mappings? Y ou would map some input event to a ointer to a function. If you where slick, you would place the configuration information into ale and load the file at run time. Function pointer arrays were the good old days of structured rogramming in C.Life is better now that we have Java technology, XML, J2EE, and all that. The Struts ontroller is a servlet that maps events (an event generally being an HTTP post) to classes. guess what -- the Controller uses a configuration file so you don_t have to hard-code the alues. Life changes, but stays the same.ActionServlet is the Command part of the MVC implementation and is the core of the ramework. ActionServlet (Command) creates and uses Action, an ActionForm, and ctionForward. As mentioned earlier, the struts-config.xml file configures the command. uring the creation of the Web project, Action and ActionForm are extended to solve the pecific problem space. The file struts-config.xml instructs ActionServlet on how to use the xtended classes. There are several advantages to this approach:• The entire logical flow of the application is in a hierarchical text file. This makes itasier to view and understand, especially with large applications.• The page designer does not have to wade through Java code to understand the flow of e application.• The Java developer does not need to recompile code when making flow changes. Command functionality can be added by extending ActionServlet.The ActionForm classActionForm maintains the session state for the Web application. ActionForm is anbstract class that is sub-classed for each input form model. When I say input form model, Im saying ActionForm represents a general concept of data that is set or updated by a HTML form. For instance, you may have a UserActionForm that is set by an HTML Form. The Struts framework will:• Check to see if a UserActionForm exists; if not, it will create an instance of the class.• Struts will set the state of the UserActionForm using corresponding fields from the HttpServletRequest. No more dreadful request.getParameter() calls. For instance, the Struts framework will take fname from request stream and call UserActionForm.setFname().• The Struts framework updates the state of the UserActionForm before passing it to the business wrapper UserAction.• Before passing it to the Action class, Struts will also conduct form state validation by calling the validation() method on UserActionForm. Note: This is not always wise to do. There might be ways of using UserActionForm in other pages or business objects, where the validation might be different. V alidation of the state might be better in the UserAction class.• The UserActionForm can be maintained at a session level.Notes:• The struts-config.xml file controls which HTML form request maps to which ActionForm. • Multiple requests can be mapped UserActionForm.• UserActionForm can be mapped over multiple pages for things such as wizards.The Action classThe Action class is a wrapper around the business logic. The purpose of Action class is to translate the HttpServletRequest to the business logic. To use Action, subclass and overwrite the process() method.The ActionServlet (Command) passes the parameterized classes to ActionForm using the perform() method. Again, no more dreadful request.getParameter() calls. By the time the event gets here, the input form data (or HTML form data) has already been translated out of the request stream and into an ActionForm class.Note: "Think thin" when extending the Action class. The Action class should control the flow and not the logic of the application. By placing the business logic in a separate package or EJB, we allow flexibility and reuse.Another way of thinking about Action class is as the Adapter design pattern. The purpose of the Action is to "Convert the interface of a class into another interface the clients expect. Adapter lets classes work together that couldn_t otherwise because of incompatibility interface" (from Design Patterns - Elements of Reusable OO Software by Gof). The client in this instance is the ActionServlet that knows nothing about our specific business class interface. Therefore, Struts provides a business interface it does understand, Action. By extending the Action, we make our business interface compatible with Struts business interface. (An interesting observation is that Action is a class and not an interface. Action started as an interface and changed into a class over time. Nothing's perfect.)The Error classesThe UML diagram (Figure 6) also included ActionError and ActionErrors. ActionError encapsulates an individual error message. ActionErrors is a container of ActionError classes that the View can access using tags. ActionErrors is Struts way of keeping up with a list of errors.UML diagram of the relationship of the Command (ActionServlet) to the Model (Action) The ActionMapping classAn incoming event is normally in the form of an HTTP request, which the servlet Container turns into an HttpServletRequest. The Controller looks at the incoming event and dispatches the request to an Action class. The struts-config.xml determines what Action class the Controller calls. The struts-config.xml configuration information is translated into a set of ActionMapping, which are put into container of ActionMappings. (If you have not noticed it, classes that end with s are containers) The ActionMapping contains the knowledge of how a specific event maps to specific Actions. The ActionServlet (Command) passes the ActionMapping to the Action class via the perform() method. This allows Action to access the information to control flow.ActionMappingsActionMappings is a collection of ActionMapping objects.Struts pros Use of JSP tag mechanism The tag feature promotes reusable code and abstracts Java code from the JSP file. This feature allows nice integration into JSP-based development tools that allow authoring with tags.• Tag libraryWhy re-invent the wheel, or a tag library? If you cannot find something you need in the library, contribute. In addition, Struts provides a starting point if you are learning JSP tag technology.• Open sourceY ou have all the advantages of open source, such as being able to see the code and having everyone else using the library reviewing the code. Many eyes make for great code review.• Sample MVC implementationStruts offers some insight if you want to create your own MVC implementation.• Manage the problem spaceDivide and conquer is a nice way of solving the problem and making the problem manageable.中北大学2014届毕业设计英文文献译文Struts 一个开源的MVC实现作者:马尔科姆·戴维斯。

信息系统外文文献翻译

信息系统外文文献翻译

引言如今的世界,已经是步入了信息化的时代,特别是互联网的迅猛发展,带动了信息进入我们生活的各个领域,也使得信息化建设成为各行业、各领域增强自身管理效率和核心竞争力的重要手段。

出版业作为我国社会主义文化产业的一部分,在信息化建设方面相对于其他领域,有成绩是肯定的,但仍然显得滞后,建设水平不够高,离市场需求还有一定距离,还有很大的发展潜力,在我国信息化建设中应该发挥更大的作用。

同时要充分利用先进的电子信息技术改造出版业,来加快出版业信息化建设的步伐。

出版社信息化建设是用一种全新的、先进的管理理念,一种全新的机制,一种全新的企业文化来改变以前的管理模式,是一种管理模式的变革。

它充分利用信息技术与出版社管理模式的结合,来推动管理水平的提升。

面对日益激烈的竞争,出版社必须转变思路,确立全新的经营理念,确立以读者需求为中心,提供专业化的一流服务。

信息化建设更是一场管理体制的革命,它要用先进的思想模式和技术手段改变以前的管理模式,用数字化、规范化、程序化、标准化来进行管理,用量化的指标支持奖惩与分配政策,体现激励机制。

通过这场改革和革命,最终实现出版社的办公自动化、管理网络化、资源数字化、商务电子化。

而在整个的出版过程中,编务管理是出版行业信息管理系统的重要部分,它将编务人员及图书管理人员从繁重的事务性工作中解放出来,并使管理工作更透明、更科学,此次的系统如果有了良好的分析与设计,不但对编务管理,而且对整个出版行业的管理信息系统的建设都具有十分重要的意义。

本文将以北京科学技术出版社为例,为出版企业编务管理部门的信息化建设提出一个可行性方案,为将来的出版社进行信息化建设打下良好的基础。

附录1 外文翻译(原文)Systems Analysis and DesignWorking under control of a stored program, a computer processes data into information. Think about that definition for a minute. Any given computer application involves at least three components: hardware, software, and data. Merely writing a program isn't enough; because the program is but one component in a system.A system is a group of components that work together to accomplish an objective. For example, consider a payroll system. Its objective is paying employees. What components are involved? Each day,employees record their hours worked on time cards. At the end of each week, the time cards are collected and delivered to the computer center, where they are read into a payroll program. As it runs, the program accesses data files. Finally, the paychecks are printed and distributed. For the system to work, people, procedures, input and output media, files, hardware, and software must be carefully coordinated. Note that the program is but one component in a system.Computer-based systems are developed because people need information. Those people, called users, generally know what is required, but may lack the expertise to obtain it. Technical professionals, such as programmers, have the expertise, but may lack training in the user's field. To complicate matters, users and programmers often seem to speak different languages, leading to communication problems. A systems analyst is a professional who translates user needs into technical terms, thus serving as a bridge between users and technical professionals.Like an engineer or an architect, a systems analyst solves problems by combining solid technical skills with insight, imagination, and a touch of art. Generally, the analyst follows a well-defined, methodical process that includes at least the following steps;1.Problem definition2.Analysis3.Design4.Implementation5.MaintenanceAt the end of each step, results are documented and shared with both the user and the programmers. The idea is to catch and correct errors and misunderstandings asearly as possible. Perhaps the best way to illustrate the process is through example.Picture a small clothing store that purchases merchandise at wholesale, displays this stock, and sells it to customers at retail. On the one hand, too much stock represents an unnecessary expense. On the other hand, a poor selection discourages shoppers. Ideally, a balance can be achieved: enough, but not too much.Complicating matters is the fact that inventory is constantly changing, with customer purchases depleting stock, and returns and reorders adding to it. [1] The owner would like to track inventory levels and reorder and given item just before the store runs out. For a single item, the task is easy-just count the stock-on-hand. Unfortunately, the store has hundreds of different items, and keeping track of each one is impractical. Perhaps a computer might help.2-1 Problem DefinitionThe first step in the systems analysis and design process is problem definition. The analyst's objective is determining what the user (in this case, the store's owner) needs. Note that, as the process begins, the user possesses the critical information, and the analyst must listen and learn. Few users are technical experts. Most see the computer as a "magic box, "and are not concerned with how it works. At this stage, the analyst has no business even thinking about programs, files, and computer hardware, but must communicate with the user on his or her own term.The idea is to ensure that both the user and the analyst are thinking about the same thing-Thus, a clear, written statement expressing the analyst's understanding of the problem is essential. The user should review and correct this written statement. The time to catch misunderstandings and oversights is now, before time, money and effort are wasted.Often, following a preliminary problem definition, the analyst performs a feasibility study. The study a brief capsule version of the entire systems analysis and design process, attempts to answer three questions:1.Can the problem be solved?2.Can it be salved in the user's environment?3.Can it be solved at a reasonable cost?If the answer to any one of these questions is no, the system should not be developed. Given a good problem definition and a positive feasibility study, the analyst can turn to planning and developing a problem solution.2- 2 AnalysisAs analysis begins, the analyst understands the problem. The next step is determining what must be done to solve it. The user knows what must be done 1 during analysis; this knowledge is extracted and formally documented. Most users think in terms of the functions to be performed and the data elements to be manipulated. The objective is to identify and link these key functions and data elements, yielding a logical system design.Start with the system's basic functions. The key is keeping track of the stock-on-hand for each product in inventory. Inventory changes because customers purchase, exchange, and return products, so the system will have to process customer transactions. The store's owner wants to selectively look at the inventory level for any product in short supply and, if appropriate, order replacement stock, so the system must be able to communicate with management. Finally, following management authorization, the system should generate a reorder ready to send to a supplier.Fig 1Given the system's basic functions, the analyst's next task is gaining a sense of their logical relationship. A good way to start is by describing how data flow between the functions. As the name implies, data flow diagrams are particularly useful for graphically describing these data flows. Four symbols are used (Fig. 1). Data sources and destinations are represented by squares; input data enter the system from a source, and output data flow to a destination. Once in the system, the data are manipulated or change by processes, represented by round-corner rectangles. A process might be a program, a procedure, or anything else that changes or moves data. Data can be held for later processing in data stores, symbolized by open-ended rectangles. A data store might be a disk file, a tape file, a database, written notes, or even a person's memory. Finally, data flow between sources, destinations, processes, end data stores over data flows, which are represented by arrows.Fig 2Figure 2 shows a preliminary data flow diagram for the inventory system. Start with CUSTOMER. Transactions flow from a customer f into the system, where they are handled by Process transaction. A data store, STOCK, holds data on each item in inventory. Process transaction changes the data to reflect the new transaction. Meanwhile, MANAGEMENT accesses the system through Communicate, evaluating the data in STOCK and, if necessary, requesting a reorder. Once, a reorder is authorized. Generate reorder sends necessary data to the SUPPLIER, who ships the items to the store. Note that, because the reorder represents a change in the inventory level of a particular product or products it is handled as a transaction.The data flow diagram describes the logical system. The next step is tracing the data flows. Start with the destination SUPPLIER. Reorders flow to suppliers; for example, the store might want 25 pairs of jeans. To fill the order, the supplier needs the product description and the reorder quantity. Where do these data elements come from? Since they are output by Generate reorder, they must either be Input to or generated by this process. Data flow into Generate reorder for STOCK; thus, product descriptions and reorder quantities must be stored in STOCK.Other data elements, such as the item purchased and the purchase quantity are generated by CUSTOMER. Still others, for example selling price and reorder point, are generated by or needed by MANAGEMENT. The current stock-on-hand for a given item is an example of a data element generated by an algorithm in one of the procedures. Step by step, methodically, the analyst identifies the data elements to be input to .stored by, manipulated by, generated by, or output by the system.To keep track of the data elements, the analyst might list each one in a data dictionary. A simple data dictionary can be set up on index cards, but computerized data dictionaries have become increasingly popular. The data dictionary, a collectionof data describing and defining the data, is useful throughout the systems analysis and design process, and is often used to build a database during the implementation stage.The idea of analysis is to define the system's major functions and data elements methodically. Remember that the objective is translating user needs into technical terms. Since the system starts with the user, the first step is defining the user's needs. Users think in terms of functions and data. They do not visualize programs, or files, or hardware .and during this initial, crucial analysis stage it is essential that the analyst think like a user, not like a programmer.Data flow diagrams and data dictionaries are useful tools. They provide a format for recording key information about the proposed system. Also, they jog the analyst's memory) for example, if the analyst doesn't have sufficient information to complete a data dictionary entry, he or she has probably missed something. Perhaps most importantly, the data flow diagram and the data dictionary document the analyst's understanding of the system requirements. By reviewing these documents, the user can correct misunderstandings or oversights. Finally, they represent an excellent starting point the next step, design.2-3 DesignAs we enter the design stage, we know what the system must do, and thus can begin thinking about how to do it. The objective is to develop a strategy for solving the problem. At this stage, we are not interested in writing code or in defining precise data structures; instead, we want to identify, at a black box level, necessary programs, files, procedures, and other components.The data flow diagram defines the system's necessary functions; how might they be implemented? One possibility is writing one program for each process. Another is combining two or more processes in a single program; there are dozens of alternative solutions. Let's focus on one option and document it.A system flowchart uses symbols to represent programs, procedures, hardware devices, and the other components of a physical system (Fig. 3). Our flowchart (.Fig.4) shows that transaction data enter the system through a terminal, are processed by a data collection program, and then are stored on an inventory file. Eventually, the inventory file is processed by a Report and reorder program. Through it, management manipulates the data and authorizes reorders.Fig. 4 on a system flowchart, symbols represent programs, procedures, hardware devices, and the other components of a physical system.Fig 3Look at the system flowchart. It identifies several hardware components, including a computer, a disk drive, a data entry terminal, a printer, and a display terminal. Two programs are needed; Process transaction and Report and reorder. In addition to the hardware and the programs, we’ll need data structures for the inventory file and for data flaws between the I/O devices and the software. Note that this system flowchart illustrates one possible solution; a good analyst will develop several feasible alternatives before choosing one.Fig 4The flowchart maps the system, highlighting its major physical components. Since the data link the components, the next task is defining the data structures. Consider, for example, the inventory file. It contains all the data elements from the data store STOCK. The data elements are listed in the data dictionary. Using them, thefile's data structure can be planned,How should the file be organized? That depends on how it will be accessed. For example, in some applications, data are processed at regular, predictable intervals. Typically, the data are collected over time and processed together, as a batch. If batch processing is acceptable, a sequential file organization is probably best.It is not always possible to wait until a batch of transactions is collected, however. For example, consider an air defense early warning system. If an unidentified aircraft is spotted it must be identified immediately the idea of waiting until 5 _ 00 p.m. because "that's when the air defense program is run" is absurd. Instead, because of the need for quick response, each transaction must be processed as it occurs. Generally such transaction processing systems call for direct access file.Our inventory system has two programs. One processes transactions. A direct access inventory file seems a reasonable choice. The other allows management to study inventory data occasionally; batch processing would certainly do. Should the inventory file be organized sequentially or directly? Faced with such a choice a good analyst considers both options. One possible system might accept transactions and process them as they occur. As an alternative, sales slips might be collected throughout the day and processed as a batch after the store closes. In the first system, the two programs would deal with direct access files; in the second system, they would be linked to sequential files. A program to process direct access data is different from a program to process sequential data. The data drive the system. The choice of a data structure determines the program’s st ructure. Note that the program is defined and planned in the context of the system.2- 4 ImplementationOnce the system's major components have been identified .we can begin to develop them. Our system includes two programs, several pieces of equipment, and a number of data structures. During implementation, each program is planned and written using the techniques described in Chapter 7. Files are created, and their contents checked. New hardware is purchased, installed, and tested. Additionally, operating procedures are written and evaluated. Once all the component parts are ready, the system is tested. Assuming the user is satisfied, the finished system is released.2- 5 MaintenanceMaintenance begins after the system is released. As people use it, they will suggest minor improvements and enhancements. Occasionally, bugs slip through debug and testing, and removing them is another maintenance task. Finally, conditions change, and a program must be updated; for example, if the government passes a low changing the procedure for collecting income taxes, the payroll program must be modified. Maintenance continues for the life of a system, and its cost can easily match or exceed the original development cost. Good planning, solid documentation, and well-structured programs can help to minimize maintenance cost.附录2 外文翻译(译文)系统的分析与设计在存储程序的控制下,计算机把数据处理成信息。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

毕业设计(论文)外文资料翻译系 : 信息工程学院专 业: 计算机科学与技术姓 名: xxxxxx 学 号: xxxxxxxxx外文出处: Thinking.In.Java.4th.Edition附 件: 1.外文资料翻译译文;2.外文原文。

指导教师评语:签名:2011年 月 日(用外文写)附件1:外文资料翻译译文一切都是对象“如果我们说另一种不同的语言,那么我们就会发觉一个有些不同的世界”。

—Ludwig Wittgenstein(1889-1951) “尽管以C++为基础,但Java是一种更纯粹的面向对象程序设计语言”。

无论C++还是Java都属于杂合语言。

但在Java中,设计者觉得这种杂合并不像在C++里那么重要。

杂合语言允许采用多种编程风格;之所以说C++是一种杂合语言,是因为它支持与C语言的向后兼容能力。

由于C++是C的一个超集,所以包含的许多特性都是后者不具备的,这些特性使C++在某些地方显得过于复杂。

Java语言首先便假定了我们只希望进行面向对象的程序设计。

也就是说,正式用它设计之前,必须先将自己的思想转入一个面向对象的世界(除非早已习惯了这个世界的思维方式)。

只有做好这个准备工作,与其他OOP语言相比,才能体会到Java的易学易用。

在本章,我们将探讨Java 程序的基本组件,并体会为什么说Java乃至Java程序内的一切都是对象。

1.1 用句柄操纵对象每种编程语言都有自己的数据处理方式。

有些时候,程序员必须时刻留意准备处理的是什么类型。

您曾利用一些特殊语法直接操作过对象,或处理过一些间接表示的对象吗(C或C++里的指针)?所有这些在Java里都得到了简化,任何东西都可看作对象,。

因此,我们可采用一种统一的语法,任何地方均可照搬不误。

但要注意,尽管一切都“看作”对象,但操纵的标识符实际是指向一个对象的“句柄”(Handle)。

在其他Java参考书里,还可看到有的人将其称作一个“引用”,甚至一个“指针”。

可将这一情形想象成用遥控板(句柄)操纵电视机(对象)。

只要握住这个遥控板,就相当于掌握了与电视机连接的通道。

但一旦需要“换频道”或者“关小声音”,我们实际操纵的是遥控板(句柄),再有遥控板自己操纵电视机(对象)。

如果要在房间里四处走走,并想保持对电视机的控制,那么手上拿着的是遥控板,而非电视机。

此外,即使没有电视机,遥控板亦可独立存在。

也就是说,只是由于拥有一个句柄,并不表示必须有一个对象同它连接。

所以如果想容纳一个词或句子,可创建一个String句柄:String s;但这里创建的只是句柄,并不是对象。

若此时向s发送一条消息,就会获得一个错误(运行期)。

这是由于s实际并未与任何东西连接(即“没有电视机”)。

因此,一种更安全的做法是:创建一个句柄时,记住无论如何都进行初始化:String s = “zyp”;然而,这里用到了Java语言的一个特性:字串可以用加引号的文本初始化。

通常,必须为对象使用一种更通用的初始化方法。

1.2 有对象都必须创建创建句柄时,我们希望它用一个新对象连接。

通常用new关键字达到这一目标。

New的意思是:“把我变成这些对象的一种新类型”。

所以在上面的例子中,可以说:String s = new String(“asdf”);它不仅指出“给我一个新的字符串”,也通过提供一个初始字符串,指出了“如何生成这个新字串”。

当然,字串(String)并非唯一的类型。

Java配套提供了数量众多的现成类型。

对我们来讲,最重要的就是记住能自行创建类型。

事实上,这应是Java程序设计的一项基本操作,是继续本书后余部分学习的基础。

1.2.1 存储到什么地方程序运行时,我们最好对数据保存到什么地方做到心中有数。

特别要注意的是内存的分配。

有六个地方都可以保存数据:(1)寄存器。

这是最快的保存区域,因为它位于不同于其他存储区的地方——处理器内部。

然而,寄存器的数量十分有限,所以寄存器是根据需要由编译器分配。

我们对此没有直接的控制权,也不可能在自己的程序里找到寄存器存在的任何踪迹(另一方面,C和C++允许您向编译器建议寄存器的分配方式)。

(2)堆栈。

驻留于常规RAM(随机访问存储器)区域,但可通过它的“堆栈指针”获得处理的直接支持。

堆栈指针若向下移,会创建新的内存;若向上移,则会释放那些内存。

这是一种特别快、特别有效的数据保存方式,仅次于寄存器。

创建程序时,Java编译器必须准确地知道堆栈内保存的所有数据的“长度”以及“存在时间”。

这是由于它必须生成相应的代码,以便向上和向下移动指针。

这一限制无疑影响了程序的灵活性,所以尽管有些Java数据要保存在堆栈里——特别是对象句柄,但Java对象并不存储于其中。

(3)堆。

一种通用的内存池(也在RAM区域),用于存放所有的Java对象。

和堆栈不同,“内存堆”或“堆”(Heap)最吸引人的地方在于编译器不必知道要从堆里分配多少存储空间,也不必知道存储的数据要在堆里停留多长时间。

因此,用堆保存数据时会得到更大的灵活性。

要求创建一个对象时,只需要用new命令编制相关的代码即可。

执行这些代码时,会在堆里自动进行数据的保存。

当然,为达到这种灵活性,必然付出一定的代价:在堆里分配存储空间时会花掉更长的时间(如果确实可以在Java中像在C++中一样在栈中创建对象)。

(4)常量存储。

常数值通常直接置于程序代码内部。

这样做是安全的,因为他们永远都不会改变。

有的常数需要严格地保护,所以可考虑将他们置入只读存储器(ROM)。

(5)非RAM存储。

若数据完全独立于一个程序之外,则程序不运行时仍可存在,并在程序的控制范围之外。

其中两个最重要的例子便是“流式对象”和“持久化对象”。

对于流式对象,对象会转化成字节流,通常会发给另一台机器。

而对于持久化对象,对象保存在磁盘中。

即使程序中止运行,他们仍可保持自己的状态不变。

对于这些类型的数据存储,一个特别有用的技巧就是它们能存在于其他媒体中。

一旦需要,甚至能将他们恢复成普通的、基于RAM的对象。

Java 提供了对轻量级持久化的支持,而诸如JDBC和Hibernate这样的机制提供了更加复杂的对数据库中存储和读取对象信息的支持。

1.2.2 特例:基本类型在程序设计中经常用到一系列类型,他们需要特殊对待。

可以把他们想像成“基本”类型。

之所以特殊对待,是因为new将对象存储在“堆”里,故用new创建一个对象——特别是小的、简单的变量,往往不是很有效。

因此,对于这些类型,Java采取与C和C++相同的方法。

也就是说,不用new来创建变量,而是创建一个并非是引用的“自动”变量。

这个变量直接存储“值”,并置于堆栈中,因此更加高效。

Java要确定每种基本类型所占存储空间的大小。

他们的大小并不像其他大多数语言那样随机器硬件架构的变化而变化。

这种所占存储空间大小的不变性是Java程序比用其他大多数语言编写的程序更具可移植性的原因。

所有数值类型都有正负号,所以不要去寻找无符号的数值类型。

Boolean类型所占存储空间的大小没有明确指定,仅定义为能够取字面值true或false。

基本类型具有的包装器类,使得可以在堆中创建一个非基本对象,用来表示对应的基本类型。

例如:Char c = ‘x’;Character ch = new Character(c);也可以这样用:Character ch = new Character(‘x’);包装基本类型的原因将在以后的章节中说明。

高精度数字Java提供了两个用于高精度计算的类:BigInteger 或 BigDecimal。

虽然它们大体上属于“包装器类”的范畴,但二者都没有对应的基本类型。

不过,这两个类包含的方法,提供的操作与对基本类型所能执行的操作相识。

也就是说,能作用于int或float的操作,也能作用于BigInteger或Big Decimal。

只不过必须以方法调用方式取代运算符方式来实现。

由于这么做复杂了许多,所以运算速度会比较慢。

在这里,我们以速度换取了精度。

BigInteger支持任意精度的整数。

也就是说,在运算中,可以准确地表示任何大小的整数值,而不会丢失任何信息。

BigDecimal支持任何精度的定点数,例如,可以用它进行精确的货币计算。

关于调用这两个类的构造器和方法的详细信息,请查阅JDK文档。

1.2.2 Java中的数组几乎所有的程序设计语言都支持数组。

在C和C++中使用数组是很危险的,因为C和C++中的数组就是内存块。

如果一个程序要访问其自身内存块之外的数组,或在数组初始化前使用内存(程序中常见的错误),都会产生难以预料的后果。

Java的主要目标之一是安全性,所以许多在C和C++里困扰程序员的问题在Java里不会再出现呢。

Java确保数组会被初始化,而且不能在它的范围之外被访问。

这种范围检查,是以每个数组上少量的内存开销及运行时的下标检查为代价的。

但由此换来的是安全性和效率的提高,因此付出的代价是值得的(并且Java有时可以优化这些操作)。

当创建一个数组对象时,实际上就是创建了一个引用数组,并且每个引用都会自动初始化为一个特定值,该值拥有自己的关键字null。

一旦Java看到null,就知道这个引用还没有指向某个对象。

在使用任何引用前,必须为其指定一个对象;如果试图使用一个还是null的引用,在运行时将会报错。

因此,常犯的数组错误在Java中就可以避免。

还可以创建用来存放基本数据类型的数组。

同样,编译器也能确保这种数组的初始化,因为它会将这种数组所占的内存全部置零。

数组将在以后的章节中详细讨论。

1.3永远不需要销毁对象在大多数程序设计语言中,变量生命周期的概念,占据了程序设计工作中非常重要的部分。

变量需要存活多长时间?如果想要销毁对象,那什么时刻进行呢?变量生命周期的混乱往往会导致大量的程序bug,本节将介绍Java是怎样替我们完成所有的清理工作,从而大大简化这个问题的。

1.3.1 作用域大多数过程型语言都有作用域(scope)的概念。

作用域决定了在其内定义的变量名的可见性和生命周期。

在C、C++和Java中,作用域由花括号的位置决定。

例如:{int x = 12; //Only x available{int q = 96; //both x & q available}//only x available//q is “out of scope”}在作用域里定义的变量只可用于作用域结束之前。

任何位于“//”之后到行末的文字都是注释。

缩排格式使Java代码更易于阅读。

由于Java是一种自由格式(free-form)的语言,所以,空格、制表符、换行都不会影响程序的执行结果。

尽管以下代码在C和C++中是合法的,但是在Java中却不能这样写:{int x = 12;{int x = 96; //illegal}}编译器将会报告变量x已经定义过。

相关文档
最新文档