Is a template template template an example of inversion of control?

Recently, in an interview, I explained about the structure I was working on. I said that we created control inversion by providing extensibility using a template design pattern. I said that this is an example of Inversion of Control, in which our infrastructure called methods implemented by a user of the framework, to which the interviewer said that the template of the template method template is not an example of IOC. I wonder if my understanding of the IOC is wrong?

+4
source share
2 answers

Your interviewer was wrong. The template method template uses inverse control. In fact, the Wikipedia entry specifically mentions this.

http://en.wikipedia.org/wiki/Template_method_pattern

, , "" . , .

, IoC, , , IoC. , , , , IoC Injection Dependency, .

+6

, IOC, , (DI ..). , , ( , ), , , , Base/Parent , , , , .

. , .

public abstract class FileProcessor {
    public final void processFile() {
        preProcess();
        process();
        postProcess();
    }

    public abstract void preProcess();
    public abstract void process();
    public abstract void postProcess();
}
0

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


All Articles