A和B之间有什么区别吗?
A类有私有构造函数:
class A
{
private A()
{ }
}
Run Code Online (Sandbox Code Playgroud)
B类是密封的,有一个私有构造函数:
sealed class B
{
private B()
{ }
}
Run Code Online (Sandbox Code Playgroud) 我刚开始用DDD设计(我既没有老师也没有经验)
我有一些域服务类,必须在某些时候互相引用.所以我决定通过构造函数注入引用.
当我创建一个有很多数据要显示在控制器中的视图时,我必须创建一堆服务(其中一些引用彼此)
此时我的控制器的第一行看起来像这样:
EmployeeRepository employRepository = new EmployeeRepository();
ShiftModelRepository shiftModelRepository = new ShiftModelRepository();
ShiftModelService shiftModelService = new ShiftModelService(shiftModelRepository);
EmployeeService employeeService = new EmployeeService(employRepository, shiftModelService);
OvertimeRepository overtimeRepository = new OvertimeRepository();
OvertimeService overtimeService = new OvertimeService(overtimeRepository, employeeService);
Run Code Online (Sandbox Code Playgroud)
但我开始为服务创建接口并使用IoC控制器(名为StructureMap)
现在,同一控制器的第一行看起来像这样:
IShiftModelService shiftModelService = ObjectFactory.GetInstance<IShiftModelService>();
IOvertimeService overtimeService = ObjectFactory.GetInstance<IOvertimeService>();
IEmployeeService employeeService = ObjectFactory.GetInstance<IEmployeeService>();
Run Code Online (Sandbox Code Playgroud)
我认为使用它会好得多,但我知道它是否是DDD中的一个好习惯.
c# asp.net-mvc domain-driven-design dependency-injection inversion-of-control
我已经开始在Access中学习VBA.我读过该语言没有继承.然后我读了一个示例代码,看起来它实际上有继承:
Dim ctrl As Control
...
If TypeOf ctrl Is TextBox Then ...
If TypeOf ctrl Is ListBox Then ...
Run Code Online (Sandbox Code Playgroud)
在我看来,TextBox,ListBox都是从Control继承而来的.有人可以解释一下吗?
我有一个简单的课程:
public class RawBomItem
{
private string material;
private string item;
private string component;
private string quantity;
private string b;
private string spt;
...
}
Run Code Online (Sandbox Code Playgroud)
每个数据库都有一个属性.
然后我有一个List包含这个类的实例
private List<RawBomItem> rawBom;
Run Code Online (Sandbox Code Playgroud)
该列表包含超过70000个项目.
此时我想在此List上运行一个复杂的LINQ查询.
List<string> endProducts = new List<string>(
rawBom.Where(x1 => new List<string>(rawBom.Select(x2 => x2.Component)
.Distinct())
.Contains(x1.Material) && (x1.B != "F"))
.Select(x3 => x3.Material));
Run Code Online (Sandbox Code Playgroud)
查询似乎遇到了无限循环.(我等了好几分钟然后把它关了)
我会把它变成DB工作,我只是对可能出现的问题感兴趣.