Is there a better way to handle data abstraction in this example?
- by sigil
I'm building an application that retrieves Sharepoint list data via a web service SPlists.Lists. To create an instance of the web service, I have the following class:
class SharepointServiceCreator
{
public SPlists.Lists createService()
{
listsService.Url = "http://wss/sites/SPLists/_vti_bin/lists.asmx";
listsService.Credentials = System.Net.CredentialCache.DefaultCredentials;
SPlists.Lists listsService=new SPlists.Lists();
}
}
I'm concerned that this isn't good OOP abstraction, though, because in order to create this service elsewhere in my application, I would need the following code:
class someClass
{
public void someMethod()
{
SharepointServiceCreator s=new SharepointServiceCreator()
SPlists.Lists listService=s.createService()
}
}
Having to use declare the instance of listService in someMethod as type SPlists.Lists seems wrong, because it means that someClass needs to know about how SharepointServiceCreator is implemented. Or is this ok?