Participants

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/fb313dda-6e2d-4595-938b-912780391904/Untitled.png

IService service = new Service();
IService serviceProxy = new ServiceProxy(service);
var result = serviceProxy.Execute();

public interface IService
{
    string Execute();
}

class Service : IService
{
    public string Execute() => "Remote Result";
}

class ServiceProxy : IService
{
    private string _resultCached;
    private IService _service;

    public ServiceProxy(IService service)
    {
        _service = service;
    }

    public string Execute()
    {
        if (string.IsNullOrEmpty(_resultCached))
            _resultCached = _service.Execute();
        return _resultCached;
    }
}

Rules of Thumb