Page 118 - DCAP405_SOFTWARE_ENGINEERING
P. 118

Unit 7: Software Engineering Practice




          7.5.2 Coding Concepts                                                                 Notes

          Computer programs are collections of instructions that tell a computer how to interact with the
          user, interact with the computer hardware and process data. The first programmable computers
          required the programmers to write explicit instructions to directly manipulate the hardware of
          the computer. This “machine language” was very tedious to write by hand since even simple
          tasks such as printing some output on the screen require 10 or 20 machine language commands.
          Machine language is often referred to as a “low level language” since the code directly
          manipulates the hardware of the computer.
          By contrast, higher level languages such as C, C++, Pascal, Cobol, Fortran, ADA and Java are
          called “compiled languages”. In a compiled language, the programmer writes more general
          instructions and a compiler (a special piece of software) automatically translates these high
          level instructions into machine language. The machine language is then executed by the
          computer. A large portion of software in use today is programmed in this fashion.
          We can contrast compiled programming languages with interpreted programming languages.
          In an interpreted programming language, the statements that the programmer writes are
          interpreted as the program is running. This means they are translated into machine language on
          the fly and then execute as the program is running. Some popular interpreted languages include
          Basic, Visual Basic, Perl and shell scripting languages such as those found in the UNIX
          environment.
          We can make another comparison between two different models of programming. In structured
          programming, blocks of programming statements (code) are executed one after another. Control
          statements change which blocks of code are executed next.
          In object oriented programming, data are contained in objects and are accessed using special
          methods (blocks of code) specific to the type of object. There is no single “flow” of the program
          as objects can freely interact with one another by passing messages.
          In this tutorial, we focus only on structured programming.


          Program Structure
          Virtually all structured programs share a similar overall structure:

               Statements to establish the start of the program
               Variable declaration

               Program statements (blocks of code)
          The following is a simple example of a program written in several different programming
          languages. We call this the “Hello World” example since all the program does is print “Hello
          World” on the computer screen.





             Notes  The Perl and Basic languages are technically not compiled languages. These language
            statements are “interpreted” as the program is running.












                                           LOVELY PROFESSIONAL UNIVERSITY                                   111
   113   114   115   116   117   118   119   120   121   122   123