Can you tell me if it is Factory, Strategy or MVC design pattern?
public interface MainObject<T>
{
void add();
T get();
}
class Person1 : MainObject<Person1>
{
public Person1(int id, string name)
{
// define
}
public void add()
{
// add
}
public Person1 get()
{
// return
}
}
class Person2 : MainObject<Person2>
{
public Person2(int id, string name, bool status)
{
// define
}
public void add()
{
// add
}
public Person2 get()
{
// return
}
}
class Client
{
public User()
{
}
public void add<T>(T obj) where T : Object<T>
{
obj.add();
}
public T get<T>(T obj) where T : Object<T>
{
return obj.get();
}
}
static class Program
{
static void Main()
{
Client client = new Client();
client.add( new Person1(123,"Duke") );
client.add( new Person2(456,"Dave",true) );
Person1 foundPerson1 = client.get( new Person1(123,null) ); // (123,"Duke")
Person2 finedPerson2 = client.get( new Person1(null,"Dave",null) ); // (456,"Dave",true)
}
}
I wrote my code with factory and strategy patterns, but i saw here the realization of MVC MVC pattern differences, and it is as my code. Now i confused what pattern is my code.