Program Design
Computer Languages
Computer languages have undergone dramatic evolution since the first electronic computers were built,Early on,programmers worked with the most primitive computer instructions—machine language,These instructions were represented by long strings of ones and zeroes,Soon,assembly language was invented,It maps machine instructions to human-readable mnemonics,such as ADD and MOV.
In time,higher-level languages evolved,such as PASCAL,BASIC,COBOL,C,C++,and JAVA,These languages let people work with something approximating words and sentences,such as Let I = 100,These instructions were translated back into machine language by interpreters and compilers,An interpreter translates a program as it reads it,turning the program instructions,or code,directly into actions,A compiler translates the code into an intermediary form,This step is called compiling,and produces an object file,The compiler then invokes a linker,which turns the object file into an executable program.
Because interpreters read the code as it is written and execute the code on the spot,interpreters are easy for the programmer to work with,Compilers,however,introduce the extra steps of compiling and linking the code,which is inconvenient,Because the time-consuming task of translating the source code into machine language has already been accomplished,compilers produce a program that is very fast each time it is run.
The problems programmers are asked to solve have been changing,Today's programs use sophisticated "user-friendly interfaces," involving multiple windows,menus,and dialog boxes,The programs written to support this new approach are far more complex than those written just ten years ago,Generally,as programming requirements have changed,both languages and the techniques used for writing programs have evolved.
参考译文计算机语言自从第一批电子计算机诞生以来,计算机语言已经发生了戏剧性的变化。在早期,程序员使用最为原始的计算机指令──机器语言来工作,这些指令由一长串的0和1组成。不久,汇编语言发明了,它是把机器指令变换成易于阅读的助记符,如ADD、MOV等。
往后,又推出了高级语言,如PASCAL、BASIC、COBOL、C、C++、JAVA。这些语言使用的是近似于人们常用的词语或语句,如Let I=100。这些指令由解释器或编译器翻译成机器语言。解释器边读边翻译程序,把程序指令或代码直接变成动作。编译器把代码翻译成中间代码。这一步叫做编译,产生一个目标文件。接着,编译程序调用链接程序,由链接程序把目标文件变为可执行程序。
因为解释程序是读出代码就执行,所以程序员易于使用;但是编译程序却增加了一些额外的步骤来编译和链接代码,相比之下则不方便。可是编译程序产生的程序运行起来非常快,因为把源代码翻译成机器语言这一耗时的任务已经完成了。
程序员要解决的问题一直在变化。今天,程序使用了复杂的“用户友好界面”,包含多重窗口、菜单、对话框。比起10年前的程序来,支持这些新方法的程序要复杂得多。总之,随着程序设计需求的变化,计算机程序设计语言和程序设计技术都已产生了变化。
Computer programming
Computer programming is the activity of developing programs,or lists of instructions,that control the operation of a computer,Computer systems consist of hardware and software,Hardware comprises the electronic and physical parts of the computer,In contrast,software comprises the programs that reside and control each hardware component,Without a software program,a computer is as useless as a bus without a driver.
Computer programs are expressed in precise notations called computer languages,The programs for elementary computer processes are written in low-level languages,These languages are difficult for the ordinary user to follow,High-level languages strike a compromise between the precise meanings required by the machine and spoken language of the users,Common high-level languages include BASIC,C,COBOL and PASCAL,A major activity in programming is the expressing of the steps of a program in one or more languages.
The programming of a computer may be broken down into five stages,They are as follows:
requirements definition
design specification
coding
testing
maintenance
As an example,for a payroll program,requirements specify how many paychecks must be processed,and what calculations need to be performed,In the design specification stage,directions are provided for meeting the requirements by quantifying the processing steps in greater detail,For this,an algorithm is devised,Coding is the stage in which the design is turned into steps expressed in a chosen programming language,In the testing stage,the programs are verified as being correct with respect to the requirements and design specification,The final stage is maintenance in which enhancements and corrections are made,It is the most lengthy and costly stage of programming.
Generally,computer programming is a costly and time-consuming activity,Approaches to improving the programmer’s are being pursued,These include inventing higher-level languages or more powerful languages,inventing utility programs that assist programmers,and inventing new methods of programming.
参考译文计算机编程计算机编程就是开发程序或者列出控制计算机运行指令的行为。计算机系统由硬件和软件组成。硬件包含了计算机中的电子的和物理的部件,而软件包含了控制各硬件部件的程序。没有了软件程序,一台计算机就像一辆没有司机的汽车一样是没有用的。
计算机程序由称为计算机语言的精确符号表示。计算机处理的基本程序是由低级语言编写的,这些语言一般人难以掌握。高级语言是要求精确意义的机器语言和使用者自然语言的折中。一般用来设计应用程序的高级语言有:BASIC、C、COBOL和PASCAL。编程的主要工作就是用一种或多种语言表示程序的详细过程。
计算机编程大致可以分为5个阶段,它们是需求设计、设计规格、编码、测试和维护。
以工资管理程序程序为例,需求指定有多少工资必须处理,需要完成什么样的计算。在设计规格阶段,通过更详细地确定处理步骤以提供满足需求的方向。因此,需要设计一个算法。在编码阶段,用某一个选定的程序设计语言将设计表达出来。在测试阶段,检验程序是否符合设计需求。最后是维护阶段,在此阶段要增强软件功能和改正软件错误,这个阶段也是程序中最漫长和花费最大的阶段。
总之,计算机编程是一个昂贵、费时的过程。人们研究了许多方法以提高程序员的生产率,包括发明更高级的或更强大的语言,发明实用程序以辅助程序员和发明新的编程方法。
Visual Basic
Visual Basic is the fastest and easiest way to create applications for Microsoft Windows,Whether you are an experienced professional or brand new to Windows programming,Visual Basic provides you with a complete set of tools to simplify rapid application development.
So what is Visual Basic? The "Visual" part refers to the method used to create the graphical user interface (GUI),Rather than writing numerous lines of code to describe the appearance and location of interface elements,you simply add pre-built objects into place on screen,If you've ever used a drawing program such as Paint,you already have most of the skills necessary to create an effective user interface.
The "Basic" part refers to the BASIC (Beginners All-Purpose Symbolic Instruction Code) language,a language used by more programmers than any other language,Visual Basic has evolved from the original BASIC language,Now it contains several hundred statements,functions,and keywords,many of which relate directly to the Windows GUI,Beginners can create useful applications by learning just a few of the keywords,yet the power of the language allows professionals to accomplish anything that can be accomplished using any other Windows programming language.
Whether your goal is to create a small utility for yourself or your work group,or a large enterprise-wide system,Visual Basic has the tools you need.
Data access features allow you to create databases,front-end applications,and scalable server-side components for most popular database formats,ActiveX technologies allow you to use the functionality provided by other applications,such as Microsoft Word processor,Microsoft Excel spreadsheet,and other Windows applications,Internet capabilities make it easy to provide access to documents and applications across the Internet from within your application,or to create Internet server applications.
Visual Basic is available in three versions,each geared to meet a specific set of development requirements,
The Visual Basic Learning edition allows programmers to easily create powerful applications for Microsoft Windows and Windows NT,It includes all intrinsic controls,plus grid,tab,and data-bound controls.
The Professional edition provides computer professionals with a full-featured set of tools for developing solutions for others,It includes all the features of the Learning edition,plus additional ActiveX controls,the Internet Information Server Application Designer,integrated Visual Database Tools and Data Environment,Active Data Objects,and the Dynamic HTML Page Designer.
The Enterprise edition allows professionals to create robust distributed applications in a team setting,It includes all the features of the Professional edition,plus Back Office tools such as Microsoft Transaction Server,Internet Information Server,and more.
参考译文
Visual Basic
Visual Basic是创建Windows应用程序最快捷、最容易的工具。不管你是有经验的行家,还是Windows编程新手,Visual Basic都为你提供了一整套简化快速应用程序开发的工具集。
那么什么是Visual Basic呢?Visual指的是创建图形用户界面(GUI)所使用的方法。不用编写许多行代码来描述界面元素的外形和位置,你只需简单地在屏幕上添加一个预先创建的对象即可。假如你已使用过像画笔(Paint)之类的画图程序,你就已经有了创建有效的用户界面所必需的大部分技巧。
Basic是指BASIC语言,这种语言的使用比其他任何语言都多。Visual Basic源于原来的Basic语言,现在已经有好几百条语句、函数、关键词,其中好多都是直接与Windows的图形用户界面(GUI)有关。初学者通过学习少量的关键词就能创建有用的应用程序,而该语言的强大功能可以让专业人员实现任何用其他Windows编程语言所实现的功能。
无论你是要创建个人还是工作组的小型实用程序或者企业级大型系统,Visual Basic都有能满足你要求的工具。
其数据访问的特性可以创建数据库、前端应用程序和应用于大多数流行数据库格式的可伸缩服务端组件。ActiveX技术允许你使用由其他应用程序所提供的功能,如由Word字处理程序、Excel电子表格和其他Windows应用程序提供的功能。Visual Basic的因特网功能,使你可以通过因特网很容易从你的应用程序访问文档和其他应用程序,或创建因特网服务器应用程序。
Visual Basic有3种版本,每一种版本都能满足一些特定的开发需求。
Visual Basic学习版可以使程序员容易地创建Windows和 Windows NT的应用程序。它包括所有的内部控件以及表格、标签和数据绑定控件。
Visual Basic的专业版为计算机专业人员提供了一套全功能的开发其他应用程序的工具。它包括了学习版的所有功能以及一些ActiveX控件、因特网信息服务器(IIS)的应用设计程序、集成的可视数据库工具和数据环境、活动数据对象(ADO)和动态HTML网页设计程序。
Visual Basic的企业版让专业人员在团队环境下,创建强大的分布式应用程序。它包含专业版的所有功能以及Back Office工具,如微软事务处理服务器(MTS)、因特网信息服务器(IIS)等。
Debugging
All programs have bugs,The bigger the program,the more bugs,and many of those bugs actually "get out the door" and into final released software,That this is true does not make it okay,Making robust,bug-free programs is the number-one priority of anyone serious about programming.
The single biggest problem in the software industry is buggy,unstable code,The biggest expense in many major programming efforts is testing and fixing,The person who solves the problem of producing good,solid,bulletproof programs at low cost and on time will revolutionize the software industry.
There are a number of discrete kinds of bugs that can trouble a program,The first is poor logic,The program does just what you asked,but you haven't thought through the algorithms properly,The second is syntactic,You used the wrong idiom,function,or structure,These two are the most common,and they are the ones most programmers are on the lookout for.
Research and real-world experience have shown beyond a doubt that the later in the development process you find a problem,the more it costs to fix it,The least expensive problems or bugs to fix are the ones you manage to avoid creating.
A bigger problem than logic or syntactic bugs is unnecessary fragility,Your program works just fine if the user enters a number when you ask for one,but it crashes if the user enters letters,Other programs crash if they run out of memory,or if the floppy disk is left out of the drive,or if the modem drops the line.
To combat this kind of fragility,programmers strive to make their programs bulletproof,A bulletproof program is one that can handle anything that comes up at runtime,from bizarre user input to running out of memory.
Nearly all modern development environments include one or more high-powered debuggers,The essential idea of using a debugger is this,You run the debugger,which loads your source code,and then you run your program from within the debugger,This allows you to see each instruction in your program as it executes,and to examine your variables as they change during the life of your program.
Learn to use your debugger,It can be the most powerful weapon in your holy war against bugs,Runtime bugs are the hardest to find and squash,and a powerful debugger can make it possible to find nearly all of them.
参考译文程序调试凡是程序都会出错。程序越大,错误越多。实际上,很多错误会被带到最终的发行版本中去。当然,这是不行的。编写强大、无错误程序是任何认真的程序设计人员头等重要的事情。
在软件业中一个最严重的问题就是错误、不稳定的代码。许多重大程序设计工作中花费最多的也是检查和修正错误。谁能解决以低成本并及时交付性能良好、稳定、强大的程序这一问题,那么他就会给软件业带来革新。
有很多不同的错误会影响程序。首先是逻辑性比较差的程序,它可能实现你的要求,但是你可能并没有考虑该算法的合理性。其次,就是句法错误,你用了错误的语法、函数或结构。这是最常见的两类错误,也是大多数程序员要提防的。
研究和现实世界的经验毫无疑问地表明:在开发过程中发现问题越晚,改正错误的代价就越大。修改问题或错误的最小代价,就是尽力避免错误的产生。
比逻辑或语法错误更大的问题是不必要的脆弱性:当用户按要求输入一个数时,程序运行得很好;如果用户输入一些字母,程序就会崩溃。如由于内存不足,或者软盘不在驱动器中,或者是调制解调器掉线等原因,还可能导致其他程序崩溃。
为了克服这类脆弱性,程序员力图使他们的程序无坚不摧。一个无坚不摧的程序能处理运行时出现的各种情况──从稀奇古怪的用户输入,到内存耗尽。
几乎所有现代的开发环境都会提供一个或多个功能很强的调试程序。使用调试程序的基本思想是:你运行调试程序,调试程序加载你的源代码,然后你在调试程序里运行你的程序。这就允许你看到程序执行时的每一条指令,查看在程序运行期间变量的变化。
学习使用调试程序吧。它是一个强大的排错工具。运行时的错误最难找到和排除,功能强的调试程序可以帮你找出几乎所有的错误。