Can factory methods return multiple instances?

This is a factory method if it returns an instance of a class, but is it a factory method if it returns multiple (array) instances?

+3
source share
3 answers

If you need to return multiple instances, do it no matter how it is called. I would say that this is really a factory method, but it does not really matter.

Perhaps you may have a factory method to return one instance, and then another, which calls the first time several times.

+4
source

T - , , Factory T [], , Factory, T:-) ( T [] T )

+3

, :

int pipe(int fildes[2]);

pipe() , fildes [0] fildes [1], .

factory, "" ( out ) , .

"factory method" , . , , , - , - .

+1

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


All Articles