Should methods that are required to be executed in a specific order be private?

Posted by TooFat on Stack Overflow See other posts from Stack Overflow or by TooFat
Published on 2010-04-28T14:59:40Z Indexed on 2010/04/28 15:03 UTC
Read the original article Hit count: 254

Filed under:
|

I have a Class that retrieves some data and images does some stuff to them and them uploads them to a third party app using web services. The object needs to perform some specific steps in order. My question is should I be explicitly exposing each method publicly like so.

myObject obj = new myObject();
obj.RetrieveImages();
obj.RetrieveAssociatedData();
obj.LogIntoThirdPartyWebService();
obj.UploadStuffToWebService();

or should all of these methods be private and encapsulated in a single public method like so.

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();
  }
}

which is called like so.

myObject obj = new myObject();
obj.DoStuff();

© Stack Overflow or respective owner

Related posts about c#

Related posts about software-engineering