Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As rightly pointed out by Bertie, I might have not followed <em>any one</em> pattern here.</p> <p>I would say that by delegating the instantiation of concrete implementation to <code>CreateComparer</code> method, I have just simplified the object creation - which comes under <a href="http://en.wikipedia.org/wiki/Creational_pattern" rel="nofollow noreferrer">Creation Method patterns</a>. By having a static function for object instantiation, it was sort of a <em>factory pattern</em> - specifically <a href="http://en.wikipedia.org/wiki/Factory_method_pattern#C.23" rel="nofollow noreferrer">this variant of Factory Method</a>. </p> <p>By inheriting <code>Impl</code> from <code>Equater</code> I have sort of followed the <a href="http://c2.com/cgi/wiki?AbstractFactoryPattern" rel="nofollow noreferrer">Abstract Factory</a> pattern - where <code>Equater</code> is factory of factory and <code>Impl</code> is its implementation to give <code>Impl</code> itself back, except that <code>Impl</code> is really not creating any other object (in other words <code>Impl</code> is not meant to be a factory), but <em>getting instantiated itself</em> via constructor. So in strict sense, its not Abstract Factory pattern, but it will be closer to if <code>Impl</code> can have a method to call the constructor of itself and return back an instance.</p> <p>Also by embedding and hiding the implementation detail (the nested classes as such), the exposed class (parent class) fakes to outside world as if it is doing it's job. It's what is called <a href="https://en.wikipedia.org/wiki/Delegation_pattern" rel="nofollow noreferrer">Delegation Pattern</a></p> <p>As far as a name for <em>hiding implementation of a generic class in a nested generic class to give easier signature for method calls</em> is concerned I don't think there exist one. Even if any name existed, it has to be very specific to the language (or similar languages) since language constructs like generics/type inference etc are involved. Eric Lippert finds the same use in nested classes <a href="https://stackoverflow.com/a/3300140/661933">here</a> although its not generics related, where he calls it Factory pattern.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload