摘要对象重构 [英] Summary object refactoring

查看:71
本文介绍了摘要对象重构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个摘要对象,他们的责任实际上是将很多东西组合在一起并创建一个摘要报告。

在这个对象中我有很多这样的结构:



  public   class  SummaryVisit :访问,IMappable 
{
public int SummaryId {获得; set ; }

public int PatientId {获得; set ; }

public int LocationId {获得; set ; }

public IMappable Patient
{
get
{
return new SummaryPatient(PatientBusinessService.FindPatient( .PatientId));
}
}

public IMappable Location
{
get
{
return new SummaryLocation( LocationBusinessService.FindLocation( this .LocationId));
}
}

public IEnumerable< IMappable>评论
{
get
{
return < span class =code-keyword> new
SummaryComments(CommentBusinessService.FindComments( this .SummaryId));
}
}

// ...可以是很多这些结构
// ...使用不同的业务服务和摘要对象

public IEnumerable< IMappable>任务
{
获取
{
返回 < span class =code-keyword> new
SummaryTasks(TaskBusinessService.FindTasks( this ));
}
}
}





PatientBusinessService,LocationBusinessService等是静态的。

这些SummaryPatient,SummaryLocation等中的每一个都有相同类型的结构。



重构和测试它的最佳方法是什么? />
尝试通过接口代理调用替换静态调用,但是这个类只有很多这些接口作为构造函数注入东西并开始超级贪婪。

解决方案

I have a summary objects, who's responsibilities actually to combine a lot of things together and create a summary report.
In this objects I have a lot of structures like this:

public class SummaryVisit : Visit, IMappable
{
    public int SummaryId { get; set; }

    public int PatientId { get; set; }

    public int LocationId { get; set; }

    public IMappable Patient
    {
        get
        {
            return new SummaryPatient(PatientBusinessService.FindPatient(this.PatientId));
        }
    }

    public IMappable Location
    {
        get
        {
            return new SummaryLocation(LocationBusinessService.FindLocation(this.LocationId));
        }
    }

    public IEnumerable<IMappable> Comments
    {
        get
        {
            return new SummaryComments(CommentBusinessService.FindComments(this.SummaryId));
        }
    }

    // ... can be a lot of these structures
    // ... using different business services and summary objects

    public IEnumerable<IMappable> Tasks
    {
        get
        {
            return new SummaryTasks(TaskBusinessService.FindTasks(this));
        }
    }
}



PatientBusinessService, LocationBusinessService etc. are statics.
And each of these SummaryPatient, SummaryLocation etc. have the same type of structure inside.

What is the best approach to refactor and test this?
Tried to replace static calls with calls via the interfaced proxies, but this class just got a lot of these interfaces as the constructor injection stuff and start to be super greedy.

解决方案

这篇关于摘要对象重构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆