Jump to content

A-level Computing 2009/AQA/Processing and Programming Techniques/Programming Concepts

From Wikibooks, open books for an open world

High Level Languages

[edit | edit source]

High-level languages are usually problem-oriented. This means that most (but not all) high-level languages are written to solve problems in specific areas. As a result there are lots of different high-level languages available to the programmer - some sources on the Internet list over 2,000 of them. This can make the process of selecting the most suitable language a daunting task.

There are several things which a programmer can use to select a suitable language. These include:

  • Looking at the facilities offered by the language and comparing them to the problem
  • How well the programme needs to interact with other existing programmes
  • The suitability of the input or output to match the user's needs
  • How experienced the programmer is with a particular language
  • The cost of the necessary compiler/interpreter
  • How long it will take to learn a new language if necessary

No programmer can have a good knowledge of all the current computer languages currently on the market. Existing languages are always being upgraded and added to and new ones are being developed to cope with new situations.

High level languages can be classified by the way in which they are organised. This method of organisation is beter known as a paradigm of which there are a recognised number.

Imperative / Procedural Programming Languages

[edit | edit source]

An imperative is a command that must be obeyed and that is exactly how an imperative language works. Such a language consists of a long list of instructions that the computer will carry out. It will always carry out exactly the same process as long as exactly the same variables are inputted. The variables allow the user to exercise control over the programme but it will still be executed in a similar way.

Some examples of imperative languages include:

  • Fortran - designed to help with mathematical and scientific products.
  • COBOL (Common Business Oriented Language) - developed specifically to handle files of data and is supported by powerful search and report creation routines.
  • BASIC (Beginner's All-Purpose Symbolic Instruction Code) - originally created to allow students to create simple computer program. In recent years, Microsoft has derived Visual Basic from the original language and has taken it towards being object-oriented.
  • Java - In recent years this language has become associated with the Internet and creating online applications but was originally used to programme the chips in mobile telephones and pagers. This language allows a developer to create standalone program called 'applets' which will run without the use of an interpreter.

Logic and Declarative Languages

[edit | edit source]

A declaration is where a statement is made. In the context of programming languages, with a declarative you give facts and rules to the computer which can then be queried to give data back.

Object-Oriented Programming

[edit | edit source]

Object-Orientated programs consist of a number of interacting objects. The objects each have properties and behaviours, much like physical objects. This similarity to the physical world is often used when modelling an existing system, or theorizing about the action of the program. The objects are similar to procedural programmes in that they have variables, methods and functions.

A key difference between an object and a section of linear code is that the variables, methods and functions may have restrictions placed on their use. By not allowing direct access to the state but instead carrying out any changes itself the object can ensure the consistency of its own state. This property is called Object Encapsulation, it is one of the primary reasons that object orientated programming is better suited to complex problems than linear code. In linear code it is common to store the state of the system in a series of global variables, accessible by any part of the program. Object encapsulation allows each object to be reasoned about without having to consider the problems of possible side-effects from code in another object.

Objects have two parts, the state of the object and the behaviours. The state of the object is stored in a number of variables while the behaviour is defined within the methods and functions. An object is defined by a ‘class’. The ‘class’ is a definition of the variables needed and the code for the methods. When an object orientated program is running only a single copy of the class is required in memory, but multiple sets of state may be created. These sets of state are referred to as objects as the compiler, interpreter or runtime environment hides the sharing of class information.

When an object orientated program starts there are no objects, so how are objects created? The program loader is given an initial class to load into memory and an initial method to then start processing. This first method is then responsible for creating further objects, which may create more objects still.

Object orientated programmes also lend themselves to having one or more concurrent flows of processing within the collection of objects.

Instantiation, classes, inheritance, multiple inheritance, polymorphism.

Object-Oriented programming takes the idea of physical real life objects such as "chairs" and "people" and uses this concept within a programming language. It sets the basic foundation as the "Object" which can be assigned variables (e.g. a name, a persons age) and methods (e.g. a method to call to return the name stored within the object). These objects are then used together to build up a program.

Declarative Programming

[edit | edit source]

In contrast to functional and object oriented languages a declarative language such as prolog contains assertions about the problem domain, often in the form of tuples. The language runtime is most often interactive and allows queries to be entered. The language then uses the declarations to deduce the answer.

Data Structures

[edit | edit source]

Data Structures relates to Data Algorithms and Data Restructring for defining good data base management systems.

Algorithms

[edit | edit source]

Algorithm is the step wise representation without any application of any particular logic .e.g. in the programme to add 3 numbers step1-start step2-take numbers m1, m2, m3,temp. step3-take m1=1,m2=2,m3=3. step4- add the three numbers. step5-temp=m1+m2+m3(value of addition goes to temp) step6-print temp. step7-stop