私はパターンを設計するのが初めてです。現在のアプリケーションでファクトリ メソッド デザイン パターンを使用しようとしています。アプリケーションには 2 つのグループ (つまり、group1 と group2) があり、各グループには異なるメソッドがあります。アプリケーション ロールをクラスとして使用し、製品 (つまり、group2) から継承することをお勧めします。次のサンプル コードが正しいか間違っているかを誰か教えてください。
class Creator
{
static void Main(string[] args)
{
if (args[0] == "GroupHead")
{
IGroup2 gh = new GroupHead();
}
else if (args[0] == "ProjectIncharge")
{
IGroup2 gh = new ProjectIncharge();
}
}
}
interface IGroup1
{
List<Employee> GetEmployees();
}
interface IGroup2
{
List<Projects> GetProjects();
}
public class Group : IGroup1
{
public List<Employee> GetEmployees()
{
//Code here
}
}
public class GroupHead : IGroup2
{
public List<Projects> GetProjects()
{
//Code here
}
}
public class ProjectIncharge : IGroup2
{
public List<Projects> GetProjects()
{
//Code here
}
}
public class ProjectManager : IGroup2
{
public List<Projects> GetProjects()
{
//Code here
}
}