计算机专业英语
第五周课外作业:阅读
Programming and Languages
Introduction
Why should you need to know anything about programming? The answer is simple. You might need to deal with programmers in the course of your work. You also may be required to do some programming yourself in the future. A growing trend is toward end user software development. This means that end users, like you, are developing their own application programs. Competent end users need to understand the relationship between systems development and programming. Additionally, they need to know the six steps of programming, including program specification, program design, program code, program test, program documentation, and program maintenance.
Programs and Programming
What exactly is programming? Many people trunk of it as simply typing words into a computer. That may be part of it, but that is certainly not all of it. Programming, as we've hinted before, is actually a problem-solving procedure.
What Is a Program?
To see how programming works, think about what a program is. A program is a list of
instructions for the computer to follow to accomplish the task of processing data into information. The instructions are made up of statements used in a programming language, such as C++, Java, or Visual Basic.
What Is Programming?
A program is a list of instructions for the computer to follow to process data. Programming, also known as software development or the software development life cycle (SOLC), is a six-step procedure for creating that list of instructions. Only one of those steps consists of typing (keying) statements into a computer.
The six steps are as follows:
1. Program specification: The program's objectives, outputs, inputs, and processing requirements are determined.
2. Program design: A solution is created using programming techniques such as top-down program design, pseudo-code, flowcharts, and logic structures.
3. Program code: The program is written or coded using a programming language.
4. Program test: The program is tested or debugged by looking for syntax and logic errors.
5. Program documentation: Documentation is an ongoing process throughout the programming process. This phase focuses on formalizing the written description and processes used in the program.
6. Program maintenance: Completed programs are periodically reviewed to evaluate their accuracy, efficiency, standardization, and ease of use. Changes are made to the program's code as needed.
In organizations, computer professionals known as software engineers or programmers use this six-step procedure. Working closely with systems analysts in systems development, Phase 4 of the systems life cycle, programmers create software required for information systems. In a recent survey by Money magazine, software engineers were ranked near the top of over 100 widely held jobs based on salary, prestige, and security
You may well find yourself working directly with a programmer or indirectly through a systems analyst. Or you may actually do the programming for a system that you develop. Whatever thy case; it's important that you understand the six-step programming procedure.
Step 1: Program Specification
Program specification is also called program definition or program analysis. It requires that the programmer-or you, the end user, if you are following this procedure-specify five items: (1) the program's objectives, (2) the desired output, (3) the input data required, (4) the processing requirements, and (5) the documentation.
Program Objectives
You solve all kinds of problems every day. A problem might be deciding how to commute to school or work or which homework or report to do first. Thus, every day you determine your objectives-the problems you are trying to solve.
Programming is the same. You need to make a clear statement of the problem you are trying to solve. An example would be, "I want a time-and-billing system to record the time 1spend on different jobs for different clients of Advantage Advertising."
Desired Output
It is best always to specify outputs before inputs. That is, you need to list what you want to get out of the computer system. Then you should determine what will go into it. The best way to do this is to draw a picture. You-the end user, not the programmer-should sketch or write how you want the output to look when it's done. It might be printed out or displayed on the monitor.
For example, if you want a time-and-billing report, you might write or draw something like
Input Data
Once you know the output you want, you can determine the input data and the source of this data. For example, for a time-and-billing report, you can specify that one source of da ta to be
processed should be time cards. These are usually logs or statements of hours worked submitted on paper forms.
Processing Requirements
Here you define the processing tasks that must happen for input data to be processed into output. For Advantage, one of the tasks for the program will be to add the hours worked for different jobs for different clients.
Program Specifications Document
As in the systems life cycle, ongoing documentation is essential. You should record program objectives, desired outputs, needed inputs, and required processing. This leads to the next step, program/design.
Step 2: Program Design
After program specification, you begin program design. Here you plan a solution, preferably using structured programming techniques. These techniques consist of the following: (1) top-down program design, (2) pseudo-code, (3) flowcharts, and (4) logic structures.
Top-Down Program Design
First determine the outputs and inputs for the program. Then use top-down program design to identify the program's processing steps. Such steps are called program modules (or just modules). Each module is made up of logically related program statements.
A Pseudocode
Pseudocode (pronounced "soc-doh-code") is an outline of the logic of the program you will write. It is like doing a summary of the program before it is written.
Flowcharts
Here we are concerned with program flowcharts. These graphically present the detailed sequence of steps needed to solve a programming problem. This flowchart expresses all the logic for just one module-"Compute time on Client A jobs" ---- in the top-down program design.
Perhaps you can see from this flowchart why a computer is a computer, and not just a fancy adding machine. A computer does more than arithmetic. It also makes comparisons-whether something is greater than or less than, equal to or not equal to. But have we skipped something? How do we know which kind of twists and turns to put in a flowchart so that it will work logically? The answer is based on the use of logic structures, as we will explain.
Logic Structures
How do you link the various parts of the flowchart? The best way is a combination of three logic structures called sequential, selection, and repetition. Using these arrangements enables you to write so-called structured programs, which take much of the guesswork out of programming. Let us look at the logic structures.
• In the sequential structure, one program statement follows another. Consider, for example, the "compute time" flowchart. The two "add" boxes are "Add regular hours to total regular hours" and "Add overtime hours to total overtime hours." They logically follow each other. There is no question of "yes" or "no," of a decision suggesting other consequences.
• The selection structure occurs when a decision must be made. The outcome of the decision determines which of two paths to follow. This structure is also known as an IF-THEN-
ELSE structure because that is how you can formulate the decision. Consider, for example, the selection structure in the "compute time" flowchart, which is concerned about computing 9vertime hours. It might be expressed in detail as follows:
IF hour finished for this job is later than 170d hours (5:00 P.M.),
THEN overtime hours equal the number of hours past 1700 hours,
ELSE overtime hour equal zero.
The repetition or loop structure describes a process that may be repeated as long as a certain condition remains true. The structure is called a "loop" or "iteration" because the program loops around (iterates or repeats) again and again. The repetition structure has two variations: DO UNTIL and DO WHILE. An example of the DO UNTIL structure follows:
DO read in job information UNTIL there are no more jobs.
An example of the DO WHILE structure is
DO read in job information WHILE (that is, as long as) there are more jobs.
There is a difference between the two repetition structures. You may have several statements that need to be repeated. If so, the decision when to stop repeating them can appear at the beginning of the loop (DO WHILE) or at the end of the loop (DO UNTIL). The DO UNTIL loop means that the loop executed before you are asked whether to stop.
.The last thing to do before leaving the program design step is to document the logic of the
design. This report typically includes pseudocode, flowcharts, and logic structures. Now you are ready for the next step, program code.
Step 3: Program Code
Writing the program is called coding. Here you use the logic you developed in the program design step to actually write the program. This is the "program code" that instructs the computer what to do. Coding is what many it is only one of the six steps in the programming process.
The Good Program
What are the qualities of a good program? Above all, it should be reliable- that is, it should work under most conditions and produce correct output. It should catch obvious and common input errors. It also should be well documented and understandable by programmers other than the person who wrote it. After all, someone may need to make changes in the program in the future. One of the best ways to code effective programs is to write so-called structured programs, using the logic structures described in Step 2.
Coding
After the program logic has been formulated, the next step is to code or write the program using the appropriate computer language. There are numerous content-markup and programming
languages. A content-markup language uses symbols, words, and phrases that instruct a computer how to structure information for display or processing. For example, HTML5 is a widely used content-markup language to create web pages.
A programming language uses a collection of symbols, words, and phrases that instruct a computer to perform specific operations. While content-markup languages focus on assigning meaning to different pieces of content, programming languages focus on processing data and information for a wide variety of different types of applications. C++, a widely used
programming language, to calculate the compute time module. For a description of C++ and some other widely used programming languages Once the program has been coded, the next step is testing, or debugging, the program.
Step 4: Program Test
Debugging refers to the process of testing and then eliminating errors ("getting the bugs out"). It means running the program on a computer and then fixing the parts that do not work. Programming errors are of two types: syntax errors and logic errors.
Syntax Errors
A syntax error is a violation of the rules of the programming language. For example, in C++, each statement must end with a semicolon (;). If the semicolon is omitted, the program will not run due to a syntax error.
Logic Errors
A logic error occurs when the programmer uses an incorrect calculation or leaves out a
programming procedure. For example, a payroll program that did not compute overtime hours would have a logic error.
Testing Process
Several methods have been devised for finding and removing both types of errors:
• Desk checking: In desk checking or code review, a programmer sitting at a desk checks (proofreads) a printout of the program. The programmer goes through the listing line by line
looking for syntax and logic errors.
• Manually testing with sample data: Using a calculator and sample data, a programmer follows each program statement and performs every calculation. Looking for programming logic errors, the programmer compares the manually calculated values to those calculated by the programs.
• Attempt at translation: The program is run through a computer, using a translator program. The translator attempts to translate the written program from the programming language (such as C++) into the machine language.
• Before the program will run, it must be free of syntax errors. Such errors will be identified by the translating program.
• Testing sample data on the computer: After all syntax errors have been corrected, the program is tested for logic errors. Sample data is used to test the correct execution of each program statement. Testing by a select group of potential users: This is sometimes called beta testing. It is usually the final step in testing a program. Potential users tryout the program and provide feedback.
Step 5: Program Documentation
Documentation consists of written descriptions and procedures about a program and how to use it. It is not something done just at the end of the programming process. Program documentation is carried on throughout all the programming steps. This documentation is typically within the program itself and in printed or electronic documents. In this step, all the prior documentation is reviewed, finalized, and distributed. Documentation is important for people who may be involved with the program in the future. These people may include the following:
• Users: Users need to know how to use the software. Some organizations may offer training courses to guide users through the program. However, other organizations may expect users to be able to learn a package just from the written documentation. Two examples of this sort of documentation are printed manuals and the help option within most applications.
• Operators: Documentation must be provided for computer operators. If the program sends them error messages, for instance, they need to know what to do about them.
• Programmers: As time passes, even the creator of the original program may not remember
much about it. Other programmers wishing to update and modify it-that is perform program
maintenance-may find themselves frustrated without adequate documentation. This kind of documentation should include text and program flowcharts, program listings, and sample output. It also might include system flowcharts to show how the particular program relates to other programs within an information system.
•
Step 6: Program Maintenance
The final step is program maintenance. As much as 75 percent of the total lifetime cost for an application program is for maintenance. This activity is so commonplace that a special job title, maintenance programmer, exists.
The purpose of program maintenance is to ensure that current programs are operating error-free, efficiently, and effectively. Activities in this area fall into two categories: operations and changing needs.
Operations
Operations activities concern locating and correcting operational errors, making programs easier to use, and standardizing software using structured programming techniques. For properly designed programs, these activities should be minimal. Programming modifications or
corrections are often referred to as patches. For software that is acquired, it is common for the software manufacturer to periodically send patches or updates for its software. If the patches are significant, they are known as software updates.
Changing Needs
The category of changing needs is unavoidable. All organizations change over time, and their programs must change with them. Programs need to be adjusted for a variety of reasons,
including new tax laws, new information needs, and new company policies. Significant revisions may require that the entire programming process begin again with program specification.
Ideally, a software project sequentially follows the six steps of software development. However, some projects start before all requirements are known. In these cases, the SDLC becomes a more cyclical process, repeated several times throughout the development of the software. For example, agile development, a popular development methodology, starts by getting core
functionality of a program working, then expands on it until the customer is satisfied with the results. All six steps are repeated over and over as quickly as possible to create incrementally more functional versions of the application.
Concept check
• What is the purpose of program maintenance?
• Discuss operations activities. What are patches? Service updates?
• What are changing needs, and how do they affect programs?
CASE and OOP
You hear about efficiency and productivity everywhere. They are particularly important for software development. Two resources that promise to help are CASE tools and object-oriented software development.
CASE Tools
Professional programmers are constantly looking for ways to make their work easier, faster, and more reliable. CASE, is meeting this need. Computer-aided software engineering (CASE) tools provide some automation and assistance in program design, coding, and testing.
Object-Oriented Software Development
Traditional systems development is a careful, step-by-step approach focusing on the procedures needed to complete a certain objective. Object-oriented software development focuses less on the procedures and more on defining the relationships between previously defined procedures or "objects." Object-oriented programming (OOP) is a process by which a program is organized into objects. Each object contains both the data and processing operations necessary to perform a task. Let's explain what this means.
In the past, programs were developed as giant entities, from the first line of code to the last. This
has been compared to building a car from scratch. Object oriented programming is like building
a car from prefabricated parts---carburetor, alternator, fenders, and so on. Object-oriented programs use objects that are reusable, self-contained components. Programs built with these objects assume that certain functions are the same. For example, many programs, from spreadsheets to database managers, have an instruction that will sort lists of names in alphabetical order. A programmer might use this object for alphabetizing in many other programs. There is no need to invent this activity anew every time. C++ is one of the most widely used object-oriented programming languages.
Generations of Programming Languages
Computer professionals talk about levels or generations of programming languages, ranging from "low" to "high." Programming languages are called lower level when they are closer to the language the computer itself uses. The computer understands the 0s and 1s that make up bits and bytes. Programming languages are called higher level when they are closer to the language humans use-that is, for English speakers, more like English.
There are five generations of programming languages: (1) machine languages, (2) assembly languages, (3) procedural languages, (4) task-oriented languages, and (5) problem and constraint languages.
Machine languages: The First Generation We mentioned that a byte is made up of bits,
consisting of 1s and 0s. These 1s and 0s may correspond to electricity's being ON or OFF in the computer. They also may correspond to a magnetic charge being present or absent on storage media such as disc or tape. From this two-state system, coding schemes have been developed that allow us to construct letters, numbers, punctuation marks, and other special characters. Examples of these coding schemes, as we saw, are ASCII, EBCDIC, and Unicode.
Data represented in 1s and 0s is said to be written in machine language. To see how hard this is to understand, imagine if you had to code this:
[***********][***********][1**********]1
Machine languages also vary according to make of computer-another characteristic that makes them hard to work with.
Assembly languages: The Second Generation
Before a computer can process or run any program, the program must be converted or translated into machine language. Assembly languages use abbreviations or mnemonics such as ADD that are automatically converted to the appropriate sequence of Is and as. Compared to machine languages, assembly languages are much easier for humans to understand and to use. The machine language code we gave above could be expressed in assembly language as
ADD 210(8,13),02B(4,7)
This is still pretty obscure, of course, and so assembly language is also considered low level.
Assembly languages also vary from computer to computer. With the third generation, we
advance to high-level languages, many of which are considered portable languages. That is, they can be run on more than one kind of computer-they are "portable" from one machine to another.
High-level Procedural languages: The Third Generation
People are able to understand languages that are more like their own (e.g., English) than machine languages or assembly languages. These more English-like programming languages are called "high-level" languages. However, most people still require some training to use higher-level languages. This is particularly true of procedural languages.
Procedural languages, also known as 3GLs (third-generation languages), are designed to express the logic-the procedures-that can solve general problems. Procedura11anguages, then, are intended to solve general problems and are the most widely used languages to create software applications. C++ is a procedural language widely used by today's programmers. For example, C++ was used in Advantage's time-and-billing report.
Consider the following C++ statement from a program that assigns letter grades based on the score of an exam:
if (score> = 90) grade = 'A:;
This statement tests whether the score is greater than or equal to 90. If it is, then the letter grade of A is assigned.
Like assembly languages, procedural languages must be translated into machine language so that the computer processes them. Depending on the language, this translation is performed by either a compiler or an interpreter .
• A compiler converts the programmer's procedural language program, called the source code, into a machine language code, called the object code. This object code can then be saved and run later. Examples of procedura11anguages using compilers are the standard versions of Pascal, COBOL, and FORTRAN.
• An interpreter converts the procedural language one statement at a time into machine code just before it is to be executed. No object code is saved. An example of a procedura11anguage using an interpreter is the standard version of BASIC.
What is the difference between using a compiler and using an interpreter? When a program is run, the compiler requires two steps. The first step is to convert the entire program's source code to object code. The second step is to run the object code. The interpreter, in contrast, converts and runs the program one line at a time. The advantage of a compiler language is that once the object code has been obtained, the program executes faster. The advantage of an interpreter language is that programs are easier to develop.
Task-Oriented Languages: The Fourth Generation
Third-generation languages are valuable, but they require training in programming. Task-oriented languages, also known as 4GLs (fourth-generation languages) and very high level
languages, require little special training on the part of the user. Unlike general-purpose languages, task-oriented languages are designed to solve specific problems. While 3GLs focus on procedures and how logic can be combined to solve a variety of problems, 4GLs are
nonprocedural and focus on specifying the specific tasks the program is to accomplish. 4GLs are more English like, easier to program, and widely used by nonprogrammers. Some of these fourth-generation languages are used for very specific applications. For example, IFPS
(interactive financial planning system) is used to develop financial models. Many 4GLs are part of a database management system. 4GLs include query languages and application generators:
• Query languages: Query languages enable non-programmers to use certain easily understood commands to search and generate reports from a database. One of the most widely used query languages is SQL (structured query language). For example, let's say that Advantage Advertising has a database containing all customer calls for service and that its management would like a listing of all clients who incurred overtime charges. The SQL command to create this list is
SELECT client FROM daily Log WHERE service End > 17
This SQL statement selects or identifies all clients (a field name from the daily log table) that required service after 17 (military time for 5:00 P.M.). Microsoft Access can generate SQL commands like this one by using its Query wizard.
• Application generators: An application generator or a program coder is a program that provides modules of prewritten code. When using an application generator, a programmer can quickly create a program by referencing the module(s) that performs certain tasks. This greatly reduces the time to create an application. For example, Access has a report generation application and a Report wizard for creating a variety of different types of reports using database information.
Problem and Constraint Languages: The Fifth Generation
As they have evolved through the generations, computer languages have become more
humanlike. Clearly, the fourth-generation query languages using commands that include words like SELECT, F1
The next step in programming languages will be the fifth-generation language l (5GL), or computer languages that incorporate the concepts of artificial intelligence to allow a person to provide a system with a problem and some constraints, and then request a solution. Additionally, these languages would enable a computer to learn and to apply new information as people do. Rather than coding by keying in specific commands, we would communicate more directly to a computer using natural languages.
Consider the following natural language statement that might appear in a 5G .program for recommending medical treatment.
Get patient Diagnose is from patient Symptoms "sneezing", "coughing", "aching"
When will fifth-generation languages become a reality? That's difficult to say; however,
researchers are actively working on the development of 5GL languages and have demonstrated some success.
第五周课外作业:翻译
A LOOK TO THE FUTURE
Your Own Programmable Robot
Have you ever dreamed of having your own robot that could help you with all your chores? Wouldn't it be nice if that robot understood every word you said and required no complex
programming from you? Such a robot will be possible in the future as the field of robotics keeps advancing. There are already several companies that are mass-producing programmable robots for individuals and educational institutions. It is just a matter of time before these robots can understand human instructions instead of complex programming languages.
One of earliest robots that was made available to consumers was the Roomba from iRobot,
which is essentially an automated, intelligent vacuum cleaner. Since then, the same company has released robots that wash floors and clean pools. The programming is handled by the robot's developers, with the end user doing very little except turning the robot on. As well as these robots perform, their function is limited to their programmed tasks.
A company named Aldebaran Robotics has taken a different approach, creating -small,
humanoid robots, called Nao, that the end user can program. Although the Nao robots are being mass-produced, they are a bit too expensive for the average home. Currently, they are being marketed toward schools and research institution a GUI, students can create programs that the robot will follow. Alternatively, programmers can use one of several supported languages to write their own custom scripts for Nao.
In the future, it will not be necessary for someone to use software or know a programming language to communicate with a robot. Developers will use sophisticated programming to give the robot the artificial intelligence necessary to understand natural language. This software will be embedded in a chip within the robot. When you purchase a robot, all you will have to do is speak the commands in normal, conversational English. If you want the robot to help you clean the pool or lift a heavy box, you can tell the robot in the same manner you would tell another person.
The hardware components needed to make robots are becoming cheaper. However, the software remains a challenge. Human languages and conversations remain very difficult for a computer to fully understand. Speech recognition continues to improve, and we are seeing this technology embedded in the latest smartphones. Nevertheless, many improvements are necessary before a humanoid robot will be able to converse with us.
Do you think you will be able to own a humanoid robot in your lifetime? Do you believe that programmers will be able to make these robots intelligent enough to carry on conversations and perform a wide variety of tasks?