OOPS-Object Oriented Programming Structure

OOPS is a programming methodology which organizes the programs as Object and data, rather than action and logic. This shift from action-based to the object-based is to bind the data and the functions together and

OOPS is a programming methodology which organizes the programs as Object and data, rather than action and logic. This shift from action-based to the object-based is to bind the data and the functions together and to restrict other parts of the code (unwanted code) from accessing them.

OOPS provide the below advantages over procedural structure:

  1. Data Security: Methods can access data only if they have access.
  2. Modularity: Action and Logics are stored in various classes. So adding or removing features will be easy. Even multiple users can work on the same application as the code is modular and it will not have interdependency.
  3. Reuse of Code: There would be times when you would write the same code over and over with OOPS you could write the code once and refer the logic whenever required.
  4. Faster Development: Code reusability and modularity lets team to work simultaneously and reuse code block to reduce development time.
  5. Easy to Maintain: As the code is modular in nature upgrades for the application will require fewer code changes.

Building Blocks Of OOPS Model:

  1. Object
  2. Class
  3. Inheritance
  4. Polymorphism
  5. Abstraction
  6. Encapsulation

CLASS:

A class is like a container that can store properties, fields, events, method, etc to perform a defined activity. You can create your own custom data types with class. To access the data within the container you would need to create an object of the container. The Class is the core foundation of OOPS.

OBJECT:

If a class is a container then the object is a way by which we can access the data associated with the class. An object is an instance of a class. When we create an object for a class, the memory will be allocated for the class.

ENCAPSULATION:

Encapsulation is a process of enclosing/binding Member variables and Member Functions together within a single package usually called a class. As a result, we are able to hide the implementation details of a class from a client function.

ABSTRACTION:

If Encapsulation is a process of enclosing data into packages, then Abstraction is a way of making relevant information visible by hiding the background details. For implementing Abstraction we use access Specifiers.

Access Specifiers: Define the scope and visibility of a class member. The following are the list of access specifiers in c#.

  1. Public: It allows a class to expose its member variables and functions to other functions and objects. i.e public member can be accessed from outside the class.
  2. Private: Only functions of the same class can access its private members.
  3. Protected: It lets a child class access the member variables and functions of its base class and helps in implementing inheritance.
  4. Internal: It allows a class to expose its member variables and functions to other functions and objects wit in the same assembly.
  5. Protected internal: It allows a class to hide its member variables and functions from other class objects and functions, except a child class within the same application.

DATA HIDING:

It is a process of hiding the internal structure of an object from the rest of the program. For implementing data hiding we use Abstraction and Encapsulation.

3 thoughts on “OOPS-Object Oriented Programming Structure

Leave a Reply

Your email address will not be published. Required fields are marked *