Factory method template

What is factory method? How can this be implemented using dll?

+3
source share
2 answers

The main idea with factory is that the function returns an object allocated from the heap, obtained from a known base class. Thus, in your situation, you should presumably have some code in your main application that calls the factory in the dll, returning an object of unknown dynamic type and implementation, but you will know that it satisfies the API requirements of a specific base class. Then you use the object through this interface and delete it through its supposedly virtual destructor. There are several types of factory methods depending on the choice of the actual derived class, but usually it considers some inputs to the function, input-output stream or XML structure, etc., and produces the corresponding type. Is factory in dll or not,actually has nothing to do with the general model here, but makes it easier to update the list and implement derived objects without recompiling the application.

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

+4

Factory - . , , . Factory, "" . , . Factory , .

Factory " , , . Factory " : " Factory ".

. Factory Component Object Model (COM)

+3

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


All Articles