直到现在,我们始终在每个Form
类似的东西:
public partial class FormTest: Form
{
private readonly ProductRepository prodRep = new ProductRepository();
private readonly UserRepository userRep = new UserRepository();
private readonly CarRepository carRep = new CarRepository();
private readonly RegistryRepository regRep = new RegistryRepository();
public FormTest()
{
InitializeComponent();
var product = prodRep.Get();
var listUsers = userRep.GetAll();
}
}
我们正在考虑创建一个包含所有存储库的新文件,并在程序启动时对其进行初始化。
这是合适的程序吗?
正面和负面方面?