This next project I will be doing will be my first fully-OOP designed solution. The project is a windows application to charges users using several different payment gateways. Here are my plans:
- Create an IGateway interface that all Gateway classes will implement. The software package will need to use several different gateways to process charges.
- Create a seperate class for each Gateway that implements the IGateway interface
- Create a function (placement of which has not been determined yet) that will determine what gateway to use to charge a user, and instantiate an instance of the proper gateway class
The first question I have is how would it be best to instantiate the proper charge gateway object based on what gateway has to be used? For example, would the following suffice? For some reason, I have a bad feeling about the code below and feel there is a better alternative:
Code:
Select Case paymentGateway
Case "gateway1"
objGateway = New Gateway1()
Case "gateway2"
objGateway = New Gateway2()
'.. etc, etc etc..
End Select
Can anyone suggest any other altneratives, or would this be the proper way to handle such a task?