I feel that I should start using the factory method design pattern on some of my code. Here is what I am doing;
The below code is my generator class for Accom namespace:
namespace Accom { public class Generator { int? _id; string _name; public Generator(int? id = null, string name = null) { _id = id; _name = name; } public string GetBaseUrl() { //some logic sits here. return somestring; } //Can have some other methods as well } }
I will have the same start-up for Traf namespace as well:
namespace Traf { public class Generator { int? _id; string _name; public Generator(int? id = null, string name = null) { _id = id; _name = name; } public string GetBaseUrl() { //some logic sits here. Same one with the Accom. return somestring; } //Can have some other methods as well } }
So, this will repeat again and again.
I tried to create some factory pattern for that but all of the abstract classes were mixed and I confused a lot (I think it is because this is first time I am trying to do something like that).
Can anyone help me on this and point me to good source code that I can read and get a sense from?