Jump to content

[SOLVED] Nested Classes hierarchy - Best approach suggestion needed


Recommended Posts

Hi All,

 

Ok so here is what i am trying to do and i strongly need advice about what is the best way to do it.

 

Requirement:

 

Build an external interface module which will interact with any third party system and if a new system comes up tomorrow i can just add a file with business logic and i dont have to worry about common things which i have already done for other similar systems. So when i need to add a new payment gateway which is a webservice all i need to do is write the business logic.

 

For this i have divided any system into categories and sub-categories nested upto nth level, Simple Example:

 

verisign

- Category : Webservice

- Sub Category: Payment Gateway

So Verisign is first a webservice and then a payment gateway.

 

I have already implemented Paypal webservice and i dont want to write the common code again for Verisign.

 

I know the first thought that comes to mind is factory method...but still read on :)

 

I have the following structure

 

interface

  -- interface.php [Factory Controller for outmost level]

  -- interfacecommon.php [Common functions for outmost level]

 

    webservice

      -- webservice.php [Factory Controller for webservice level]

      -- webservicecommon.php [Common functions for webservice level]

 

      payment

        -- payment.php [Factory Controller for payment level]

        -- paymentcommon.php [Common functions for payment level]

 

        paypal

        -- paypal.php [Actual business logic for Paypal]

        verisign

        -- verisign.php [Actual business logic for Verisign]

 

Solutions that i can think of:

 

1) Create object of outermost level (interface.php). Call a function, which will create an object of inner level controller(webservice.php) and assign it to its own member variable. The inner level controller again creates an object of the one more level inner level controller (payment.php), which inturn creates object of lowest level class (verisign.php). All these controllers will inherit a class each present on thier level which will have the common functionality for that level. By this I get one object with many member variables nested.

 

2) I dont use Factory so i dont need a controller. I start from inner most level (paypal.php) , which inherits upper level common class(payment.php), which inherits 1 more level upper common class (webservice), which inherits one more level upper common class (interface.php) and i use object of this.

 

3) anything u can suggest..i am all ears.

 

man this is complicated !! I really hope i am able to explain properly what i need.

 

anyways i need the system to be extremely scalable but extremely fast too, so i dont want unnecessary includes and object creations.

 

Thanks for the patience !! :)

 

your suggestions are highly appreciated..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.