SitePoint Sponsor

User Tag List

Page 4 of 4 FirstFirst 1234
Results 76 to 95 of 95
  1. #76
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sk89q View Post
    In PHP, if you want to use namespaces, you have to explicitly define every class you want to use with a use statement if you want to use autoload, so you have to write even more with PHP.
    Note...the forum syntax coloring doesn't like "\" in namespaces...

    library.php
    PHP Code:
    <?php namespace Logical::Collection;

    class 
    Manager
    {
        public function 
    whoami ()
        {
            
    var_dump'NS: ' __NAMESPACE '; CN: ' __CLASS__ );
        }
    }

    class 
    Another
    {
        public function 
    whoami ()
        {
            
    var_dump'NS: ' __NAMESPACE '; CN: ' __CLASS__ );
        }
    }
    PHP Code:
    use Logical::Collection;

    $t = new Collection::Manager;
    $t->whoami();

    $t = new Collection::Another;
    $t->whoami(); 
    Or do you mean by importing you what this:
    PHP Code:
    use Logical::Collection;

    $t = new Manager;
    $t->whoami();

    $t = new Another;
     
    $t->whoami(); 
    Last edited by logic_earth; Nov 26, 2008 at 00:32.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  2. #77
    Spirit Coder allspiritseve's Avatar
    Join Date
    Dec 2002
    Location
    Ann Arbor, MI (USA)
    Posts
    648
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac View Post
    Actually, "SELECT id FROM daisy" makes much more sense linguistically than "SELECT id FROM daisies" -- especially if you remember that "FROM" is a shorter version of "FROM EACH", which is what it essentially stands for.
    The FROM clause contains table references... not row references. Consider "DELETE FROM daisies" or "INSERT INTO daisies"... they just don't work in singular. It's the same clause as a SELECT or an UPDATE. A table contains rows, so it should be plural, much in the same way you'd name an array of pages... $pages.

    I don't know where you got the FROM EACH.. but maybe it's "FROM EACH [row in the tables] table1, table2, etc."?

  3. #78
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #79
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    while i don't have preference either way, it seems quite a few people connect dots that shouldn't be connected when trying to prove one side better than the other. One guy on the microsoft forum had the argument that the table was directly related to the model and you wouldn't want the model to be plural, so the table should be singular as well. in reality the model doesn't have to be the EXACT SAME name as the table. actually i find it easy to have plural table names with singular model names. doesn't create any confusion at all to be honest.

    i guess i shouldn't be replying to posts not even on this forum, heh....but my point is it seems like it really don't matter either way, as there are convincing arguments for both sides. it's almost like choosing a political party, but not really.

    Is there any other language that uses underscores in class names? and aligns the class names to files.

    This type of coding from Zend framework is ridiculous:

    $var = new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter();
    i think zend just decided to use the default implementation of __autoload which translates underscores to directory separators. when php 5.3 comes out and is widespread, we'll have namespaces so ridiculous class names like this will be much more under control.

  5. #80
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by blueyon View Post
    Is there any other language that uses underscores in class names? and aligns the class names to files.

    This type of coding from Zend framework is ridiculous:

    $var = new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter();
    Honestly... What the hell are you talking about? Zend Framework's naming convention is structured and consistent as far as there class names are formed. There is nothing wrong with it. So it's a little long, big deal. All it is is a pseudo namespace that's all.

    Quote Originally Posted by blueyon View Post
    You can tell they are not coding properly because of such poor benchmarks and having to rely a lot more on caching.
    Poor benchmarks? From where are you getting this information? Please, enlighten us.

    Quote Originally Posted by blueyon View Post
    If you look at frameworks from Joomla or Code Igniter you can tell there is more intelligence behind the coding.
    Right... More intelligence... From you posts on this thread so far, I wouldn't consider you a valid judge when it comes to intelligence.

    The Zend Framework is very much a community driven project. It wasn't just built by Zend. Many members of the PHP community have contributed to it. It has it's weaknesses and it has it's strengths. If you can't accept that then don't use it.

    Quote Originally Posted by XtrEM3
    i think zend just decided to use the default implementation of __autoload which translates underscores to directory separators. when php 5.3 comes out and is widespread, we'll have namespaces so ridiculous class names like this will be much more under control.
    Even when namespaces are being used widely, you will still have a long list of namespaces. Instead of
    PHP Code:
    $var = new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter(); 
    We will have
    PHP Code:
    $var = new Zend::Search::Lucene::Index::SegmentWriter::DocumentWriter(); 
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  6. #81
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    Honestly... What the hell are you talking about? Zend Framework's naming convention is structured and consistent as far as there class names are formed. There is nothing wrong with it. So it's a little long, big deal. All it is is a pseudo namespace that's all.
    Quote Originally Posted by imaginethis View Post
    Poor benchmarks? From where are you getting this information? Please, enlighten us.
    http://www.avnetlabs.com/php/php-fra...son-benchmarks

    Also from personal experiance i find produces high execution times.

    Quote Originally Posted by imaginethis View Post
    The Zend Framework is very much a community driven project. It wasn't just built by Zend. Many members of the PHP community have contributed to it. It has it's weaknesses and it has it's strengths. If you can't accept that then don't use it.
    Possibly the reason its so bad. Too many cooks spoil the broth. You have to many programmers that only know about PHP and are making up their own coding standards. When I look at examples on php.nets web site they use a coding standard similar to sun's coding standrard for Java. Yet Zend framework has a completely differnt one.

    Look a this page and see how they write classes:
    http://wiki.php.net/rfc/closures

    Quote Originally Posted by imaginethis View Post
    Even when namespaces are being used widely, you will still have a long list of namespaces. Instead of
    PHP Code:
    $var = new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter(); 
    Yes, It still does not solve the problem. I think what happens is that the developers of PHP code these one features and people who write the user guides or zend framework implement the new features incorrectly. The name spaces are only supposed to let you use classes with the same names from differnt frameworks. It was never ment to be used to be able to lazy load.

    Checkout how Joomla implements autoload. Instead of having require_once at the top of all the pages it uses a custom function called import.

    Now if you use require all the time it might cause a lot of unneed files to be loaded. Its probably good programming practise to put the require function at the top of the pages so you are not searching for the loading of files in the code. If you move a file its easy to replace the paths at the top of the pages.

    So instead of using require Joomla uses a custom import function which wich registers a file and the class name with a static loader linked to autoload. So only if the class is initialized is the file loaded.

    Quote Originally Posted by imaginethis View Post
    Right... More intelligence... From you posts on this thread so far, I wouldn't consider you a valid judge when it comes to intelligence.
    Why be so rude unsless you are one of the developers of zend framework?

  7. #82
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Probably because you keep relating the coding choices of PHP programmers to the actual language.

    Sure, the zend framework isn't how you'd like it to be. Don't blame PHP for it though.

    Say, when walking down the street, you see a car racing down the road, then hitting a lamp-post. Do you blame the car manufacturer or the idiot driving it?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  8. #83
    SitePoint Addict
    Join Date
    Feb 2006
    Posts
    281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    Probably because you keep relating the coding choices of PHP programmers to the actual language.

    Sure, the zend framework isn't how you'd like it to be. Don't blame PHP for it though.

    Say, when walking down the street, you see a car racing down the road, then hitting a lamp-post. Do you blame the car manufacturer or the idiot driving it?

    Your right PHP is not the problem its Zend Framework. It just gets me annoyed that people are pushing this thing to be the defacto framework and standard yet its put together so badly using bad practises.

  9. #84
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It is, but it works.

    If you want fast, you don't want the bloat of a big framework behind your site. I'd say a good deal of regulars in this app design forum write their own frameworks, even writing a new one for different situations.

    I know I do.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  10. #85
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by blueyon View Post
    Why be so rude unsless you are one of the developers of zend framework?
    That wasn't rude. It was blunt honesty, a side-effect of not sleeping.

    Quote Originally Posted by blueyon View Post
    Your right PHP is not the problem its Zend Framework. It just gets me annoyed that people are pushing this thing to be the defacto framework and standard yet its put together so badly using bad practises.
    What is bad practice for you isn't for others. You don't have to use the framework if you don't want. It's a tool. If you try to use a screw driver to hammer a nail into a piece of wood, chances are you can get it done eventually but it will take far more energy than just using a hammer. In the same way, if the Zend Framework doesn't work for you, don't use it. If no framework works for you, build your own. Most of the problems you have pointed out with the Zend Framework thus far aren't really problems at all. You have your personal preferences and that's fine, but your preferences aren't the only preference.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  11. #86
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    Even when namespaces are being used widely, you will still have a long list of namespaces. Instead of
    PHP Code:
    $var = new Zend_Search_Lucene_Index_SegmentWriter_DocumentWriter(); 
    We will have
    PHP Code:
    $var = new Zend::Search::Lucene::Index::SegmentWriter::DocumentWriter(); 
    http://php.net/manual/en/language.namespaces.using.php

  12. #87
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mmm... Was my code syntactically incorrect? Cause I don't see the point you are trying to make.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  13. #88
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Basically you don't have to do stuff like that if you just import the namespace:
    PHP Code:
    use Zend::Search::Lucene::Index::SegmentWriter;
    $doc = new SegmentWriter::DocumentWriter(); 
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  14. #89
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    Basically you don't have to do stuff like that if you just import the namespace:
    PHP Code:
    use Zend::Search::Lucene::Index::SegmentWriter;
    $doc = new SegmentWriter::DocumentWriter(); 
    That seems pointless. They are semantically the same so I don't see the point.

    Generally, I would avoid using
    PHP Code:
    use Zend::Search::Lucene::Index::SegmentWriter;
    $doc = new SegmentWriter::DocumentWriter(); 
    and use
    PHP Code:
    $var = new Zend::Search::Lucene::Index::SegmentWriter::DocumentWriter(); 
    because you would reduce the chance of naming collisions. But that may just be a preference adopted from C++.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  15. #90
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Of course, if you use it one time then it's pointless.

    But consider this situation:
    PHP Code:
    <?php
    use MyNamespace::SubNameSpace::Text::RegularExpressions as Regex;
    $text 'The difference between 21 and 19';
    $pattern '/The difference between (\d+) and (\d+)/';
    $text Regex::Match($pattern$text) ? Regex::Replace(, '$2 - $1'$text) : 'Invalid';
    Or
    PHP Code:
    $text 'The difference between 21 and 19';
    $pattern '/The difference between (\d+) and (\d+)/';
    $text MyNamespace::SubNameSpace::Text::RegularExpressions::Match($pattern$text) ? MyNamespace::SubNameSpace::Text::RegularExpressions::Replace(, '$2 - $1'$text) : 'Invalid'
    I'd prefer the first - and that's just 2 uses, there could be many.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  16. #91
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would do the same, for the most part. However for example Zend_Config.

    PHP Code:
    use Zend;
    use 
    Zend::Db;
    $config = new Config();
    $table = new Table(); 
    For something like that, It is almost always better to just use

    PHP Code:
    $config = new Zend::Config();
    $table = new Zend::Db::Table(); 
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  17. #92
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most of the namespace examples so far seem pretty pointless.

    When you are working with libraries you can drop the (for example) Zend_ prefix everywhere. The even bigger benefit is being able to swap classes by only changing the namespace and none of the lower level code using the classes.
    Adrian Schneider - Web Developer

  18. #93
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SirAdrian View Post
    Most of the namespace examples so far seem pretty pointless.

    When you are working with libraries you can drop the (for example) Zend_ prefix everywhere. The even bigger benefit is being able to swap classes by only changing the namespace and none of the lower level code using the classes.
    Now, if only PHP allowed overloading of operators and pointers. . I'd be happy!
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  19. #94
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP has allowed the use of pointers for a very long time.

    PHP Code:
    $this->myVar
         
    |
         |
         --- 
    SEE?!  IT'S A POINTER! 
    Sorry. Couldn't resist. No more lame jokes. For today.

  20. #95
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its important to separate autoloading from the class file structure.
    If you don't want to use PEAR style class files you can always do something like symfony and have arbitrary file names, and cache a class map.

    The PEAR standards have laid out a clear structure for files and coding standards.
    Sure there may be some annoying stuff with working with insane class files but that does not mean the standard is bad, it just points to classes that could use a rename or being moved into different packages.

    The point is the php community would be far better off if we adopted the PEAR standards as a whole and had some more uniformity in file organization and code formatting.

    note: not enough points for link
    google "php development best practices pdf"
    good overview of php standards.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •