Is there a name for a java method that is considered separate from any particular class?

This is a terminological issue that complicates the task!

Let me give you an example. Suppose I am writing a symbolic differentiation algorithm. I have an abstract class Exp, which is a superclass of a group of expression types (sums, integrals, whatever). There is an abstract derivative of a method such that e.derivative () is assumed to be a derivative of the expression e. All specific Exp subclasses (representing a whole hierarchy here) implement a derived method that captures knowledge of how to distinguish expressions of this type. This method usually computes the derivative of an expression by combining the derived subexpressions.

The details of this example are not important. The important thing is that all these scattered methods can be considered as parts of one (recursive) algorithm. This does not apply to all methods, but this is true for many of them (and using an overload to reuse the same method name for fundamentally different operations is considered a bad idea). The question is, what does the term “derivative” mean, considered as a single function? This is not a method; in another language, this would be a function, and the various points (what to do with the sums, what to do with the integrals) would be in the same place. I don't care which approach or skill is better, or whether this style can be used in Java. I just want to know which term to use for "derivative",considered as the only function or procedure (the idea is not limited to functional programming, and is not a key feature of recursion). When I tell someone what I did today, I would like to say: "I tried to make a symbolic difference__ , but every algorithm I thought about didn't work. "What happens in the sample?

I assume the same problem occurs for other OO languages, but Java is the one I am most familiar with. I am so familiar with this that I am sure that there is no standard term, but I thought that I would ask us for an excellent battery of experts before proceeding with this conclusion.

+3
source share
4 answers

"" . / , . " ", , , " "(" , Java ") " "( Java) /if -else. , - .

: Scala case-classes ? . , , "" "" " ", :

... OO, . , . , , . , . , ... , , . , .

+2

, , , , . , GoF . , Java.

+1

, , "" Java.

+1

A polymorphic function can be applied to values ​​of different types. A function can be implemented by more than one Java method.

0
source

Source: https://habr.com/ru/post/1778887/


All Articles