vendredi 1 mars 2019

Is there a standard name for an empty interface implementation used for a 'null behavior'?

Consider (in C# just as an example) an interface:

interface ILog
{
   void log(string text);
}

Which has the following implementations:

class GUILog : ILog
{
   public log(string text)
   {
      MessageBox.Show(text);
   }
}

class ConsoleLog : ILog
{
   public log(string text)
   {
      Console.WriteLine(text);
   }
}

class FakeLog : ILog
{
   public log(string text)
   {
      //Do nothing
   }
}

Is there a common naming convention for something like 'FakeLog'. Note that the logging context is just an example. The general idea is more that you have an implementation which does nothing...how should you name that? Of course you must assume the client doesn't rely on the implementation doing something to operate correctly. 'Mock' is perhaps close but is more from the testing side of things, and in this case no calls are logged. Maybe 'NOOP'?

Aucun commentaire:

Enregistrer un commentaire