The main difference between structured and object oriented programming is that structured programming allows developing a program using a set of modules or functions, while object oriented programming allows constructing a program using a set of objects and their interactions.
What is Structured Programming
Structured Programming divides a program into a set of functions or modules. Modular programming is another name for this. These functions have statements embraced inside curly braces. Each of these functions performs a subtask. Usually, as each function represents a specific functionality, it is easier for the programmer to test and debug the code, but this can differ depending on the program. C language and Pascal are two common structured programming languages.
In the structured programming C, the user can create his own user-defined functions. The main function calls the other functions. It indicates the execution of the program. When there is a function call, the control is passed to that function. After completing the function, the control passes back to the main program. Moreover, a variable inside a function is a local variable, and global variables are accessible by all the functions.
What is Object Oriented Programming?
Object oriented programming allows the programmer to represent real-world scenarios using objects. An object is any entity that has states and behaviours. States represent the attributes or data of an object, whereas the methods represent the behaviours of objects. Student, Employee, Book etc. are objects. These objects interact with other objects by passing messages. Furthermore, a class is a blueprint for creating an object. It is necessary to have a class to create objects. For example, to create an Employee object, there should be an Employee class.
0 टिप्पणियाँ:
Post a Comment