――The conclusion is as follows.
First, I will explain the inheritance function from the basic history. (I'm sorry if you know it.)
In the olden days programming had little commercial value and had only small developments. From there, it became a large-scale development, and there was a problem that we wanted to make large-scale code easier to read and also lacked memory. So, by trying to save memory, I want reusability or abstraction! Thats how its going to be.
(Reconfirming the meaning of abstraction) For example, when we explain to others "baseball, soccer, tennis, etc. are fun!", In a word, "sports are fun!"
In the old days, programming did not have the power (abstraction) to put together such overlapping meanings. That's where object-oriented (Java) abstracts, which can also express parent classes (abstractions), came into play. (There was no interface at that time.)
The abstract was so flexible that it was hard to read. Both the method (function) and the global variable (state) came out, and it was something that I did not understand intuitively. Well, I could still use it.
At one point, there was a request for object-oriented development using abstract. I want to make it with polymorphism. And I want to make it easier to read by setting a little more restrictions.
Speaking of polymorphism, it's a List type. For example, you want to be able to handle both ArrayList and LinkedList with List type, and you want to be able to handle .size () and .add () with any type.
If you can handle inheritance relationships for such purposes, write them neatly in interface to make them easier to read! So the interface was provided to Java.
Over time, it became Java8, and the interface itself became able to have functions. It's the default function. I'm sure this story is a problem that I don't really understand the difference between abstract and interface.
The reason why this default function was provided is different from the request for abstraction so far. I think it was a measure against Moore's Law. There was a request for thorough parallelization because we wanted to save the resources of existing semiconductors as much as possible in order to be able to deal with the resource shortage problem as much as possible.
Therefore, a stream API was created to make parallel processing easy and safe, and a simple lambda expression was introduced because it was difficult to understand because it was full of anonymous classes.
In other words, default was created to provide a stream API for Moore's Law collapse countermeasures, so there is currently no rule that default can be used freely.
How to use default is basically a function required for stream API and lambda expressions, and I was not sure if I could use the default function freely. It will be nice to wait for a while.
You couldn't inherit multiple abstracts like interface. It seems that there is also a history of creating another abstraction function interface because it wants to inherit multiple times. (If multiple inheritance is possible, it will be difficult to track bugs, and it seems that in the past it was said to be a forbidden person or Pandora's box and was opposed.)
Computer is a hobby ↓ Computers are a source of business! ↓ Computers are a great industry! I want to handle programming on a larger scale! At least I want an abstraction function in programming! So I also want to save memory! ↓ High-performance Java is emerging. An abstract is also provided. ↓ It's hard to read abstract. I also want polymorphism. ↓ Providing interface ↓ Moore's Law is in jeopardy ....? I can't laugh .... Saya! Since we want to handle existing semiconductor resources effectively, let's provide a function that allows us to write thorough parallel processing in a concise manner! ↓ Providing stream API or lambda expression
I think that's how it was.
Q. What is the purpose of the reification coercion function (override)?
A. If you want to abstract things, you need to embody the opposite. For example, when trying to implement "playing baseball," "playing soccer," and "playing tennis"
(Fictional language)
abstract sports
do (play with ??)
I think that it will be designed. Isn't it easier to force this reification every time?
@Override
do (play with "baseball")
@Override
do (play with "soccer")
@Override
do (play with "tennis")
I think it will be. So, the answer to your question is, "I wanted to design in an abstract way, so it was easy to have a concrete function."
Recommended Posts