SitePoint Sponsor

User Tag List

Page 2 of 4 FirstFirst 1234 LastLast
Results 26 to 50 of 95
  1. #26
    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)
    Coding styles are upto the author of the code. IIRC there is no standard - and you can see that if you look at the existing PHP library.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  2. #27
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    arkinstall, i'm sure this has already been said somewhere or another, but i'm very impressed at your knowledge of PHP and OOP at only 16. if you make a career out of it, you're definitely going places.

  3. #28
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm waiting for namespaces to use PHP's autoload. Otherwise, I'm committing myself to some very hideous conventions.

    In the meantime (as of recently), I have been writing my classes in preparation of namespaces. I can grep for "require_once '...'" and "// PHPNS: namespace" and replace them with actual namespaces and use statements when PHP 5.3 comes about. Then, I can implement an autoload function cleanly with minimum work on my part later.

    Slowly, PHP's becoming ever so less annoying. Hopefully, we'll be away from the current point where PHP is a b*****d child of Python's forgiving nature and Java's strictness.

  4. #29
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    Quote Originally Posted by blueyon View Post
    One thing that annoyes me about zend is that they created their own coding standard rather tham use a current one like GNU.
    Zend's coding standard is a variation on PEAR's coding standard. But why should Zend use GNU why not something else like my own coding standard?
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #30
    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
    One thing that annoyes me about zend is that they created their own coding standard rather tham use a current one like GNU.
    GNU Coding standards? Is anything Zend GNU? PHP isn't GNU. Zend Framework isn't GNU. So why would the adopt GNU coding standards? O.o

    Q. Why is PHP 4 not dual-licensed under the GNU General Public License (GPL) like PHP 3 was?

    A. GPL enforces many restrictions on what can and cannot be done with the licensed code. The PHP developers decided to release PHP under a much more loose license (Apache-style), to help PHP become as popular as possible.
    Stolen from PHP.net

    Lots of people create there own coding standards... Hell I even have my own coding standard which I adhere to from time to time Why? Because it makes me more efficient. If you ever work for an established software company, they will have there own coding standards that you will have to adopt with out hesitancy.
    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. #31
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Autoloading classes is a huge time saver with larger projects, at least for me.

    If you don't like the idea of automatic "rules", then define an array (probably want that moved to config) matching up classes with file paths for your autoload function.
    Adrian Schneider - Web Developer

  7. #32
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    I disagree, but I'm intrigued - why do you prefer to keep multiple classes in one file?
    One-class-per-file feels too "bitty". It would be like keeping separate pairs of socks each in their own dedicated sock drawer.

  8. #33
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    I disagree, but I'm intrigued - why do you prefer to keep multiple classes in one file?
    It's a lot easier to rename classes, if they don't depend on the file name.

  9. #34
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's just as easy to rename the file. Besides, how often do you write a class without having already settled on a name for it?

  10. #35
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff View Post
    It would be like keeping separate pairs of socks each in their own dedicated sock drawer.
    I was gonna stay out of this discussion...but I had to say that I don't think this is a similar scenario at all. not that i can think of a better analogy, but this isn't a good one.

    one class per file, unless the class is a helper file, or you're intentionally compacting your files for performance reasons.

  11. #36
    simple tester McGruff's Avatar
    Join Date
    Sep 2003
    Location
    Glasgow
    Posts
    1,690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by World Wide Weird View Post
    It's just as easy to rename the file. Besides, how often do you write a class without having already settled on a name for it?
    Very often. It's a bit like writing poetry. Every word is important and it can be hard to find just the right one which expresses everything which you want to say.

  12. #37
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    refactoring is a part of developing, it shouldn't affect your conventions tho.

  13. #38
    SitePoint Addict
    Join Date
    Feb 2007
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'd have to agree with McGruff. I've changed names a lot in my most recent project. All of the classes sit in the same file and it would've been a serious drag if I had to keep up with changing filenames. However, I might consider breaking them out into individual files now that the design has solidified a bit and the usage scenarios are clearer. I actually won't though, because the code is used on almost every page, so I just include the file once in a common file. I'm using __autoload to load model classes though.

  14. #39
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff View Post
    Very often. It's a bit like writing poetry. Every word is important and it can be hard to find just the right one which expresses everything which you want to say.
    Mmm... I would say its more like writing an essay

    Realistically, it doesn't matter what convention you use, so long as it gets the job done and you document it. If you don't have it documented, then you FAIL and should be LOL'ed to death for all eternity... I haven't slept yet... and its 9 am... sorry
    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. #40
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff View Post
    Very often. It's a bit like writing poetry. Every word is important and it can be hard to find just the right one which expresses everything which you want to say.
    Interesting. When I wrote a lot of poetry, I would struggle for days with choosing a single word, feverishly thumbing through thesauri and Word Finder to find the most concise way to express a thought. I've seldom had that problem with class names though. The names usually just come to me as I'm writing the code, if indeed I don't already have a name chosen beforehand. That said, I did recently rename my JavaScript "Viewer" to "Presenter".

  16. #41
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I personally love the idea of the waterfall development paradigm. But I never have the patience to sit down and plan everything, naming all my classes, functions and so on. Its just so easy to figure it all out as I go. ._.
    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. #42
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's a lot easier when you're using existing design patterns that already have the naming spoon-fed to you. takes the thinking out of the whole deal.

  18. #43
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by XtrEM3 View Post
    it's a lot easier when you're using existing design patterns that already have the naming spoon-fed to you. takes the thinking out of the whole deal.
    Thinking is the enemy! I love it! I love going to work, writing 400 lines of code and never once stopping to think about what I'm doing and everything just works, without error..
    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. #44
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    I never have the patience to sit down and plan everything, naming all my classes, functions and so on. Its just so easy to figure it all out as I go. ._.
    Same here.

    Quote Originally Posted by XtrEM3 View Post
    it's a lot easier when you're using existing design patterns that already have the naming spoon-fed to you.
    Except for "Registry", I've never named a class after a design pattern. Or do I misunderstand your statement?

  20. #45
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you understand it correctly. i usually do something like $type$pattern, in PHP terms lol. so for instance:

    SessionRegistry
    UserController
    DatabaseFactory

    if it's a model that directly corresponds to a database table, the model's class name is just the singularized version of the database table name.

    of course there's still some creativity needed...there isn't a pattern for everything, but it certainly helps reduce that.

  21. #46
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Database table names should be singular anyway.

  22. #47
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that convention is still up in the air for me. i've been using plural lately, but i don't have any convincing arguments either way.

  23. #48
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by XtrEM3 View Post
    that convention is still up in the air for me. i've been using plural lately, but i don't have any convincing arguments either way.
    It's no big deal. Nobody's going to take away your birthday if you use plural table names.

  24. #49
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so have we concluded that __autoload is not overrated?

  25. #50
    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)
    Quote Originally Posted by World Wide Weird View Post
    Database table names should be singular anyway.
    Surely this:
    Code sql:
    SELECT id FROM topics WHERE name IN('something', 'something else')

    Makes more sense than:
    Code sql:
    SELECT id FROM topic WHERE name IN('something', 'something else')

    In the english sense.

    so have we concluded that __autoload is not overrated?
    I hope so
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


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
  •