[OOP] What Is Object-Oriented Programming?
[OOP] What Is Object-Oriented Programming?
If you end up working in IT, chances are you'll work with at least one of Java, C++, or C#. What these three languages have in common—including Java, the most widely supplied and demanded language in Korea's IT industry—is that they're all object-oriented languages.
Of course, the concept of functional programming has since emerged as well, but object-oriented programming, which arose after C's simple procedural approach, offered a new perspective on programming, and countless languages, big and small, have been influenced by it, knowingly or not. Despite being such an influential concept, when actually asked a related question, people often can't give a clear answer.
Let's assume you were asked exactly this question, as the title suggests. I can't give a clear answer to this question myself. Even though I do have Java experience, I never had much interest in the theory, and as someone without a formal CS background, it was hard to pick up this kind of knowledge on the job without deliberately looking it up.
If you don't know how the language you use actually works, it's hard to say you're really using it properly. Through this post, I want to organize my understanding of the concept of object orientation.
Object-oriented. Literally, a language oriented around objects. To understand object orientation, we first need to understand the concept of an object, which this methodology is ultimately oriented around.
An object, as object orientation defines it, refers to an element that acts as the subject of a program's behavior. This object can be tangible or intangible. It might be something with a clear physical form, or it might be an abstract concept.
Every object has state and behavior. For example, think about buying a TV. Most people would consider a TV's design, performance, price, and so on before buying one.
A TV's color, screen size, and price can be seen as the TV's state. Changing channels, watching on-demand, connecting to Netflix, and so on can be seen as the TV's functionality.
In this way, every object has state and behavior.
Java, the flagship object-oriented language in Korea, approaches this concept as follows.
| Object Orientation | Java |
|---|---|
| Object | Class |
| State | Member Variable |
| Behavior | Method (Function) |
Let's look at an example of how Java handles the real-world object car as a class.
JAVA
/** * 자동차 클래스 * * @author RWB * @since 2021.08.05 22:06:24 */ public class Car { // 시동 여부 private final boolean IS_STARTED = false; // 최대 속력 private final int MAX_SPEED; // 현재 속력 private int speed; /** * Car 생성자 함수 * * @param maxSpeed: [int] 최대 속도 */ public Car(int maxSpeed) { MAX_SPEED = maxSpeed; } /** * 시동 결과 반환 함수 * * @return [boolean] 시동 결과 */ public boolean startUp() { return !IS_STARTED; } /** * 시동 종료 결과 반환 함수 * * @return [boolean] 시동 종료 결과 */ public boolean shutdown() { return IS_STARTED; } /** * 현재 속도 반환 함수 * * @return [int] 현재 속도 */ public int getSpeed() { return speed; } /** * 가속 함수 * * @param amount: [int] 속도 */ public void upSpeed(int amount) { // 시동이 걸렸을 경우 if (IS_STARTED) { // 가속된 값이 최대 속도를 넘지 않을 경우 if (MAX_SPEED >= speed + amount) { speed += amount; } // 가속된 값이 최대 속도를 넘을 경우 else { speed = MAX_SPEED; } } } /** * 감속 함수 * * @param amount: [int] 속도 */ public void downSpeed(int amount) { // 시동이 걸렸을 경우 if (IS_STARTED) { // 감속된 값이 0보다 클 경우 if (0 <= speed - amount) { speed -= amount; } // 감속된 값이 0보다 작을 경우 else { speed = 0; } } } }
The Car class in the code above implements the real-world object "car" in a very simple form.
- Member variables (state)
- IS_STARTED: whether the car's engine has started
- MAX_SPEED: maximum speed
- speed: current speed
- Methods (behavior)
- startUp: start the engine
- shutdown: stop the engine
- getSpeed: display current speed
- upSpeed: accelerate
- downSpeed: decelerate
The elements of the Car class break down as shown above. To use this object in Java, it must be allocated in memory, and an object allocated this way is referred to as an instance.
Allocating the Car class in memory to create a new instance is conceptually the same as rolling an actual car off the production line in real life.
Since it's object-oriented, as mentioned earlier, understanding it requires understanding what an object is. Since we've already gone into detail about objects in the previous section, we can define object orientation as a methodology for structuring code around such objects.
Every object has state and behavior matching its own characteristics, and through these, interactions between objects can be represented in code. Object orientation represents these object interactions in code.
For example, Java treats every element—String, HashMap, and so on—as an object. In Java, we allocate the objects we need in memory and write code using the variables or methods those objects have. This programming style in Java turns out to be exactly the same as the object orientation described so far.
Many languages have adopted object orientation. Beyond the flagship Java, there's C++, C#, Visual Basic, Swift, Python, and more. These languages aren't just familiar names to us—they're also major, heavily used languages that each hold a significant place among programming languages.
So why has object-oriented programming become so widely used and beloved among developers?
Object orientation emerged after procedural programming. Typically, when something comes along later like this, it tends to improve on the shortcomings or needs of what came before, offering a lot of advantages in functionality or convenience. Object orientation, in particular, focused on boosting productivity and maintainability, which is why developers working in object-oriented languages can generally develop more easily and quickly.
-
Code reusability
Because code is built around modularized objects, an object's characteristics can be applied to similar logic elsewhere, or objects implemented by other developers can be pulled in and reused with relative ease. -
Easier maintenance
When an object is modified, that change is applied uniformly across all the logic that uses it, simplifying the management of duplicate code. Or, if an object or behavior changes, you only need to find and modify the objects associated with that particular object or behavior. -
Advantageous for large-scale programming
Since work is divided by object and module, it's easier to split up responsibilities, and it's easier to diagram the relationships between modules.
-
Relatively slower speed
Unlike procedural programming, object orientation tends to be slower overall due to the dependency relationships between objects. -
Requires strong design skills
An approach built around interactions between modules depends heavily on how precisely each module is specified and how cohesively their interrelationships are designed. Poorly designed objects or relationships can easily degenerate into spaghetti code. -
Potential code complexity
Along with the demand for strong design skills, complex concepts like abstract objects, inheritance, and interfaces—and how they're used—can make a codebase's structure difficult to grasp.
- Java
- C++
- C#
- Python
- Simula 67
- Delphi
- Swift
- Ruby
- Perl
Mostly familiar faces here
Procedural programming, the foundation of the old C language, had its own merits too. Because the computer's processing flow closely mirrored the code's flow, there was little preprocessing overhead, making execution relatively fast. The code's flow was also consistent, which likely made it easier to analyze.
But as time passed, the times evolved, and the average developer's skill level rose as well. Computer processing speed hardly even needs mentioning. As the environment evolved this way, the advantages procedural programming offered became less valuable, while its disadvantages, conversely, became felt all the more heavily.
Object orientation is a development methodology that prioritizes ease of maintenance and development convenience. Thanks to the advantages object orientation offers, sharing code between developers became easier, the scale of services grew even further, and it became easier to build robust programs.
If procedural programming is friendly to computers, object orientation could be said to be friendly to developers. As computing performance skyrocketed, a program's performance naturally came to depend more on the developer's skill. This trend is likely what allowed object orientation to be embraced by so many languages and developers.
As AI technology has advanced recently, technologies like Copilot, where AI assists with coding, seem to be under research and starting to emerge.
Once time passes and developer skill eventually matters less, will some new methodology become the next dominant trend?

