This is the second day of my participation in Gwen Challenge

We’re always talking about object orientation, but what exactly is object orientation? What about process orientation before object orientation?

In fact, both object – oriented and process – oriented are ways of thinking that we solve problems in programming.

At the beginning, when analyzing and solving problems, people would list all the steps needed, and then realize these steps one by one through functions in the computer. This kind of procedural narrative thinking is process-oriented thinking.

For example, if you put an elephant in a refrigerator, what would you do?

Step 1: open the fridge door, step 2: push the elephant in, and step 3: close the fridge door (assuming the elephant is well-behaved and the fridge is large enough to close the door).

This works, but when the scene changes — an elephant becomes a pig, a refrigerator becomes a wardrobe — the same steps are written again in process-oriented code. This leads to code development becoming a ledger, which over time becomes noodle code.

If we look closely at these process-oriented steps, we will find that they are all commands: open the refrigerator door, push the elephant, open the closet door, push the pig. You can find the commonality in these two scenes, that is, the refrigerator door and the wardrobe door have the characteristics of opening and closing, and the elephant and pig can walk, so they can be pushed in.

When our perspective is no longer the process, but the operation object, refrigerator door and wardrobe door can be abstracted into doors, with the characteristics of opening and closing, elephants and pigs can be abstracted into animals, with the characteristics of walking. Following this line of thinking, we can reduce the matter to subject-verb construction: the door opens, the animal walks in, the door closes.

This idea of breaking things down into objects and describing the behavior of objects in the whole thing is object oriented.

You’ll find that process-oriented is more about the steps of things, object-oriented is more about the behavior of objects.

Object orientation can be abstracted based on the commonness of objects, which lays a solid foundation for the reuse and extension of software engineering. This is why many large software development models are programmed in object-oriented languages.