Re: Code Critique Please :)
| From: | Jochem Maas | Date: | Wed, 21 Nov 2007 20:15:41 +0000 |
| Subject: | Re: Code Critique Please :) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264947@lists.php.net to get a copy of this message | ||
Simeon F. Willbanks wrote:
> Jochem,
>
> Thanks for the tips.
no worries, for the rest you stuff looks tidy and
making use of phpDoc comments and using CS consistently
are both recommended!
with regard to OO I didn't really see enough [complexity]
to be able to offer any worthwhile feedback - but then again
I didn't see any faux pas' either.
you might consider checking out other implementations of similar
functionality to compare your own idea/implementation against.
oh and we prefer to keep all communications on list :-)
> Simeon
>
> On Nov 21, 2007, at 2:23 PM, Jochem Maas wrote:
>
>> Simeon F. Willbanks wrote:
>>> Hello,
>>>
>>> I am trying to increase my knowledge and understanding of OO and OO
>>> Design Patterns. I'd like to request a critique of a program that
>>> extracts MySQL table information and translates it into XML. In the
>>> program, I tried to accomplish a few things:
>>>
>>> 1. Correct use of ADOdb
>>> 2. Closely match the PEAR coding standards
>>> - I encode my scripts in UTF-8
>>> - Not all indents are 4 spaces, but I have switched my IDE to treat
>>> tabs as four spaces
>>> - My phpDoc comments could probably use some tweaking
>>> 3. Object Oriented principles
>>> 4. Strategy Design Pattern
>>> - Interface used for column attribute parsing
>>>
>>> My overall goal is to use these xml files as a starting point to write a
>>> DAO with the Data Mapper Pattern.
>>>
>>> Here are the related files to peruse:
>>>
>>> http://simeons.net/code/datamapper/sql/photo_portfolio.sql
>>> - SQL dump
>>> http://simeons.net/code/datamapper/mysql_to_xml_oo.phps
>>> - Calling script
>>>
>>> http://simeons.net/code/datamapper/helpers/autoload.phps
>>> - Auto load classes
>>
>> does the preg_replace() need to be run for every call to __autoload(),
>> I think it would speed it up a little if you stored the class path in
>> a static
>> variable so that you only have to determine it once.
>>
>>> http://simeons.net/code/datamapper/classes/DB.phps
>>> - ADOdb connection
>>>
>>> http://simeons.net/code/datamapper/classes/MySQLToXML.phps
>>> - MySQL extraction and parsing
>>> - XML writing
>>>
>>
>> I'd drop the trailing '?>' in all your files - it's not required and
>> it will
>> save you hunting through stacks of files trying to find errant blank
>> lines
>> (which are output to the browser and will break subsequent calls to
>> header())
>>
>>> Here are the outputted xml files:
>>>
>>> http://simeons.net/code/datamapper/xmldatamaps/album.xml
>>>
>>> http://simeons.net/code/datamapper/xmldatamaps/photo.xml
>>>
>>> http://simeons.net/code/datamapper/xmldatamaps/comment.xml
>>>
>>> Any comments are appreciated.
>>>
>>> Thanks,
>>> Simeon
>>>
>>
>