OO Programming  «Prev  Next»
Lesson 2 Traditional approach/ Procedural Programming
Objective Procedural programming and how it is used.

Traditional Approach of Procedural Programming

Prior to the rise of object-oriented programming, the most popular approach was procedural, or structured, programming. Structured programming uses top-down design to decompose a problem into a series of successively more granular functions. Structured programming requires well-defined flow control. Languages that support this are often called procedural languages because of their heavy reliance on procedures.
Development begins by identifying the problem domaindefining what th, e problem is that your project is supposed to help solve. This is the case whether you use a procedural or an object-oriented design. Once the problem domain has been identified, however, the two methods diverge. Procedural designs begin by defining the procedures, starting with a top-level function. From there, the problem is broken into more specific procedures. For example, a program that converts GIF files to JPEG files might begin with a single function called convertImage(), which demonstrates the traditional programming approach. This function is then broken down into three functions called
readGIF(), 
convertGIFtoJPEG(), 

and
writeJPEG().

In turn, each of these functions can be broken down even further.

Method Notation for Procedural Programs

  • Procedural design approach: The traditional design approach is in use in many software development projects at the present time. This traditional design technique is based on the data flow-oriented design approach. It consists of two important activities;
    1. first structured analysis of the requirements specification is carried out where the detailed structure of the problem is examined.
    2. This is followed by a structured design step where the results of structured analysis are transformed into the software design.
  • Naming Conventions for Procedural Methods: First, you must understand what a function is, and then you can proceed to find out how it can be most effectively used in the development of programs. Go back to the very first program that you wrote , which displayed the phrase "Programming in C" at the terminal. The following is an example of a simple C Program.
  • First version using builtin prinf
    #include <stdio.h>
    int main (void)
    {
     printf ("Programming in C.\n");
     return 0;
    }
    
  • Second Version with a user-defined printMessage: Here is a function called printMessage that does the same thing:
    void printMessage (void)
    {
     printf ("Programming in C.\n");
    }
    

    The differences between printMessage and the function main from the first version is in the first and last line. The first line of a function definition tells the compiler (in order from left to right) four things about the function:
    1. Who can call it
    2. The type of value it returns
    3. Its name
    4. The arguments it takes

Naming Conventions for Object Oriented Methods

In this course, function and method names that are inline with the text are identified by putting empty parentheses after them.
			
getData()

  • Internal capitals used for methods
    This course adopts the common convention of using internal capitals, such as
    	 
    convertImage()
    

    in the method and variable names. This convention is not written in stone, but it does make code easier to read and identifiers in the text more obvious.

Object-Oriented Analysis

Advantages and Disadvantages of Object-Oriented Programming

  • Advantages of object-oriented Programming:
    1. Improved software-development productivity: Object-oriented programming is modular, as it provides separation of duties in object-based program development. It is also extensible, as objects can be extended to include new attributes and behaviors. Objects can also be reused within an across applications. Because of these three factors 1)modularity, 2) extensibility, and 3) reusability object-oriented programming provides improved software-development productivity over traditional procedure-based programming techniques.
    2. Improved software maintainability: For the reasons mentioned above, objectoriented software is also easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes.
    3. Faster development: Reuse enables faster development. Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects.
    4. Lower cost of development: The reuse of software also lowers the cost of development. Typically, more effort is put into the object-oriented analysis and design, which lowers the overall cost of development.
    5. Higher-quality software: Faster development of software and lower cost of development allows more time and resources to be used in the verification of the software. Although quality is dependent upon the experience of the teams, objectoriented programming tends to result in higher-quality software.
  • Disadvantages of object-oriented Programming:
    1. Steep learning curve: The thought process involved in object-oriented programming may not be natural for some people, and it can take time to get used to it. It is complex to create programs based on interaction of objects. Some of the key programming techniques, such as inheritance and polymorphism, can be challenging to comprehend initially.
    2. Larger program size: Object-oriented programs typically involve more lines of code than procedural programs.
    3. Slower programs: Object-oriented programs are typically slower than procedurebased programs, as they typically require more instructions to be executed.
    4. Not suitable for all types of problems: There are problems that lend themselves well to functional-programming style, logic-programming style, or procedure-based programming style, and applying object-oriented programming in those situations will not result in efficient programs

Object Oriented Analysis

Procedural Programming

Procedural programming refers to a programming paradigm derived from structured programming which is based upon the concept of the procedure call. Procedures, also known as
  1. subroutines,
  2. methods, or
  3. functions

simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself. A list of instructions telling a computer what to do, usually having a linear order of execution from the first statement to the second occasional loops and branches. Procedural programming languages include C, C++, Fortran, Pascal, and BASIC.
Programming Language Questions
  1. Question: What is meant by an executable specification language?

    Answer: When the specification of a system is expressed formally or is described by using a programming language, then it becomes possible to directly execute the specification without having to design and write code for implementation.
  2. Question: How is an executable specification language different from a traditional procedural programming language?

    Answer: Executable specifications are usually slow and inefficient and 4th Generation Languages are examples of executable specification languages. 4th Generation Languages are successful because their granularity can be used across data processing applications which have been identified and mapped to program code. 4GLs get their power from software reuse, where the common abstractions have been identified and parameterized. Careful experiments have shown that rewriting 4GL programs in 3GLs results in up to 50 per cent lower memory usage. In addition, the program execution can reduce run-time up to ten folds.

SEMrush Software