samshel Posted March 23, 2009 Share Posted March 23, 2009 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.. Quote Link to comment https://forums.phpfreaks.com/topic/150793-solved-nested-classes-hierarchy-best-approach-suggestion-needed/ Share on other sites More sharing options...
samshel Posted March 24, 2009 Author Share Posted March 24, 2009 dont worry ! i got it I am using combination of multi level includes [for inner levels] and factory [for outer level]. Its scalable and fast Quote Link to comment https://forums.phpfreaks.com/topic/150793-solved-nested-classes-hierarchy-best-approach-suggestion-needed/#findComment-792225 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.