samedi 1 août 2015

Reflection in factory design patterns in Java or C#

I came across a term called reflection. It is a feature commonly used in factory design patterns. I had a hard time understanding the concept because I’m still learning how to program. How can reflection be used in factory design patterns in C# or Java? Can anyone give me a simple example, and show me your code that uses reflection to implement factory design patterns?

Microsoft provides this code example of reflection, but i don't see how this can be used in factory design patterns.

 // Using GetType to obtain type information: 
  int i = 42;
  System.Type type = i.GetType();
  System.Console.WriteLine(type);

  The Output is: System.Int32





Aucun commentaire:

Enregistrer un commentaire