I have a program which extract data from SQL which is used with Redmine. The program works for normal AR extractions, but now we want to make extraction to other types. So we would have AR extraction, ICN extraction…
How can I make this code more general? I thought about creating a new namespace called “TypeLinker” which would determine the type passed then would assign different template to them. Is this a good idea?
MAIN CODE
private static void Main(string[] args)
{
try
{
if (args[0] == "ALL" || args[0] == "*" || args[0] == "all")
{
PrintARs();
Console.Read();
}
else
{
CreateARDocument(args[0]);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.Read();
}
}
public static void PrintARs()
{
}
public static void CreateARDocument(string arg)
{
}
You need to read about the Factory pattern..
http://www.codeproject.com/Articles/9319/Creating-a-Class-Factory-with-C-and-NET
Can also be done with an abstract base class.
Best regards.