Re: API RFC
| From: | Greg Beaver | Date: | Thu, 03 Jun 2004 02:55:50 +0000 |
| Subject: | Re: API RFC | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-29936@lists.php.net to get a copy of this message | ||
Claudio Bustos wrote:
Pear-devs: Reading the post about Savant, I think that would be a good idea create an API reference for new files. In PHP 5, this will be implemented with interfaces. For example, many classes handles input from files and arrays and returns string or save files. With a very fast search on XML, I found: - get input from file: getTreeFromFile(XML_Tree),setInputFile(XML_Parser), XML_image2svg(XML_image2svg),runFromFile(xml_fo2pdf) - get input from string: getTreeFromFile(XML_Tree),setInputString(XML_Parser),runFromString(xml_fo2pdf) - return string:get(XML_Tree,XML_image2svg), transform (-with implicit parsing -XML_Transformer), toString(XML_NITF), returnPDF(xml_fo2pdf) - print to screen: dump (XML_Tree),show(XML_image2svg),printPDF(xml_fo2pdf) Many ways to do the same thing. Is a pain read a lot of documentation to: - create a instance of the object - set params - set the input file or string - start the process - save a file or get a string If you want it, I can search in the packages and get a list of commons names for method that do the same thing. Next, we could create a RFC for newcomers with a set of interfaces and the old ones could create wrappers for this standards methods. BTW, for the previous method we could use - create a instance: constructor, singleton() or factory() - very commons - set parameters: setParameter($param,$value) or similar - set input and output file: setInputFile - setOutputFile - set input string: setInputStringI prefer methods that read input to preface with "from" like "fromFile" or "fromString" or "fromXml" and methods that create output to preface with "to" like "toString", "toArray" and implied string methods "toXml" "toHtml" "toSql" etc.
- setParam - set - run process: run() - parse() - process() - save a File: save($sFile) - saveFile($sFile) - get a string: get() - very commonveto - "toString()" is better get() is too generic
- print on screen: show() - again, very common.I prefer again "printScreen" or "echoScreen" - it should describe exactly what it does. "printHtml" "printSwf" Greg