Is there a better way to handle data abstraction in this example?
Posted
by
sigil
on Programmers
See other posts from Programmers
or by sigil
Published on 2012-09-21T16:31:06Z
Indexed on
2012/09/21
21:55 UTC
Read the original article
Hit count: 180
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?
© Programmers or respective owner