Implement Concrete Factory Design Pattern using Reflection in VB.NET

In order for a Class A to create an instance of Class B, A must have a reference to B, which means that class B must be instantiated and a reference to object B must be available to A. A has a direct reference to B and they are tightly coupled.

In order to reduce tight coupling between these two objects, it is best to give the responsibility of creating B to a factory class using Reflection. It then becomes less coupled.

Reflection is used to dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object. In this example, we implement Concrete Factory Pattern using Reflection to fetch records from MS-Access and MS-SQL Database. It is possible to configure this application to retrieve data from Oracle DB also.

Up Next
    Ebook Download
    View all
    Learn
    View all