We have a class "DataAccessServiceConnector", in which we have few methods to communicate with Data Access Service.
public class DataAccessServiceConnector: IDataAccessServiceConnector
{
public async Task<HttpResponseMessage> GetDataAccessServiceResponse()
{
//Some code
return GetDataFromDataAccessService();
}
}
We have an Interface:
public interface IDataAccessServiceConnector
{
Task<HttpResponseMessage> GetDataAccessServiceResponse();
}
And having a different class, that is holding the instance of "DataAccessServiceConnector" class in the as static object.
public class ClassA
{
public static IDataAccessConnector DataAccessConnector;
//Constructor of the Class
ClassA()
{
DataAccessConnector = DataAccessConnector ?? new DataAccessConnector();
}
}
Is it bad practice to hold the class instance (i.e. DataAccessServiceConnector) in a static object(i.e. DataAccessConnector)?
Aucun commentaire:
Enregistrer un commentaire