I'm having a hard time to grasp a solution for the following problem.
I am decoupling the classes with their correspondent interface but I need to extend the class for a new change instead of changing the original implementation in order to be compliant with open close principle.
This the base class HttpRequest implementing IHttpRequest
public class HttpRequest : IHttpRequest
{
public string RawUrl { get; protected set; }
public HttpRequest(string rawUrl)
{
RawUrl = rawUrl;
}
public string GetJsonFromUrl(string url)
{
//
}
}
public interface IHttpRequest
{
string GetJsonFromUrl(string url);
}
and the extended class is UrlMetadataResolver:
public class UrlMetadataResolver : HttpRequest
{
public UrlMetadataResolver(string rawUrl) : base(rawUrl)
{
//
}
}
What should I do? should I created an interface for UrlMetadataResolver (IUrlMetadataResolver)?
If that's the case it becomes even more confusing.
Thanks