View Single Post
Old 03-17-2009, 08:40 AM   #17 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Quote:
The examples are always small so they are useless.
I kind of disagree that short examples are useless. They are if you already understand what you're doing, but for somebody just starting out, you need it. That's why the most famous first example in the world for almost every language is something along the lines of;

PHP Code:
echo 'Hello, World!'
Simple, short, and gets your feet wet. Now we look at OOP;

PHP Code:
class hello_world
{
    public 
$hello_string 'Hello, World!';

    public function 
write_string()
    {
        echo 
$this->hello_string;
    }

}

$my_first_time = new hello_world;
$my_first_time->write_string(); 
Short, and doesn't accomplish a thing we can't do procedurally twice as fast and with 10% of the code. So is it useless? I don't believe so. It gets your feet wet. While you may not understand why it's working the way it is, you've just written your first class, and you're starting to integrate the knowledge of how it's all put together. The problem with some of those tutorials probably lies within the authors ability to convey the necessity of OOP and when and where it can be used most effectively.
delayedinsanity is offline  
Reply With Quote