我在我的项目中有类似这样的东西,这个项目已经基本完成了(它能够正常工作)。我只是想知道是否符合SOLID原则。
static public class Tools
{
static public GetProduct(this id){...}
static public GetProductCategory(this id){...}
static public GetUser(this id){...}
// I also have here methods like IsStringNull ...
// IsNull IsFalse, lots of stuff, everything static
}
使用方法如下:
var UserThatCreatedCategoryForThisProduct =
prodId.GetProduct().CategoryId.GetProductCategory().Creator.GetUser();
我知道这显然违反了SRP原则,但是这个类是静态的,它包含了相互独立的静态方法。如果我为每个方法创建一个静态类,那么本质上就是一样的。