Interface-based programming, am I doing it right?

OK, so I decided to start using interfaces in my code base, and it works well for certain tasks. For example, I have a URL builder class that implements IUrlBuilder, and now the implementation does not matter. Brilliant, but take this interface, for example.

namespace SproutMessagingFramework.Webtext.Interfaces
{
using System.Net;

public interface ICookieJar
{
    CookieCollection Collection { get; set; }
    CookieContainer Container { get; set; }

    void AddResponse(HttpWebResponse Response);
    void AddResponse(HttpWebResponse Response, string Path, string Domain);
}
}

This interface is quite specific in my opinion, these two methods will not do anything other than what a particular class will do. So why did I make it an interface? Well, I think that if I need to change the implementation of AddResponse?

Is this correct or am I just inflating the codebase?

+3
source share
2 answers

1:1 . ( ) , cookie , cookie .

. IDisposable. IDisposable, , , .., , .

, ICollection IEnumerable.

, , .

+8

AddResponse, ICookieJar, - , - .

, , , , cookie, .

+2

Source: https://habr.com/ru/post/1777452/


All Articles