【发布时间】:2010-04-28 14:59:40
【问题描述】:
我有一个检索一些数据的类,图像对它们做了一些处理,然后它们使用 Web 服务将它们上传到第三方应用程序。 对象需要按顺序执行一些特定的步骤。 我的问题是我是否应该像这样公开公开每种方法。
myObject obj = new myObject();
obj.RetrieveImages();
obj.RetrieveAssociatedData();
obj.LogIntoThirdPartyWebService();
obj.UploadStuffToWebService();
或者所有这些方法都应该是私有的,并像这样封装在一个公共方法中。
public class myObject()
{
private void RetrieveImages(){};
private void RetrieveAssociatedData(){};
private void LogIntoThirdPartyWebService(){};
private void UploadStuffToWebService(){};
public void DoStuff()
{
this.RetrieveImages();
this.RetrieveAssociatedData();
this.LogIntoThirdPartyWebService();
this.UploadStuffToWebService();
}
}
就是这样称呼的。
myObject obj = new myObject();
obj.DoStuff();
【问题讨论】:
标签: c#