SitePoint Sponsor

User Tag List

Page 5 of 10 FirstFirst 123456789 ... LastLast
Results 101 to 125 of 230
  1. #101
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    As a rule of thumb, globals are evil.

    Or a bit more pronounced - A global is accessible from anywhere in the entire program. Each time you introduce a global, you thus potentially affect any part of your application. This means that with a complex application, the consequences are incomprehensible.
    Possibly worse though, is that whenever someone (for example a thirdparty developer) needs to write any piece of code which interacts with you application (or indeed just run alongside it), the programmer will need to take each and every global into consideration.
    This reminds me of a contract I had to work on, fixing someone else code. Instead of using regular function parameters, the previous programmer would pass data into functions by writing values into the $_POST array. As you can imagine, this was a nightmare to debug.

  2. #102
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Edman
    Another thing about quality of code and why badly coded applications become so popular - n00bs can modify them! Not so with OO apps.
    Indeed. Be careful not to confuse quality with sophistication.

  3. #103
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selkirk
    Indeed. Be careful not to confuse quality with sophistication.
    Thing is, as far as clean OOP code people go, higher quality = more sophisticated code. For us sophisticated code might seem like a good, easy to modify and build upon solution, but for most people, most users, and even most contributors, it's "class... method.. what??"

    Pretty much everyone I know of who uses forums such as phpBB, or hell, even vBulletin, does so because of the literally hundreds upon hundreds of modifications that are freely available that literally allow you to make a board the way you want it to. Who's making these modifications? How much support would an app that requires someone to learn proper programming to modify get instead of one which can be used to start learning programming?

    What does proper programming mean? You can easily satisfy the half-arsed programmer crowd, you just have to build something simple. But if you're bulding something for the hardcore programmers, the result will be that half of them won't care, and the other half will disagree with your methods for the most obscure of reasons.

  4. #104
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    the previous programmer would pass data into functions by writing values into the $_POST array.
    Oh my. Even globals are better than this...

  5. #105
    SitePoint Guru glenngould's Avatar
    Join Date
    Nov 2005
    Posts
    662
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Vanilla is nice and looks different from vBulletin and clones. I hope they release 1.0 asap. I'm not a programmer but the code is also looking pro.

    http://getvanilla.com/
    Tweep List adds an avatar menu to Twitter (open source) ---------- Word Stats shows your most used words on Twitter

  6. #106
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    United States
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unless your going to go commercial with your code I see no reason as to why you can't code how you want, uncommented, sloppy, badly formatted, whatever. It usually won't be a problem if its only you looking at it. I can write a several thousand line piece of software without any documentation and still understand the whole thing (since it was a result of my thinking).

    Now if your going commercial, I can see why you may want to use better coding habbits.

  7. #107
    SitePoint Guru LinhGB's Avatar
    Join Date
    Apr 2004
    Location
    Melbourne, Australia
    Posts
    902
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selkirk
    Indeed. Be careful not to confuse quality with sophistication.
    Quality is sophistication. I think you should perhaps say "not to confuse quality with success or popularity". Because the most successful or the most popular is rarely the best quality.

    Quote Originally Posted by Edman
    Thing is, as far as clean OOP code people go, higher quality = more sophisticated code. For us sophisticated code might seem like a good, easy to modify and build upon solution, but for most people, most users, and even most contributors, it's "class... method.. what??"
    Most contributors, and I dare say, most developers of these projects never did Computer Science so they don't really understand any of these concepts. They may talk about them but they don't know how important or useful those are. If a quick Google search for tutorials returns some code that they can hack into the scripts which make them work after a page refresh, then that's good enough.

    Be careful before you jump to conclusions about open source PHP code though. I've seen commercial code that is just as bad if not worse. The difference is that they aren't open so most people don't get the chance to see and criticize them.
    "I disapprove of what I say,
    but I will defend to the death my right to say it."

  8. #108
    SitePoint Addict phptek's Avatar
    Join Date
    Jun 2002
    Location
    Wellington, NZ
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by McGruff
    There aren't many places to find good advice if you're trying to learn.
    PHP? Are you serious?

    I would say that there are arguably more PHP resources out there than for any other scripting language. Sitepoint, Webmonkey, phpbuilder.com you name it, there's been a PHP tute on there.

    Try building a website out of Zope & Plone - the documentation is so scant it isn't funny!

    All this said, I'm not a contributer, I don't code for or document any of these products (I intend to) and until I do, I'm in no position to complain.

  9. #109
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Edman
    What does proper programming mean? You can easily satisfy the half-arsed programmer crowd, you just have to build something simple. But if you're bulding something for the hardcore programmers, the result will be that half of them won't care, and the other half will disagree with your methods for the most obscure of reasons.
    Funny, but so true!

    There seems to be an endless amount of opinions on the proper MVC-implementation, for example.

  10. #110
    SitePoint Zealot
    Join Date
    Feb 2003
    Posts
    156
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So... do good (as defined in this context) PHP programmers just suck at creating Opensource projects? Or do they suck at making them popular? Do they lack all the other skills necessary to keep a project alive and grow it? Or is it that they rather work on paying projects (don't think that is it, because the PHP-based products that were being sold, that I've seen were even worse than their opensource counterparts)? Maybe they prefer to consult and do individual work, which hapens to shield them from public evaluation...?

    What do you think?

  11. #111
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phptek
    Quote Originally Posted by McGruff
    There aren't many places to find good advice if you're trying to learn.
    I would say that there are arguably more PHP resources out there than for any other scripting language.
    That's true. But the majority of those resources - well, suck. I myself have only relatively recently found these great sites that have good advice dealing with high-class concepts, and I have been doing PHP for quite a long time.

    Or, in other words, the majority of PHP resources are exactly the same quality as the majority of PHP forum software.

  12. #112
    SitePoint Zealot agoossens's Avatar
    Join Date
    Mar 2004
    Location
    Adelaide, Australia
    Posts
    124
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Ezku
    Or, in other words, the majority of PHP resources are exactly the same quality as the majority of PHP forum software.
    A harsh statement, but very true. Experts aren't, and writing your own news casting script doesn't mean you really know what you're talking about.

    PHP is consistently seen as an "amateur" language because primarily amateurs use it and hence produce exceedingly amateur code. This in turn means that the majority of times when a person sees PHP code it's a pile of festering, malignant ooze spawning global variables and heredoc syntax.

    The good news is that those amateurs who really are interested will quickly become good programmers due to actively improving their skills.

    Quote Originally Posted by R. U. Serious
    So... do good (as defined in this context) PHP programmers just suck at creating Opensource projects? Or do they suck at making them popular? Do they lack all the other skills necessary to keep a project alive and grow it?
    That's not a failing of PHP programmers, per se, it's a downside of Free/Open Source in general. It's really, really hard to stay motivated on something you're not getting any tangible reward for (read: money), and that doesn't change if you're programming in PHP, .NET, Ruby, or $LANGUAGE. Even if you really believe in what you're creating eventually your enthusiasm will fade.
    This space for rent.

  13. #113
    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 33degrees
    This reminds me of a contract I had to work on, fixing someone else code. Instead of using regular function parameters, the previous programmer would pass data into functions by writing values into the $_POST array. As you can imagine, this was a nightmare to debug.
    nasty.

    Quote Originally Posted by BerislavLopac
    Oh my. Even globals are better than this...
    You mean, using $GLOBALS is better (I agree), but $_GET, $_POST etc. are globals aswell, and thus they are in the red zone as far as I'm concerned.
    There are two justifications for superglobals in PHP - one being that they are (or were meant to at least) read-only. You generally won't write to $_POST or $_GET, which of course makes so much worse when somebody actually does it. And second, it's a language-feature.
    Still - I don't ever write code which access said superglobals directly at the application-level. Instead I wrap it in a request-object. Most serious PHP projects does something similar.

  14. #114
    SitePoint Member talktechno's Avatar
    Join Date
    Apr 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im not a php programer but im using SMF on my forum
    http://forums.talktechno.com/

    might not be as good as vB but its free so



    IPB imo is rubbish

  15. #115
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    Montreal
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hate to make a shameless plug, but feel free to check out http://k4bb.org. It is my brother's software. I'll say right away that there is a lot of room for improvement, but there are also some good things in there.

  16. #116
    SitePoint Enthusiast Labrocca's Avatar
    Join Date
    Feb 2004
    Location
    Las Vegas
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lately I been toying with a few forum software.

    I wasn't impressed by them except for MyBB.

    http://www.Mybboard.com

    Take a look and tell me your opinion on it's code base. I am an average coder and I would like to hear what you gurus think.

    I also plan to use Vanilla really soon on a couple projects to see how well it does.

  17. #117
    SitePoint Enthusiast didimo's Avatar
    Join Date
    Jan 2006
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a look and tell me your opinion on it's code base.
    see for yourself (mybb's index.php)


    1. you can count on the fingers of your hand how many lines of comments there is
    2. eval() function everywhere
    3. 10 levels of indentation?! (if else, loops etc)
    4. no classes in sight






    PHP Code:
    <?php


    define
    ("KILL_GLOBALS"1);

    $templatelist "index,index_whosonline,index_welcomemembertext,index_welcomeguest,index_whosonline_memberbit,forumbit_depth1_cat,forumbit_depth1_forum,forumbit_depth2_cat,forumbit_depth2_forum,forumbit_depth1_forum_lastpost,forumbit_depth2_forum_lastpost,index_modcolumn,forumbit_moderators,forumbit_subforums,index_welcomeguesttext"
    $templatelist .= ",index_birthdays_birthday,index_birthdays,index_pms,index_loginform,index_logoutlink,index_stats,forumbit_depth3";

    require 
    "./global.php";
    require 
    "./inc/functions_post.php";

    $plugins->run_hooks("index_start");

    // Load global language phrases
    $lang->load("index");

    if(
    $mybb->user['uid'] != 0)
    {
        eval(
    "\$logoutlink = \"".$templates->get("index_logoutlink")."\";");
    }
    else
    {
        eval(
    "\$loginform = \"".$templates->get("index_loginform")."\";");
    }
    if(
    $mybb->settings['showwol'] != "no" && $mybb->usergroup['canviewonline'] != "no")
    {
        
    // Get the online users
        
    $timesearch time() - $mybb->settings['wolcutoffmins']*60;
        
    $comma "";
        
    $query $db->query("SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."sessions s LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid) WHERE s.time>'$timesearch' ORDER BY u.username ASC, s.time DESC");
        
    $membercount 0;
        
    $guestcount 0;
        
    $anoncount 0;
        
    $doneusers = array();

        while(
    $user $db->fetch_array($query))
        {
            
    $botkey strtolower(str_replace("bot="""$user['sid']));
            if(
    $user['uid'] > 0)
            {
                if(
    $doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
                {
                    if(
    $user['invisible'] == "yes")
                    {
                        
    $anoncount++;
                    }
                    
    $membercount++;
                    if(
    $user['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes" || $user['uid'] == $mybb->user['uid'])
                    {
                        if(
    $user['invisible'] == "yes")
                        {
                            
    $invisiblemark "*";
                        }
                        else
                        {
                            
    $invisiblemark "";
                        }
                        
    $user['username'] = formatname($user['username'], $user['usergroup'], $user['displaygroup']);
                        eval(
    "\$onlinemembers .= \"".$templates->get("index_whosonline_memberbit"10)."\";");
                        
    $comma ", ";
                    }
                    
    $doneusers[$user['uid']] = $user['time'];
                }
            }
            elseif(
    strstr($user['sid'], "bot=") !== false && $session->bots[$botkey])
            {
                
    $onlinemembers .= $comma.formatname($session->bots[$botkey], $botgroup);
                
    $comma ", ";
                
    $botcount++;
            }
            else
            {
                
    $guestcount++;
            }
        }
        
    $onlinecount $membercount $guestcount;
        if(
    $onlinecount != 1)
        {
            
    $onlinebit $lang->online_online_plural;
        }
        else
        {
            
    $onlinebit $lang->online_online_singular;
        }
        if(
    $membercount != 1)
        {
            
    $memberbit $lang->online_member_plural;
        }
        else
        {
            
    $memberbit $lang->online_member_singular;
        }
        if(
    $anoncount != 1)
        {
            
    $anonbit $lang->online_anon_plural;
        }
        else
        {
            
    $anonbit $lang->online_anon_singular;
        }
        if(
    $guestcount != 1)
        {
            
    $guestbit $lang->online_guest_plural;
        }
        else
        {
            
    $guestbit $lang->online_guest_singular;
        }
        
    $lang->online_note sprintf($lang->online_notemynumberformat($onlinecount), $onlinebit$mybb->settings['wolcutoffmins'], mynumberformat($membercount), $memberbitmynumberformat($anoncount), $anonbitmynumberformat($guestcount), $guestbit);
        eval(
    "\$whosonline = \"".$templates->get("index_whosonline")."\";");
    }
    // Get birthdays
    if($mybb->settings['showbirthdays'] != "no")
    {
        
    $bdaycount 0;
        
    $bdaytime time();
        
    $bdaydate mydate("j-n"$bdaytime""0);
        
    $year mydate("Y"$bdaytime""0);
        
    $query $db->query("SELECT uid, username, birthday FROM ".TABLE_PREFIX."users WHERE birthday LIKE '$bdaydate-%'");
        
    $comma "";
        while(
    $bdayuser $db->fetch_array($query))
        {
            
    $bday explode("-"$bdayuser['birthday']);
            if(
    $year $bday['2'] && $bday['2'] != "")
            {
                
    $age " (".($year $bday['2']).")";
            }
            else
            {
                
    $age "";
            }
            eval(
    "\$bdays .= \"".$templates->get("index_birthdays_birthday"10)."\";");
            
    $bdaycount++;
            
    $comma ", ";
        }
        if(
    $bdaycount 0)
        {
            eval(
    "\$birthdays = \"".$templates->get("index_birthdays")."\";");
        }
    }
    // Get Forum Statistics
    if($mybb->settings['showindexstats'] != "no")
    {
        
    $stats $cache->read("stats");
        if(!
    $stats['lastusername'])
        {
            
    $newestmember "no-one";
        }
        else
        {
            
    $newestmember "<a href=\"member.php?action=profile&amp;uid=".$stats['lastuid']."\">".$stats['lastusername']."</a>";
        }
        
    $lang->stats_posts_threads sprintf($lang->stats_posts_threadsmynumberformat($stats['numposts']), mynumberformat($stats['numthreads']));
        
    $lang->stats_numusers sprintf($lang->stats_numusersmynumberformat($stats['numusers']));
        
    $lang->stats_newestuser sprintf($lang->stats_newestuser$newestmember);
        
        
    // Most users online
        
    $mostonline $cache->read("mostonline");
        if(
    $onlinecount $mostonline['numusers'])
        {
            
    $time time();
            
    $mostonline['numusers'] = $onlinecount;
            
    $mostonline['time'] = $time;
            
    $cache->update("mostonline"$mostonline);
        }
        
    $recordcount $mostonline['numusers'];
        
    $recorddate mydate($mybb->settings['dateformat'], $mostonline['time']);
        
    $recordtime mydate($mybb->settings['timeformat'], $mostonline['time']);
        
        
    $lang->stats_mostonline sprintf($lang->stats_mostonlinemynumberformat($recordcount), $recorddate$recordtime);
        
        eval(
    "\$forumstats = \"".$templates->get("index_stats")."\";");
    }
    // Get Forums
    $query $db->query("SELECT f.*, t.subject AS lastpostsubject FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid = f.lastposttid) WHERE active!='no' ORDER BY f.pid, f.disporder");
    while(
    $forum $db->fetch_array($query))
    {
        
    $fcache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

    }
    $forumpermissions forum_permissions();
    // Get forum moderators
    if($mybb->settings['modlist'] != "off")
    {
        
    $query $db->query("SELECT m.uid, m.fid, u.username FROM ".TABLE_PREFIX."moderators m LEFT JOIN ".TABLE_PREFIX."users u ON (m.uid=u.uid) ORDER BY u.username");
        while(
    $moderator $db->fetch_array($query))
        {
            
    $moderatorcache[$moderator['fid']][] = $moderator;
        }
    }

    $excols "index";
    $permissioncache['-1'] = "1";
    $bgcolor "trow1";
    if(
    $mybb->settings['subforumsindex'] != 0)
    {
        
    $showdepth 3;
    }
    else
    {
        
    $showdepth =2;
    }
    $forums getforums();

    function 
    getforums($pid="0"$depth=1$permissions="")
    {
        global 
    $fcache$moderatorcache$forumpermissions$theme$mybb$mybbforumread$settings$mybbuser$excols$templates$bgcolor$lang$showdepth$forumpass$collapsed$plugins;
        if(
    is_array($fcache[$pid]))
        {
            while(list(
    $key$main) = each($fcache[$pid]))
            {
                while(list(
    $key$forum) = each($main))
                {
                    
    $perms $forumpermissions[$forum['fid']];
                    if(
    $perms['canview'] == "yes" || $mybb->settings['hideprivateforums'] == "no")
                    {
                        
    $plugins->run_hooks("index_forum");

                        if(
    $depth == 3)
                        {
                            eval(
    "\$forumlisting .= \"".$templates->get("forumbit_depth3"10)."\";");
                            
    $comma ", ";
                            
    $donecount++;
                            if(
    $donecount == $mybb->settings['subforumsindex'])
                            {
                                if(
    count($main) > $donecount)
                                {
                                    
    $forumlisting .= $comma;
                                    
    $forumlisting .= sprintf($lang->more_subforums, (count($main) - $donecount));
                                }
                                return 
    $forumlisting;
                            }
                            continue;
                        }
                        if(
    $mybb->user['uid'] != 0)
                        {
                            
    $lastvisit $mybb->user['lastvisit'];
                        }
                        else
                        {
                            
    $lastvisit $_COOKIE['mybb']['lastvisit'];
                        }
                        
    $forumread mygetarraycookie("forumread"$forum['fid']);
                        if(
    $forum['lastpost'] > $lastvisit && $forum['lastpost'] > $forumread && $forum['lastpost'] != 0)
                        {
                            
    $folder "on";
                            
    $altonoff $lang->new_posts;
                        }
                        else
                        {
                            
    $folder "off";
                            
    $altonoff $lang->no_new_posts;
                        }
                        if(
    $forum['open'] == "no")
                        {
                            
    $folder "offlock";
                            
    $altonoff $lang->forum_locked;
                        }
                        
    $forumread 0;
                        if(
    $forum['type'] == "c")
                        {
                            
    $forumcat "_cat";
                        }
                        else
                        {
                            
    $forumcat "_forum";
                        }
                        
    $hideinfo 0;
                        if(
    $forum['type'] == "f" && $forum['linkto'] == "")
                        {
                            if(
    $forum['password'] != "" && $_COOKIE['forumpass'][$forum['fid']] != md5($mybb->user['uid'].$forum['password']))
                            {
                                
    $hideinfo 1;
                            }
                            elseif(
    $forum['lastpost'] == || $forum['lastposter'] == "")
                            {
                                
    $lastpost "<span style=\"text-align: center;\">".$lang->lastpost_never."</span>";
                            }
                            else
                            {
                                
    $lastpostdate mydate($mybb->settings['dateformat'], $forum['lastpost']);
                                
    $lastposttime mydate($mybb->settings['timeformat'], $forum['lastpost']);
                                
    $lastposter $forum['lastposter'];
                                
    $lastposttid $forum['lastposttid'];
                                
    $lastpostsubject $fulllastpostsubject $forum['lastpostsubject'];
                                if(
    strlen($lastpostsubject) > 25)
                                {
                                    
    $lastpostsubject substr($lastpostsubject025) . "...";
                                }
                                
    $lastpostsubject htmlspecialchars_uni(dobadwords($lastpostsubject));
                                
    $fulllastpostsubject htmlspecialchars_uni(dobadwords($fulllastpostsubject));
                                eval(
    "\$lastpost = \"".$templates->get("forumbit_depth$depth$forumcat"."_lastpost")."\";");

                            }
                        }
                        if(
    $forum['linkto'] != "" || $hideinfo == 1)
                        {
                            
    $lastpost "<center>-</center>";
                            
    $posts "-";
                            
    $threads "-";
                        }
                        else
                        {
                            
    $posts mynumberformat($forum['posts']);
                            
    $threads mynumberformat($forum['threads']);
                        }
                        if(
    $mybb->settings['modlist'] != "off")
                        {
                            
    $moderators "";
                            
    $parentlistexploded explode(","$forum['parentlist']);
                            while(list(
    $key$mfid) = each($parentlistexploded))
                            {
                                if(
    $moderatorcache[$mfid])
                                {
                                    
    reset($moderatorcache[$mfid]);
                                    while(list(
    $key2$moderator) = each($moderatorcache[$mfid]))
                                    {
                                        
    $moderators .= "$comma<a href=\"member.php?action=profile&uid=$moderator[uid]\">".$moderator['username']."</a>";
                                        
    $comma ", ";
                                    }
                                }
                            }
                            
    $comma "";
                            if(
    $moderators)
                            {
                                eval(
    "\$modlist = \"".$templates->get("forumbit_moderators")."\";");
                            }
                            else
                            {
                                
    $modlist "";
                            }
                        }
                        if(
    $mybb->settings['showdescriptions'] == "no")
                        {
                            
    $forum['description'] = "";
                        }
                        
    $expdisplay "";
                        
    $cname "cat_".$forum['fid']."_c";
                        if(
    $collapsed[$cname] == "display: show;")
                        {
                            
    $expcolimage "collapse_collapsed.gif";
                            
    $expdisplay "display: none;";
                        }
                        else
                        {
                            
    $expcolimage "collapse.gif";
                        }
                        if(
    $bgcolor == "trow2")
                        {
                            
    $bgcolor "trow1";
                        }
                        else
                        {
                            
    $bgcolor "trow2";
                        }

                        if(
    $fcache[$forum['fid']] && $depth $showdepth)
                        {
                            
    $newdepth $depth 1;
                            
    $forums getforums($forum['fid'], $newdepth$perms);
                            if(
    $depth == && $forums)
                            {
                                eval(
    "\$subforums = \"".$templates->get("forumbit_subforums")."\";");
                                
    $forums "";
                            }
                        }
                        eval(
    "\$forumlisting .= \"".$templates->get("forumbit_depth$depth$forumcat")."\";");
                    }
                    
    $forums $subforums "";
                }
            }
        }
        return 
    $forumlisting;
    }

    $plugins->run_hooks("index_end");

    eval(
    "\$index = \"".$templates->get("index")."\";");
    outputpage($index);
    ?>

    now compare that to my previous post (few posts back)

    which one is easier to follow? performs faster?

  18. #118
    Non-Member lostseed's Avatar
    Join Date
    Sep 2005
    Location
    Zurconion Soon!
    Posts
    1,549
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by agoossens
    Never before have I seen a mass of spaghetti code that even comes close to matching PHP-Nuke .
    Agreed. Thats probably the most horrific piece of trash I've ever tried.

  19. #119
    SitePoint Evangelist tetsuo shima's Avatar
    Join Date
    Oct 2005
    Location
    Switzerland
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    nasty.


    You mean, using $GLOBALS is better (I agree), but $_GET, $_POST etc. are globals aswell, and thus they are in the red zone as far as I'm concerned.
    There are two justifications for superglobals in PHP - one being that they are (or were meant to at least) read-only. You generally won't write to $_POST or $_GET, which of course makes so much worse when somebody actually does it. And second, it's a language-feature.
    Still - I don't ever write code which access said superglobals directly at the application-level. Instead I wrap it in a request-object. Most serious PHP projects does something similar.
    Agree. Globals are a real problem as it counters the benefits of what polymorphism is all about.
    The SEO Faq thread
    Dependency injection made easy: Phemto

  20. #120
    SitePoint Addict
    Join Date
    Apr 2005
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by R. U. Serious
    So... do good (as defined in this context) PHP programmers just suck at creating Opensource projects? Or do they suck at making them popular? Do they lack all the other skills necessary to keep a project alive and grow it? Or is it that they rather work on paying projects (don't think that is it, because the PHP-based products that were being sold, that I've seen were even worse than their opensource counterparts)? Maybe they prefer to consult and do individual work, which hapens to shield them from public evaluation...?

    What do you think?
    First of all, I find most programmers who are very good often have their head up their own ****. That's true, btw, for pretty much every single part of an industry where excellence is achieved. Industries where logical thinking isn't required are far worse off. This leads to very opinionated people, which in turn leads to products that are considered to be extremely good by some very good programmers to be considered extremely bad by others due to 5 lines of code that could have been written differently.

    Secondly, many many of the very very good programmers stop being programmers. Instead they are hired by large companies to lead teams. Or they find a way to start their own business. If you're a freelancer, you need 2 years of client building, then just start off finding people to work for you. In a year max you'll simply act as a middle man and a quality assurance person. Open source what?

    Thirdly, very good programmers often enjoy working on open source products far more complicated than a forum. Let's face it, anyone with 1 year of commercial PHP experience and no prior computer science education can sit down and write a forum. It's not difficult at all. It is, however, a lot of boring code.

  21. #121
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by z0s0
    From a design perspective?

    I have yet to find a _single_ bit of PHP forum software that doesn't fail my "is-it-crapware" test. That being:

    Code:
    root@Thunder phpBB2# grep "global $db" *
    common.php:* Remove variables created by register_globals from the global scope
    common.php:// Grab global variables, re-cache if necessary
    download.php:   global $user, $db, $config, $phpbb_root_path;
    download.php:   global $config, $user, $db;
    mcp.php:        global $forum_id, $topic_id, $post_id;
    mcp.php:        global $auth, $db;
    mcp.php:        global $db, $auth;
    mcp.php:        global $auth, $db;
    ....
    I'm truly astonished.. fudforum, smf, punbb, phpbb, vbulletin, every one of them is pure spaghetti.

    Surely someone has written something decent?
    How is using global variables directly related to spaghetti code?
    "Never imagine yourself not to be otherwise than what
    it might appear to others that what you were or might
    have been was not otherwise than what you had been
    would have appeared to them to be otherwise."

  22. #122
    SitePoint Evangelist tetsuo shima's Avatar
    Join Date
    Oct 2005
    Location
    Switzerland
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You never know the scope in which you are working. That's one of the characteristics of spaghetti code.
    The SEO Faq thread
    Dependency injection made easy: Phemto

  23. #123
    SitePoint Zealot Serberus's Avatar
    Join Date
    Oct 2005
    Location
    Herts, UK
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by eldacar
    How is using global variables directly related to spaghetti code?
    Wikipedia to the rescue.

  24. #124
    SitePoint Member
    Join Date
    Dec 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think the use of globals in PHP is not always a bad thing. There are instances where it just makes sense. For example the database class in most PHP software is used almost globally in everything. Now you can pass it all your other classes as params on the constructor or you can use global. Either way you are producing the same effect

    Taken from wikipedia even

    However, in a few cases, global variables can be suitable for use. They can be used to avoid having to pass frequently-used variables continuously throughout several functions


    However use of many globals is probably a bad idea but some things like your $db maybe a function class are going to be passed one way or another.


    For example method without globals if I made a syntax error sue me I'm just getting my point across.
    PHP Code:
    class Thread 
    {
        function 
    Thread(&$db)
        {
            
    $this->db=$db;
        }

    Method with a global

    PHP Code:
    class Thread 
    {
        function 
    Thread()
        {
            global 
    $db;
            
    $this->db=$db;
        }

    Of course this also depends on how you designed your database class.

    Reading more I seem some of the most uneeded practices I've ever seen. Yeah I'm going to never grab $_POST, $_GET ect.

    Instead I'm going to have something stupid like this

    PHP Code:
    class Globals
    {
        function 
    Globals()
        {
             
    // This is our way to not use globals YES
        
    }
        function 
    getPost($name)
        {
            return 
    $_POST[$name];
        }

    What exactly are you accomplishing by this you could say add things to do basic checks. Your form data however will always be different and they all may have different constraints. So in the end of it you've added overhead for something so simple. This thing probably would also have one for say $_GET, $_COOKIE ect.


    But hey you guys know best but don't seem to be pumping out your own forum.

    Of course I'm one to talk I have yet to complete mine but I'm only one person. Of course when I do finish and someone asks about it I'm sure it'll be hated on for some bad practice of some kind by the "experts".

  25. #125
    SitePoint Guru
    Join Date
    May 2005
    Location
    Finland
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TonyBaird
    However use of many globals is probably a bad idea but some things like your $db maybe a function class are going to be passed one way or another.
    The other being... Dependency Injection!

    Now, seriously, I don't think there's a good reason to build a class that initializes itself from globals such as you posed. There are tons of ways to get around arduously passing the database connection instance to the constructor. And is it really that bad anyway? Applying a bit of DRY gets you a long way.


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
  •