Sie sind auf Seite 1von 3

A program is a set of instructions, written in a sequence, that tells the comput er what to do.

A program may, for example, instruct the computer to request info rmation from the user, process the information, and display results to the user. Depending on the nature of the task to be done, a program may be simple or comp lex. The instructions are written using a programming language and are later con verted into machine language that can be processed by the computer. ====================================================================== There are many programming languages available today, each having its own streng ths and drawbacks. Some languages are designed to be fast with mathematical calc ulations. Others are designed to be readable by non-programmers. Still others ar e designed to work with databases. The developers can choose any programming lan guage that best suits the project they want to work on. # Common Programming Language Element Despite the differences in the rules for writing instructions among the various languages, all programming languages have the following elements in common: - Literals - Operators - Functions - Variables - Constans - Arrays - Conditional Operator - Branch (If Then statement) - Loops - Procedures - Arguments (Parameter) - File I/O ====================================================================== Each program instruction has syntax that specifies what keywords can be used, wh at combinations of words are meaningful, and what punctuation is necessary while writing the instruction. The syntax of an instruction may vary from one program ming language to another. A computer executes an instruction only if its syntax is correct. # Principles of Coding While writing a program, the programmer should write the source code in a way th at makes it easy to read, understand, and debug. This helps not only the origina l developer, who may have to go back to the code later to fix a bug, but also ot her developers who are enhancing a section of code they did not originally write . The source code can be made more understandable by using two techniques: 1. Comments can be used in the source code to explain what a particular section of code will do. This is useful for explaining those sections of code which are difficult to understand. 2. Whitespaces can be used to enhance the code format and make it more readable. A whitespace is created when you use tabs, spaces, or indents in the code. ====================================================================== Programming methodologies are the different approaches or sets of practices foll owed to write a program. The choice of a particular methodology depends on the n ature of the task to be done by the program, and the ease and efficiency with wh

ich the program can be developed. Some of the commonly used programming methodol ogies are structured programming, object-oriented programming, and event-driven programming. ====================================================================== Structured programming is a programming methodology that enforces a logical stru cture on the program being written. The program is divided into many simpler mod ules and each module handles a specific task. These modules are then arranged in a hierarchical structure, and the program execution flows from higher levels to lower levels. There are three types of flow controls used. Some of the programming languages that follow the structured methodology are C, Pascal, BASIC, and Ada. Some of the advantages of using structured programming are: 1. Structured programming uses a top-down approach where a big program is viewed as a collection of many small modules, thus making the program look simpler and easier to understand. 2. Many programmers can work on a single, large program, with each programmer wo rking on a different module, thereby reducing the development time. 3. Since a module is defined to perform just one task, each module can be checke d individually, which makes debugging easier. ====================================================================== Object-oriented programming is a programming methodology where the program is mo delled on the concept of objects and their interactions. For example, consider t hat you are assembling a computer system. You would connect the mouse, monitor, printer, and so on, to create the complete system. Object-oriented programming w orks in a similar way by putting together various objects, their features, and i nteractions, to create an application that can perform multiple tasks. Some of the programming languages that follow the object-oriented methodology ar e C++, Java, VisualBasic.NET and C#. Some of the advantages of object-oriented programming are: 1. The objects created for one program can be used in another program for perfor ming similar functions. This code reusability feature helps in reducing the deve lopment time. 2. The inheritance feature of object-oriented programming allows the creation of new objects and classes from existing ones. 3. The encapsulation feature of object-oriented programming helps hide the imple mentation details from the user and thereby provides increased data security. On ly the interface of a system is visible to the user. 4. Object-oriented programming provides built-in code libraries, which are usefu l for developing graphical user interfaces. ====================================================================== Event-driven programming is a programming methodology in which the flow of a pro gram is determined by user actions such as mouse clicks or key presses, and mess ages received from other programs. These user actions and messages from other pr

ograms are known as events. An event-driven program is made up of many event han dlers, which are subroutines that handle the events generated. Once all the even t handling routines are developed, they are combined together by writing a loop which will check for the events being called and call the appropriate event hand ler. Some of the programming languages that follow the event-driven methodology are T cl (Tool Command Language) and PERL. ====================================================================== The programming process involves three main stages: coding, compiling, and debug ging. 1. In the coding stage, the instructions of the program are written using a suit able programming language. 2. In the compiling stage, the source code is converted into machine language by using a compiler. The compiled instructions are saved as an executable program. If any errors are detected in the source code, then error messages are displaye d. 3. In the debugging stage, the causes of errors are identified and necessary cor rections are made to the code. Once debugging is done, the source code is compil ed again. - A compiler is software that converts code written in a programming language in to machine language. The program code is written using English alphabets that th e computer cannot execute. A computer can understand only the binary language of zeros and ones, hence code written in a programming language must be translated into machine language before execution. - An interpreter is software that translates the source code written in a progra mming language into an intermediate form and then executes it. Unlike a compiler , the interpreter executes the code line by line and therefore takes comparative ly longer time to complete the process. However, the design of an interpreter is easier and simpler as compared to a compiler. Some programming languages such a s BASIC and LISP can be executed only by an interpreter. In a compiler, the resu ltant program is executed by hardware, whereas, in an interpreter, the resultant program is executed by the interpreter itself. ====================================================================== All the programs developed using Java programming language go through the Java p latform process. The Java platform process consists of five phases: edit, compil e, load, verify, and interpret. 1. In the edit phase, programmers use a text editor to write, correct, and save their source code. 2. In the compile phase, the Java source code is translated into an interm ediate Java bytecode using the Java compiler. 3. In the load phase, the class loader uses the compiled file and transfer s the bytecode into the computer's primary memory. 4. In the verify phase, the bytecode contained within the compiled file is validated. 5. In the interpret phase, the Java Virtual Machine interprets the bytecod e and executes the program.

Das könnte Ihnen auch gefallen