Skip to main content

Use of Object-Oriented Programming Style

Lalit Kumar is a software developer and programmer and has been developing websites and software since 2008.

What are the benefits of OOS?

What are the benefits of OOS?

What Is OOPs?

Object-oriented programming or OOPs is the modern programming style which supports the creation of large and complex software architecture in an easy and maintainable manner.

OOPs represent a major shift from traditional procedural programming using data and functions. The data is stored in variables and passed to a defined function which in turn performs some action and modifies it or creates new data. We can define the traditional procedural programming style as a list of instructions which gets executed in an orderly manner defined by control flow statements and functions.

For simple programming tasks, use of procedural programming style is well suited, but as the program becomes complex and software architecture becomes large, object-oriented programming is suitable to create modular designs and patterns.

Data and functions are very much separated in procedural programming style, whereas in OOPs, data and functions are tied together in an entity called an object. We call the functions of an object to modify its data. These data in OOPs are known as properties and functions used to modify properties are called methods.

Major Benefits of Using OOPs

  1. Encapsulation: Objects created in OOPs are able to hide certain parts of code from the programmer. This prevents unintentional modification in the code which may cause unwanted outcomes.
  2. Code Reuse: Objects created in OOPs can easily be reused in other programs.
  3. Software Maintenance: Code written in OOPs is easy to debug and maintain.
  4. Design Benefits: OOPs need extensive design planning which certainly provides design benefits over traditional style.

Core OOPs Concepts

  • Abstraction: This concept includes hiding the program's internal details and implementing things easily. In OOPs, there are many ways to achieve this, including Encapsulation and inheritance.
  • Encapsulation: In the object-oriented programming style, we use Encapsulation to implement abstraction. Encapsulation is used for access restriction to property or method of class. We use access modifiers to implement these access restrictions. There are three access modifiers are available private, public and protected.
  • Polymorphism: We can define many methods in a class with the same name but different types and number of variables it takes as inputs. This is the concept of Polymorphism, where an object behaves differently in different situations. There are two types of Polymorphism – compile time polymorphism and runtime polymorphism.
  • Inheritance: Inheritance encourages code reuse in programming. This is the concept in which we define a class which extends properties and methods from another class. This way, a new class has all the properties of the class from which it is extended and you can add extra properties and methods in your new class.
  • Association: Association is the OOPS concept which defines the relationship between two objects. It defines one too many or many to one relationship between two objects.

Access Modifiers

  1. Private: Properties and methods defined with private access modifiers can only be accessed by the class in which these are defined.
  2. Public: Available everywhere on object instantiation.
  3. Protected: Available within the class itself and in the derived class.

OOPs' Common Elements

  • Class: Behaviour and contents of an object are defined in a class. So a class is a set of instruction to create an objects.
  • Property: Variables defined inside a class are known as properties. These variables contains data.
  • Methods: Functions defined inside a class, which perform some action on properties and inputs are called methods.
  • Object: Object is a specimen of class. It is a self-contained entity which consists of methods and properties to make a particular type of data useful.

Explaining OOPs

Object-oriented programming (OOP) is a programming language paradigm structured around objects and data rather than actions and logic. A traditional procedural program is organized to take input data, process it and produces the result. Program was centralized around logic rather than data.

In object-oriented programming, we concentrate on objects and its manipulation and not on logic which do it. OOPs programmers choose many things as objects for illustration like Car, Dog, Human, Building etc.

The first step in OOPs is data modelling, which includes identification of objects involved, ways to manipulate them and the relation between all objects. Data modelling is a planning phase and requires extensive care. Once all objects involved in the program are identified, we put a mechanism to create those objects. This mechanism is known as class. A class contains data or properties and methods which are logical sequence to manipulate data. All methods should be distinct in nature and should not repeat the logic already defined in other methods.


More Terms Used in OOPs

  • Interfaces: Interfaces contains the protocols which define methods a class must contain. Interfaces are defined just like a class and used by programmers to follow pre-defined rules from the original creator to use APIs.
  • Static Class, Property, Method: Static class or property or method contains values which are common for all objects and can be accessed without creating objects.

This content is accurate and true to the best of the author’s knowledge and is not meant to substitute for formal and individualized advice from a qualified professional.

Questions & Answers

Question: what is the difference between object oriented programming laguage and non object oriented programming language?

Answer: Non-object oriented programming is called procedural programming languages. Object Oriented Programming supports features such as Inheritance, Encapsulation, Polymorphism, Abstraction which the above languages do not support.

Question: What are the usages of OOP?

Answer: Object-Oriented Programming supports features such as Inheritance, Encapsulation, Polymorphism, Abstraction. Object-oriented programming is a modern way of software development. So all modern software you see is developed using OOP.

Question: What do I need to start coding in Java?

Answer: You only need a good PC with at least 4GB RAM & 100 GB HDD. Install java which is available for free.

Question: Application of OOP?

Answer: Object oriented programming is modern way of software development. So all modern software you see are developed using OOP.

© 2018 Lalit Kumar


Mark Gatere on November 04, 2019:

This information was so helpful.

Thank you so much Sir Lalit Kumar.