A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having a single entry and a single exit point, and in which control is passed downward through the structure without unconditional branches to higher levels of the structure.
The Fundamental Principle of Structured Programming is that at all times and under all circumstances, the programmer must keep the program within his intellectual grasp
Features of Structured Programming
Emphasis is given on algorithm rather than on data.
Programs are divided into individual functions. Each function has a clearly defined purpose and clearly defined interface to other functions in the program.
Supports modular programming.
The idea of breaking into functions can be further extended by grouping a number of functions together into a larger entity called a module.
Maintenance of program is easier than procedural program.
Disadvantages of Structured Programming
Lack of Encapsulation
But while the encapsulation concept is a powerful working tool, its lack of availability in structured programming means that programs will be longer.
The same or similar code will appear in more than one location. This also means that the programs will have a greater chance of errors. The testing will be lengthy as well since every piece of code will have to be tested. Even if the code is without errors in one place, the same piece of code may appear in a different part of the program and could have problems there.
Same Code Repetition
Because the code that is written may appear in different parts of the program, it can be vulnerable to different problems because of its location. Programs have variables, which means that they can take on different values at different parts of the program. So the testing that is necessary to develop an error-free program can be time consuming.
Lack of Information Hiding:
In procedural approach, the program code can not be secured due since unauthorized users due to following reasons;
Focus on functions rather than data.
Global variable overcome the local variable.
In large program, it is difficult to identify which data is used for which function.
Global variables are more vulnerable to an careless change by a function.
To revise an external data structure, all functions that access the data should also be revised.
Maintaining and enhancing program code is still difficult because of global data.
Object Oriented Programming (OOPs)
The methodology focuses on data rather than processes, with programs composed of self-sufficient modules (objects) each containing all the information needed to manipulate its own data structure which provides for code reuse, and self-sufficient reusable units of programming logic.
An object-oriented program may be viewed as a collection of interacting objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects and can be viewed as an independent 'machine' with a distinct role or responsibility.
Features of OOPs
Objects
Classes
Inheritance
Data Abstraction
Data Encapsulation
Polymorphism
Overloading
Reusability
Message Passing
Features contd…
Objects:
Object is the basic unit of object-oriented programming. Objects are identified by its unique name. An object represents a particular instance of a class. There can be more than one instance of an object. Each instance of an object can hold its own relevant data.
Classes:
A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.
Classes are data types based on which objects are created. Objects with similar properties and methods are grouped together to form a Class. Thus a Class represents a set of individual objects.
Inheritance:
Inheritance as the name suggests is the concept of inheriting or deriving properties of an exiting class to get new class or classes. In other words we may have common features or characteristics that may be needed by number of classes.
So those features can be placed in a common tree class called base class and the other classes which have these characteristics can take the tree class and define only the new things that they have on their own in their classes.
Features contd…
Reusability:
This term refers to the ability for multiple programmers to use the same written and debugged existing class of data. This is a time saving device and adds code efficiency to the language.
Additionally, the programmer can incorporate new features to the existing class, further developing the application and allowing users to achieve increased performance.
This time saving feature optimizes code, helps in gaining secured applications and facilitates easier maintenance on the application.
Data Abstraction:
An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer. It focuses on the outside view of an object, and so serves to separate an object’s essential behavior from its implementation and essential characteristics of some object, relative to the perspective of the viewer.
Data Encapsulation:
It is the mechanism that binds together code and data it manipulates, and keeps both safe from outside interference and misuse (acts like protective wall). The data are visible only to that particular function, called data hiding.
For example consider a T.V. (relating to the real world). It encapsulates hundreds of bits of information about the internal architecture. The user has only one method of affecting this complex encapsulation: by opening the T.V. box.
Features contd…
Polymorphism:
The word “polymorphism” is derived from Greek word “poly-morphos” which means many forms. Polymorphism is an ability to take more than one form is called polymorphism. It is similar to that one people acting differently according to the situation. An operation may exhibit different behavior in different instances that depends upon the types of the data used in the program.
Overloading:
Overloading is a kind of polymorphism. In other words say for instance we know that +, - operate on integer data type and is used to perform arithmetic additions and subtractions. But operator overloading is one in which we define new operations to these operators and make them operate on different data types in other words overloading the existing functionality with new one. This is a very important feature of object oriented programming methodology which extended the handling of data type and operations.
Message Passing
An Object-Oriented program consists of set of objects that communicate with each other. Object communicates with each other by sending and receiving message (information). A message for an object is a request for execution of a procedure and therefore will invoke a function or procedure in receiving object that generate the desired result. Message passing involves specifying the name of the object name of the function (message ) and the information to be sent .
Differences between Structured and Object Oriented programming Language
6. ‘C++’ follows bottom-up approach. 6. ‘C’ follows top-down approach 5. New data & function can easily be added whenever the need arises. 5. It is very difficult to add the new function and data once the program is completed. 4. Data more valued. 4. Data undervalued 3. Object may communicate with each other through function. 3. Most of the function shares the global data. Function transforms the data from one to another. 2. Programs are divided into what we known as object. 2. Larger programs are divided into smaller programs known as functions. 1. It is an object oriented technique in which emphasis is on data rather than procedure or algorithm. 1. It is a procedure language emphasize on doing the things only i.e it focuses on algorithm. Object Oriented Structured
Exercise
What is structural programming? Explain its drawbacks.
What is object oriented programming language? Explain its major feature.
Differentiate between structural and object oriented programming language.
Give at least five real life example of objects and classes.
Note:
you must submit this assignment at 16th kartik, 2068
This assignment carry the marks of one unit test.
If you will be absent in that day, then you have to send through your friends
Comments