Re: Structured data

From: Date: Wed, 01 Aug 2007 20:03:16 +0000
Subject: Re: Structured data
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-47739@lists.php.net to get a copy of this message
On 8/1/07, Philippe Jausions <Philippe.Jausions@11abacus.com> wrote: > Hi all, > > How much sense would it make to have in PEAR some base classes for data > structures? Think along the line of Structure_Location, or > Structure_Phone. This would allow to not reinvent the wheel for packages > that use similar complex data types. Vcard and address book packages of > course, but also for web services such as mailing (UPS, FedEx, Postal > Services) or location services (a la Google Maps and so on...) > > Even though it would just be a glorified array and would increase > package dependencies, it would also allow for better API for packages > making use of such Structure_* classes (typing comes to mind) and > increase package interoperability. > > Is it too framework-specific? Should it just be an Interface instead of > a class? Any thoughts? > > -Philippe > > -- > PEAR Development Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > What I usually do is the interface For instance Fedex, ups, etc .. I need the same data from each of those providers thus: interface Prefix_DeliveryServiceInterface { public function getLocation(); public function getArea(); public function getConfirmationCode(); /** ... */ } But for things like vcard and other messaging I go with another interface like: interface Prefix_MessagingServiceInterface { public function getFirstName(); public function getLastName(); public function getPhones(); /** ... */ } But perhaps a way to make those somewhat standards could be a good thing..I could easily see something like: <STANDARD_GOD_ROOT> <package type="messaging"> <method name="getFirstName" return="string" /> <method name="getLastName" return="string" /> <method name="getPhones" return="array" /> </package> <package type="delivery"> <method name="getLocation" return="string" /> <method name="getArea" return="string" /> <method name="getConfirmationCode" return="string" /> </package> </STANDARD_GOD_ROOT> And upon calling a type of package, it would autobuild the interfaces for the needed package.. Something like: <class name="ImplementerOfDelievery"> <implements="delivery" /> <construct> <param type="string" name="company" value="{passSomething...its php afterall}" /> </construct> </class> and then: $implementerOfDeliveryClass = Structured_Standard::buildClass('ImplementerOfDelivery'); and this could build standards classes, etc.. but a bit too complex for the gain imo... The interface per type of Structure should be good enough imho. -- David Coallier, Founder & Software Architect, Agora Production (http://agoraproduction.com) 51.42.06.70.18

« previous php.pear.dev (#47739) next »