Analysis of different issues faced in Object-Oriented programming

Comments · 3929 Views

Object-oriented design is a software engineering approach that models a system as a group of interacting objects. Even though it has been widely used by programmers, there are many issues that are being faced while using it on very large scale. This article discusses about object-oriented

  1. Introduction

The main goal of structured programming is to find abstraction that enables us to build correct and efficient computer programs. The main idea used to create object-oriented design is to use an object as abstraction. The behavior of the program results from the collaboration of those objects.

There are three important parts of object-oriented programming:

  1. Uses of objects and not algorithm as its fundamental logical building.
  2. Each object is an instance of some class.
  3. Classes are related to one another through inheritance relationship.

A program cannot be object-oriented if it is missing any of these elements. The goal of object-oriented approach is to make system elements more reusable, thus improving quality and the productivity of system analysis and design.

  1. Mechanism of Object-oriented programming

 The main foundations for object-oriented system development includes object, encapsulation, inheritance and polymorphism. In order to understand the essential features of an application in the complex real world, an object-oriented model is built around objects. An object encapsulates both data and behavior which can be used for data modeling and process modeling. Specific objects in a system can inherit characteristics from the global instance of an object. Inheritance attempts to avoid the redundant definition of similar characteristics that can be embodied at higher levels in the system. By using polymorphism, functionality that is conceptually similar among differing objects is extracted to a global level.

  1. Issues faced in Object-oriented programming

3.1 Code Complexity

The most important aspect of programming is keeping the code's complexity as low as possible. Wrong abstraction and shared mutable states make code very complex in OOP. It fails especially when the complexity of program increases. Instead of reducing its complexity, it encourages promiscuous sharing of mutable states and introduces additional complexity with its numerous design patterns. This makes it hard to write a good and maintainable object-oriented code. While following this technique most of the time is spent thinking about ‘abstraction’ and ‘design patterns’ instead of solving real-world problems. For efficiency sake, objects are passed to function not by their values but by reference. If an object is passed by reference to an object constructor, the constructor can put that object reference in a private variable which is protected by encapsulation.

3.2 Input/Output

Object oriented programming is non-deterministic unlike functional programming, we’re not guaranteed to get the same output given the same input. For example if we call get_product(int x,int y) function which takes two arguments we might get different answers sometimes.

3.3 Understanding and debugging issues

Understanding Object Oriented code is a big problem for beginners. If an object-oriented programming code is very complex, it gets very hard to debug it. This can be caused due to inheritance and polymorphism. 

Inheritance

Inheritance creates problem for someone who is trying to understand a code written using OOP. In order to figure out what given method does, you have to search up to the class hierarchy until you find its definition. Inheritance also increases the load on the program and the program runs slower than normal as there is indirection. Sometimes data members in the base class are left unused which leads to memory wastage.

Polymorphism

The problem with polymorphism means that simply finding a function with the right name is not sufficient, you have to also look at the parameters. Trying to read code without a good class browser is almost impossible. It is impossible once you get into virtual functions where the decision of which function gets called is only determined at runtime. Polymorphism also limits the production of parallel functionality and streamlines the information interface. Polymorphism directs the specification writer to understand the functionality of a process and make it available to any object that requires a similar instance of functionality. 

3.4 Memory leakage

A memory leak is a type of resource leak that occurs when a computer program incorrectly manges memory allocation in a way that memory which is no longer needed is not releases. Using a class to handle upstream API interaction is fairly common practice. However, if variables were defined on the class for convenience in defining their initial value or type, this could lead to unnecessary allocation and persistence.

4. Conclusion

A good programming framework helps us to write reliable code. It should help reduce complexity by providing modularity and reusability, proper state of isolation and high signal-to-noise ratio. One of the solutions to this is using functional programming. It has strong mathematical foundation and takes its roots in lambda calculus. The core abstraction of Functional programming are functions and when used properly it will provide a level of code modularity and reusability. It makes debugging very easier. Object oriented programming do have many advantages but can be more helpful if used for less writing less complicated codes.

Comments