I have 3 log classes that all implement the iLog interface:
DatabaseLog FileLog ScreenLog
there can be only one instance of them. at first I used one template for each class, but then I thought, why not use a factory to create an instance instead, so I don’t have to create a single template for each of them and for all future journal classes.
and maybe someone will want them as several objects in the future.
so my questions are: should i use factory or singleton pattern here?
Logger? , ? - , ?
, , , , Factory . faatory , .
factory . singleton-pattern , . factory -pattern . factory , , , . , .
singleton-pattern , . factory, , .
(, ), factory , (, ). , , .
, - , .
factory, () ILOG
Like others, I also suggest using factory. One advantage when not using Singletons is that you do not have a global state, which makes your code much more verified.
I would use a factory here, singleton cannot satisfy your single instance requirements between all three classes.
Source: https://habr.com/ru/post/1743790/More articles:How to get the original value of a DataColumn from a DataRow? - c #ASP.NET MVC Html Additional Extensions and Rendering of Required "Include" s - jqueryHtmlHelper extension dynamics - c #Rtti для записей Variant - serializationHow to send chat invitation to user using XMPP java protocol? - javaselect failing with program C but not shell - chow to decode a string in a variable in javascript? - javascriptВывод json с хорошо сформированными акцентами - jsonBy defining a class as internal, you define what will usually be public fields as internal? - c #What is wrong with this statement in Perl? - unixAll Articles