Welcome Guest, Not a member yet? Register   Sign In
Objects: Why are they useful?
#12

[eluser]tonanbarbarian[/eluser]
I certainly agree with ucantblamem - he often explains things better than i do that is why he does more training of clients than i do
and I also agree with Beren that using Object Oriented Design or Programming does after a while get you into a mindset that helps you to code better because you start to treat each object as discrete.
In fact I credit Objects with a change in the way I programmed so that now I try to create objects that are fairly generic but can be extended to do very specific things as well

And that brings us to the other thing about objects not really talked about yet - extending

Lets take ucantblamem's hammer example. This object might be fine to explain a regular carpentry hammer but what if we need a slegde hammer
Well we can extend the hammer definition and just add the things we need that it doesnt have

Code:
class Sledge Extend Hammer {
    var $weight = 15;
    
    function Sledge($material = 'metal', $weight = 1) {
        parent::Hammer($material, $weight);
    }
    
    function demolish() {
        // Do funcationality here
    }
}

And it now inherits all of the properties and methods of hammer but has its own extras that can be very specific.
So now I know the Sledge Hammer weighs more than the regular hammer and not only can it be used to hammer_nails and remove_nail (not a good example i guess) but it can be used to demolish as well

As for the question about what use is result_object.... not much in its current version
I have seen other version of this implements (in Mambo/Joomla) that will take an existing object and add the properties to it. This can now be done in PHP5+ by passing extra parameters.
If CI result_object could do this it would be more useful, but in general I think I just prefer to use arrays of data from the database. If the object does not have any methods to use I do not think it has much use as such.


Messages In This Thread
Objects: Why are they useful? - by El Forum - 01-22-2008, 02:59 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 03:18 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 03:32 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:02 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:20 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:22 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:31 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:38 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:41 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:49 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:51 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:51 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 04:52 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 05:01 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 05:06 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 05:19 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 06:55 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 07:15 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 07:23 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 07:23 PM
Objects: Why are they useful? - by El Forum - 01-22-2008, 08:15 PM
Objects: Why are they useful? - by El Forum - 01-24-2008, 05:47 PM
Objects: Why are they useful? - by El Forum - 01-24-2008, 05:59 PM
Objects: Why are they useful? - by El Forum - 01-24-2008, 06:34 PM
Objects: Why are they useful? - by El Forum - 01-25-2008, 02:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB