본문 바로가기

Computer Science/Concept

Object Oriented Programming

What is "Object" Object is everything that we are usuing in daily life. If you ever took any object oriented object program, you will know the "Car" example. 

 

What compose a car? Accelerator, break, steer wheel, doors, tires etc. 

These parts interact each other and let the car moves. 

 

In Programming, Object is instance (exist in real : actual car parts) which is created by Classes. Therefore, object oriented program compose with connection between those instances and inside that instances contain datastructures, logics and algorithems. 

 

Process Oriented Programming

So far Object Oriented Programming is one that we have to focuse on all the time. 

However, there is a major disadvantage when we are using the object oriented programming.

 

Process Oriented Programming is focusing on the functioning which means, "How many steps we need to do a task and how to increase the efficiency of each steps". 

 

Object Oriented Program is focusing on each instance which means "which part do this part of a task".

 

Process Oriented VS Object Oriented

  • Large scale Projects need to distribute responsibility to each part. When a single part has a small responsibility, it becomes easy to test, maintain and refactor. Also, we can group a many different part in large category.
    • We do not want to add acceleration and break on your steer wheel (Other than some special cases)
    • We can group a accelerator and break togetehr in movement category.
  • Small scale Projects does not require to distribute responsibility to each part therefore, process base is better to finish a task effectively. If we distribute responsibility in small scale projects, it can cause confusion.
    • For example, when we use hairspary, we do not need to know how strong it will be or how to stop spraying in the middle. 

 

Some Cool Features of Object Oriented Program

 

1. Abstraction

  • We can extract similiar functions and attributes of instances and manage them together.

2. Encapsulation

  • We can hide, or publish methods and variables to control access.
  • Each object can have their own responsibility
  • Libraries, Libraries, Libraries!!! (External Tool box that you don't actually have to build everything from scratch)

3. Inheritance

  • Inherate properties, functions from one class to other so that you can reuse a code that is already exist. 

4. Polymorphism

  • Calling a similar functioning methods in a same name (Overriding, Overloading)
    • Overrding - Implements a function that was inherated by using same parameters. 
    • Overloading - Declare multiple same name functions that perform differently by parameters.

 

Advantages and Disadvantages

Advantage:

  • Increase Productivivity

Since Object Oriented Programming is focusing on distribute responsibility, it is easy to resue codes, easy to implement the code, and easy to debug.

  • Easy to model a real world project

Because we are living in a such a complicated world that has various connection like a spiderweb between objects, using a Object Oriented Programming is perferred to use.

  • High security

Using a private method or variables can hide important information.

 

Disadvantage:

  • Increase amount of time to run a program

Because we divide responsibilities into tiny particles, it takes long to run each particles.

 

 

 

 

'Computer Science > Concept' 카테고리의 다른 글

Features of Object Oriented Programming - Abstraction  (0) 2023.05.02