Professional Documents
Culture Documents
PROCEDURAL PARADIGM
The problem with procedural languages is that it can be difficult to reuse code and
to modify solutions when better methods of solution are developed. In order to
address these problems, object-oriented languages (like Eiffel, Smalltalk and Java)
were developed.
The point to note with these procedural languages is that the programmer has to
specify exactly what the computer is to do.
Procedural languages are used to solve a wide variety of problems. Some of these
languages are more robust than others. This means that the compiler will not let
the programmer write statements that may lead to problems in certain
circumstances.
Procedural languages may use functions and procedures but they always specify
the order in which instructions must be used to solve a problem. The use of
functions and procedures help programmers to reuse code but there is always the
danger of variables being altered inadvertently.
1
OBJECT-ORIENTED PARADIGM
For object-oriented paradigm the data and methods of manipulating the data, are
kept as a single unit called an object. An object comprises both data and
algorithms. The data describes the state of the object. Objects communicate by
sending messages to each other. When an object receives a message, it responds by
executing one of its algorithms. The algorithm may change the state of the object,
generate output, or send messages to other objects. OOPS are well-suited to
programming graphical user interface (GUIs). Typically, each element of a GUI is
represented by one object. The object determines both the state and the behavior of
the corresponding element.
For example, an object representing a window would have data for its position,
size and title. If the user closes the window, the OOPS sends a message to the
window object telling it to close itself. The window then executes an algorithm that
erases its image from the screen. The only way that a user can access the data is via
the object's methods. This means that, once an object is fully working, it cannot be
corrupted by the user. It also means that the internal workings of an object may be
changed without affecting any code that uses the object.
Data encapsulation is the combining together of the variables and the methods
that can operate on the variables so that the methods are the only ways of using the
variables.
Advantages
Modularity
The objects in an OOPS are self-contained, and have clearly defined interfaces to
other objects. This facilitates writing modular code, which reduces the inherent
complexity of a program.
Extensibility
2
Adding a new feature is often simply a matter of defining an object to implement
it. Furthermore, new sub-objects can be defined without having to modify, or even
see, the original code.
In principle, the same thing can be done in a procedural language. However, for
technical reasons, it is more difficult, and it very often corrupts the original design
of the program, leading to unmanageable complexity.
Disadvantages
FUNCTIONAL PARADIGM
Programs written using this paradigm use functions, which may call other
functions (including themselves). These functions have inputs and outputs.
Variables, as used in procedural languages, are not used
in functional languages. Functional languages make a great deal of use of
recursion. This makes it a very powerful programming paradigm.
Functional languages are often simpler syntactically and make it easier to work on
abstract problems, but they can also be "further from the machine" in that their
programming model makes it hard to understand exactly how the code is translated
into machine language (which can be problematic for system programming).
DECLARATIVE PARADIGM
3
languages are particularly useful when solving problems in artificial intelligence
such as medical diagnosis, fault finding in equipment and oil exploration. The
method is also used in robot control. An example of a declarative language is
Prolog.
SCRIPTING
A script is an interpreted language that runs on a client. That is they run on your
computer instead of on a web server. Scripts are used to add special multimedia
effects to web pages. Examples: animated graphics, scrolling messages, ads and
calendars. Scripts also allow interactive capabilities.
SUMMARY
Designers and programmers can decide how to build a program using any or a mix
of these paradigm elements.