design-patterns

Design pattern used in projects [closed]

与世无争的帅哥 提交于 2020-01-31 04:59:11
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Hi I am learning Design patterns these days. I want to read design pattern used in various projects and how it is implemented. Implementation is helpful to connect the design pattern in broader picture and why they deiced to use that pattern. Problem with open source projects are they are not documented properly

Design pattern used in projects [closed]

China☆狼群 提交于 2020-01-31 04:58:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . Hi I am learning Design patterns these days. I want to read design pattern used in various projects and how it is implemented. Implementation is helpful to connect the design pattern in broader picture and why they deiced to use that pattern. Problem with open source projects are they are not documented properly

Am I using IRepository correctly?

删除回忆录丶 提交于 2020-01-30 18:55:10
问题 I'm looking to use the IRepository pattern (backed by NHibernate, if it matters) in a small project. The domain is a simple one, intentionally so to allow me to focus on understanding the IRepository pattern. The lone domain class is Movie , with properties for Year , Genre , and Title . My intent would be to "get" movies whose properties match criteria of the aforementioned types. Convention seems to be to have a generic IRepository interface, similar to the following: public interface

Am I using IRepository correctly?

喜夏-厌秋 提交于 2020-01-30 18:54:05
问题 I'm looking to use the IRepository pattern (backed by NHibernate, if it matters) in a small project. The domain is a simple one, intentionally so to allow me to focus on understanding the IRepository pattern. The lone domain class is Movie , with properties for Year , Genre , and Title . My intent would be to "get" movies whose properties match criteria of the aforementioned types. Convention seems to be to have a generic IRepository interface, similar to the following: public interface

Insert instance of ofstream to container

孤街醉人 提交于 2020-01-30 12:15:45
问题 I created my a class file which is a wrapper for std::ofstream . I created a Container to contain all the instances of file . class file { private: std::ofstream ofs; public: void open(std::string filename); void write(std::string s); void close(); }; class Container { private: std::map<int, file> m; public: void insert(file f,int i) { m.insert(std::pair<int,file> (i,f)); } void get(int i) { m.at(i); } }; However, there is an issue in this code. In the insert method I am attempting to copy a

Insert instance of ofstream to container

假如想象 提交于 2020-01-30 12:15:28
问题 I created my a class file which is a wrapper for std::ofstream . I created a Container to contain all the instances of file . class file { private: std::ofstream ofs; public: void open(std::string filename); void write(std::string s); void close(); }; class Container { private: std::map<int, file> m; public: void insert(file f,int i) { m.insert(std::pair<int,file> (i,f)); } void get(int i) { m.at(i); } }; However, there is an issue in this code. In the insert method I am attempting to copy a

Add index to filename for existing file (file.txt => file_1.txt)

*爱你&永不变心* 提交于 2020-01-30 07:42:50
问题 I want to add an index to a filename if the file already exists, so that I don't overwrite it. Like if I have a file myfile.txt and same time myfile.txt exists in destination folder - I need to copy my file with name myfile_1.txt And same time if I have a file myfile.txt , but destintation folder contains myfile.txt and myfile_1.txt - generated filename has to be myfile_2.txt So the functionality is very similar to the creation of folders in Microsoft operating systems. What's the best

Add index to filename for existing file (file.txt => file_1.txt)

不想你离开。 提交于 2020-01-30 07:41:50
问题 I want to add an index to a filename if the file already exists, so that I don't overwrite it. Like if I have a file myfile.txt and same time myfile.txt exists in destination folder - I need to copy my file with name myfile_1.txt And same time if I have a file myfile.txt , but destintation folder contains myfile.txt and myfile_1.txt - generated filename has to be myfile_2.txt So the functionality is very similar to the creation of folders in Microsoft operating systems. What's the best

singleton in objective c

不羁的心 提交于 2020-01-30 06:45:30
问题 I saw a singleton example on objective-c book. However, I don't know if there is difference of meaning of 'singleton' definition between objective-c and other langs. Can this [[SingletonClass alloc] init] still be used to create a new object? If yes, how to guarantee there is only one object in the memory? #import "SingletonClass.h" @implementation SingletonClass static SingletonClass *sharedInstance = nil; // Get the shared instance and create it if necessary. + (SingletonClass*

Design pattern for loading multiple message types

帅比萌擦擦* 提交于 2020-01-29 09:38:26
问题 As I was looking through SO I came across a question about handling multiple message types. My concern is - how do I load such a message in a neat way? I decided to have a separate class with a method which loads one message each time it's invoked. This method should create a new instance of a concrete message type (say AlphaMessage, BetaMessage, GammaMessage, etc.) and return it as a Message. class MessageLoader { public Message Load() { // ... } } The code inside the method is something