I am following this link:
http://codebetter.com/jpboodhoo/2007/10/15/the-static-gateway-pattern/
to understand the Gateway pattern.
The author shares a sample of the “gateway” logger class and related interfaces:
public class Log
{
private static ILogFactory logFactory;
public static void InitializeLogFactory(ILogFactory logFactory)
{
Log.logFactory = logFactory;
}
public void InformationalMessage(string informationalMessage)
{
logFactory.Create().InformationalMessage(informationalMessage);
}
}
public interface ILogFactory
{
ILog Create();
}
public interface ILog
{
void InformationalMessage(string message);
}
This is the calling API
public class Calculator
{
public int Add(int number1,int number2)
{
Log.InformationalMessage("About to add two numbers");
return number1 + number2;
}
}
I am unable to understand where the initialization of the concrete logging class happens here. What is the entry point of the gateway?
With regards to concrete implementation of the Interfaces, there are examples at the bottom of the article which show how it can be implemented.