|
-
Aug 24th, 2004, 12:42 PM
#1
Thread Starter
New Member
OOP Design Questions
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?
-
Aug 24th, 2004, 12:55 PM
#2
Fanatic Member
Is gateway1 and gateway2 essensially the same code?
If so use something like
Select Case paymentGateway
Case "gateway1"
paymenttype = this
Case "gateway2"
paymentType = that
'.. etc, etc etc..
End Select
objGateway = New Gateway(paymentType)
Then in your gateway you can initialize your class according to the type of payment or whatnot.
If wishes were fishes we'd all cast nets.
-
Aug 24th, 2004, 12:59 PM
#3
Thread Starter
New Member
Thanks for the reply, Graff..
gateway1 and gateway2 are not essentially the same code. Although they will share a lot of identical public methods, properties, etc. (which I why I was going to create an interface for them to implement), their functionality is different. For instance, take this as an example. Let's say gateway1 is for processing a payment via Bank of America's API, and gateway2 is for processing a payment via Authorize.NET's API. The public method signatures in both will be identical, but the code in the methods will be completely different.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|