我正在尝试将大对象分解为较小的接口。示例:
public class SomeService
{
readonly GodObject _god; // <-- Replace this with an Interface
public SomeService(GodObject god)
{
_god = god;
}
public string SomeProperty => _god.GetSomeValue();
public string SomethingElse => _god.SomethingDifferent;
}
public class GodObject
{
public string GetSomeValue()
{
// do something and return
}
public string SomethingDifferent { get; set; }
// Lots and lots more Members
}
重构后,它应该看起来像这样:
public interface IPartialGodObject // <-- Extracted from GodObject
{
string GetSomeValue();
string SomethingDifferent { get; }
}
public class SomeService
{
readonly IPartialGodObject _god; // <-- Now only references the Interface
public SomeService(IPartialGodObject god)
{
_god = god;
}
public string SomeProperty => _god.GetSomeValue();
public string SomethingElse => _god.SomethingDifferent;
}
public class GodObject : IPartialGodObject
{
//...
}
Visual Studio或Resharper是否可以自动执行此类操作?我确实了解Extract Interface
,但是对于一个大对象,仅检查一个大列表中的几个属性/方法是很痛苦的。
更新:为了澄清,我只希望提取SomeService
类使用的成员。
答案 0 :(得分:0)
似乎没有自动执行的操作。我最终要做的是以下内容( Resharper 2018 ):
select count(columnname) from TABLEB failing :
Error: java.io.IOException: java.io.IOException: java.lang.RuntimeException: java.lang.ClassCastException:org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector cannot be cast to org.apache.hadoop.hive.ql.exec.vector.LongColumnVector
Extract Interface