Download Programming Paradigms: Procedural vs. Object-Oriented Languages and more Slides Geochemistry in PDF only on Docsity!
Programming Paradigms
- There are two main programming paradigms.
- Older languages (e.g. Fortran, Basic, Cobol, Pascal, C) use
a procedural (or imperative ) paradigm.
- Newer languages (Visual Basic, C++, Delphi, Java and
C#) are more likely to be object orientated.
Procedural Languages
- In the early days programs were usually run as batch jobs
and required very little user interaction – so they were basically a series of instructions to be carried out in a specific sequence.
- This was a function of early input/output devices (e.g.
punched cards, line printers).
- In the 1970s keyboards and text monitors allowed
programs to be more interactive, but this did not really affect the way in which the languages operated (i.e, they were still basically sequential).
Object Orientated Languages(2)
- The new object orientated languages provide windows,
button, menus etc. as pre-written objects, making it simple to build a graphical user interface to a program.
- Interpreters and compilers use to be simple programs, but
now they tend to form part of a more complex Integrated Development Environment (IDE).
- The newer languages tended to GUI orientated, but not all
object orientated languages are ‘visual’.
Web Scripting Languages
- The explosion of the Internet and more especially the World Wide Web in the 1990s created a demand for new technologies.
- All web pages are written in HTML (hypertext markup language).
- This is not really a language at all, just a ste of tags that can be used to control the display of fonts.
- Early web pages were static, so new scripting languages (e.g. JavaScript , VBScript , tcl , and PHP ) emerged to provide dynamic content.
- Mostly interpreted, either client-side or server side.
Procedures
- In many situations you might find yourself doing the same type of operation several times within a single program, or you may find yourself doing the same operation in different programs.
- Rather than write new code each time it is required, procedural languages allow you to write it as a procedure , routine , subroutine or function separate from the main program.
- The procedure can then be called as required – i.e. the work can be ‘subcontracted’ to the procedure when necessary.
Modularity
- In some languages the procedure may directly operate on the variables in the main program.
- However, greater flexibility is provided using arguments and parameters.
- Arguments are the actual values passed by the main program, parameters are their generalised representations in the procedure.
- Procedures can be stored in libraries, and linked in as required.
- Procedures also provide a useful means of clarifying the logic in a program, even if only called once.
Object Orientated Programming
- A class is the name given to a collection of objects – it can also be thought of as a template.
- An object has:
- A set of characteristics ( attributes or properties )
- A set of things it can do ( actions , operations , methods or services )
- A current state (defined by the values of its attributes)
- The data and the methods for changing it are in the same ‘bundle’ ( encapsulation ).
- Programmer can issue requests to change properties.