[PYTHON] What is object-oriented programming? ~ Beginners ~

I often hear the word "** object-oriented programming **", but I didn't understand it well, so I looked it up, but it's just a memorandum for programming beginners, so if you have any mistakes, please point out more and more.

In addition, there are many technical books and websites that explain object-oriented programming, and all the explanations are different, and the answers are different depending on the engineer. There is no clear answer, so it's good to understand the atmosphere roughly. If you try to understand 100%, you will not understand well, and as you grow up, understanding will progress and you will be able to define it within yourself. Become. That's the stance, so I'm not asking for 100% understanding at this point. Thank you for your cooperation.


What is object-oriented?

First of all, object-oriented is not the name of a specific programming language or method, but the way of thinking when programming. It means "** concept **".

If you look it up on wikipedia

`Object-oriented programming (object-oriented programming, English: object-oriented programming, abbreviation: OOP) is to combine data and methods that are closely related to each other into one object, and give them different properties and roles. It is a software development method that builds the entire program through various definitions of objects and the settings of various processes that interact with these objects. ``

a. In addition, the background to the birth of object-oriented programming was the rapid development of computer technology, which required coding a huge number of lines in order to write a program that suits the purpose, and the complexity of programming. And the idea that was born as this solution was the idea of ​​thinking of programming as a "collection of things".

I would like to break it down further and explain it in an easy-to-understand manner, but I cannot explain it at my level at the moment, so I referred to the article "What is object-oriented?" below.

What is an object = thing in a program?

As an example, consider "building a city with a 3D model".

I will explain the ideas of "** Pre-object-oriented concept " and " Object-oriented **" respectively.

■ Pre-object-oriented thinking A method that does not consider buildings, roads, and cars running on them as "things" In other words

--A square white object with some holes in it = a building --Wide flat white line = road --The box has four movable wheels = car

The method was taken to enumerate.

■ Object-oriented Start by ** preparing "things" named "buildings," "roads," and "cars." After that, "building" is defined as having characteristics such as "square", "made of concrete", and "the inside is divided into rooms".

As mentioned above, before the birth of object-oriented programming, it was difficult to take the method of "asking people for only" automobiles "" with "one continuous program" for cities. On the other hand, in object-oriented programming, "city" is regarded as "** a set of individual programs made into objects **" such as "buildings", "roads", and "automobiles", and each one is created separately. Can be done.

This is the difference between the traditional method and object-oriented programming. The idea of ​​making programming convenient and rational can be said to be object-oriented.


What are the benefits of object orientation?

Object-oriented has the following merits.

-** Easy to understand the whole picture of programming ** -** Easy division of labor and collaboration ** -** Easy to improve and modify ** -** Programming can be made faster or lighter depending on the process **

Let's look at each one.

■ ** Easy to understand the whole picture of programming **

Returning to the "city" example above, the traditional method is programmed as "instructions to a continuous computer without boundaries", whereas in object-oriented programming it can be recognized as "a place made up of buildings, roads and cars". ..

** You can clearly understand the structure of the entire program and design the program with the image of designing an actual city. ** **

You can proceed with the project by first formulating the overall image and then elaborating the details.

■ ** Easy division of labor and collaboration **

If the entire program is continuous and unbroken, it will be difficult for multiple programmers to collaborate. On the other hand, if it is object-oriented, it will be much easier to divide the labor while separating the program, "I will make the whole structure, so you should make the building."

The advent of object-oriented programming is said to have contributed to the realization of huge systems involving hundreds of programmers.

■ ** Easy to improve and modify **

In most programming work, we constantly make corrections and changes, and repeatedly work toward the goal. For example, suppose that when it is nearing completion, there is a revision opinion that you want to attach "antennas" to the rooftops of all "buildings." If it is a "one connection" program, the work of "inserting the antenna program one by one into all the buildings already made" will occur, resulting in a huge amount of work.

On the other hand, if you are object-oriented, you can add "antenna" to the definition of "building" and modify all "buildings" with just one action.

An object-oriented feature is that it can be modified at once, just like putting a horizontal skewer in a program.

■ ** Programming can be made faster or lighter depending on the process **

Object-oriented programming is similar to circuit design for electronic components.

As with circuit design, "how to group and separate the entire program", that is, to create the structure, is an important role of the programmer, as in the case of circuit design, which "connects parts to create overall functions". Become.

With this idea, calculations can be made much faster and memory can be made lighter.

In fact, there are genius programmers out there who "write a program that takes 100 lines in 5 lines for a normal person". It can be said that this is possible thanks to object orientation.


in conclusion

I've read several articles about object-oriented programming, and I feel that the article I referred to this time was easy for me to understand. And I think it was a very easy-to-understand article for programming beginners, but how was it? I don't understand 100%, but I would like to gain more experience and deepen my understanding. Thank you! !!

Recommended Posts

What is object-oriented programming? ~ Beginners ~
What is programming?
[For programming beginners] What is a method?
What is object-oriented after all?
What is object-oriented after all?
Object-oriented programming
[# 2 Java] What is object-oriented programming that you often hear?
What is a snippet in programming?
What is Cubby
What is Docker?
What is java
What is Keycloak
Kantai Collection Java # 0 What is Object Oriented Programming (OOP)? [For beginners]
What is maven?
What is Jackson?
What is Docker
What is self
What is Jenkins
What is ArgumentMatcher?
What is IM-Juggling?
Object-oriented programming terminology
What is params
What is SLF4J?
[For super super beginners] What is object orientation?
What is Facade? ??
What is Java <>?
What is Gradle?
What is POJO
What is Java
What is centOS
What is RubyGem?
What is before_action?
What is Docker
What is Byte?
What is Tomcat
What is Maven Assembly?
What is `docker-compose up`?
What is a constructor?
What is vue cli
What is an interface?
What is Ruby's self?
What is hard coding?
What is a stream
What is Ruby's attr_accessor?
What is Java Encapsulation?
What is permission denied?
What is instance control?
What is an initializer?
What is Spring Tools 4
What is an operator?
What is object orientation?
What is Guava's @VisibleForTesting?
What is MVC model?
What is an annotation?
What is Java technology?
What is Java API-java
What is @ (instance variable)?
What is Gradle's Artifact?
What is JPA Auditing?
[Swift] What is dismiss?
[Java] What is flatMap?