Author Topic: ->set  (Read 857 times)

Offline pavansss91

  • Level 18
  • *
  • Posts: 185
  • Reputation: +1/-0
    • View Profile
->set
« on: January 27, 2009, 12:17:57 PM »
i often see this in some config files.

-> set *********          *=blah..blah..

what does this stand for and whi they are used?
bbgFramework v0.1.3
Sun Database Class v0.3

Offline raestlyn

  • Level 29
  • **
  • Posts: 463
  • Reputation: +9/-5
    • View Profile
Re: ->set
« Reply #1 on: January 27, 2009, 04:19:06 PM »
$foo->bar means that the $foo is an object that is using method (its like a function, but its called method when its used in OOP) named bar. If you really want to learn Object Oriented programming I suggest that you read The basicc of the OOP.

The ->set() is so-called Setter, it gives a value to the object. I must say I haven't fully understanded the benefit to use Setters and Getters, but they are commonly used.


I can send you pics of my cocks if you want reference.


Offline Caesium

  • Level 4
  • *
  • Posts: 14
  • Reputation: +0/-0
    • View Profile
Re: ->set
« Reply #2 on: January 27, 2009, 04:34:17 PM »
$foo->bar means that the $foo is an object that is using method (its like a function, but its called method when its used in OOP) named bar. If you really want to learn Object Oriented programming I suggest that you read The basicc of the OOP.

The ->set() is so-called Setter, it gives a value to the object. I must say I haven't fully understanded the benefit to use Setters and Getters, but they are commonly used.

Setters and getters are great because you should not allow direct control of a member of a class.  Sometimes you want to perform some validation or set some other variables when a variable changes.  Sometimes you might not want to return the variable directly, you may want to perform some calculation against it.  Sometimes you might want to prevent it from being read at all.

I'm currently working on a game in my college program where an object has an X and a Y position.  I store the positions as floats, because the movement per game loop is rather small, but when outside objects ask for its position I return it to them as an integer, because in terms of the game world that's all they need to know.  Setters can also be useful from within a class, because you may want to prevent some variables from getting out of range.  In the same game, one of my objects has a maximum speed it can go and receives speed boosts from outside sources.  My setter takes care of capping the speed for me, instead of me checking wherever I might happen to increase the speed from within the class.  Getters and setters are a great way of writing code once and forgetting about overcoming that problem throughout the rest of your code.

It's a good practice to get into, because even if a property seems rather straight forward when you begin coding, an issue may arise later down the road where you might need to implement some error checking or value capping.  Being able to change code in one place and have the functionality you want becomes extremely beneficial and can help reduce bugs being introduced by code updates.
« Last Edit: January 27, 2009, 04:37:38 PM by Caesium »

Offline pavansss91

  • Level 18
  • *
  • Posts: 185
  • Reputation: +1/-0
    • View Profile
Re: ->set
« Reply #3 on: January 28, 2009, 03:00:44 AM »
thnks

i think that i understood most of the reply by u guys.
bbgFramework v0.1.3
Sun Database Class v0.3

Offline pavansss91

  • Level 18
  • *
  • Posts: 185
  • Reputation: +1/-0
    • View Profile
Re: ->set
« Reply #4 on: January 28, 2009, 06:25:17 AM »
$cl_builds->set_maxstage("30");

there are so many $cl_builds->set_maxstage("x"); in the phpfile.

what does that mean??
bbgFramework v0.1.3
Sun Database Class v0.3

Offline raestlyn

  • Level 29
  • **
  • Posts: 463
  • Reputation: +9/-5
    • View Profile
Re: ->set
« Reply #5 on: January 29, 2009, 02:13:50 AM »
Its a custom made method that sets maximum amount of something to the object. Look trough the included files and you'll see the objects properties.


I can send you pics of my cocks if you want reference.


Offline pavansss91

  • Level 18
  • *
  • Posts: 185
  • Reputation: +1/-0
    • View Profile
Re: ->set
« Reply #6 on: January 29, 2009, 05:46:00 AM »
yes i have seen the object properties but how will theyuse these variables.

i want an applicative example please
bbgFramework v0.1.3
Sun Database Class v0.3

Offline raestlyn

  • Level 29
  • **
  • Posts: 463
  • Reputation: +9/-5
    • View Profile
Re: ->set
« Reply #7 on: January 30, 2009, 02:58:08 PM »
Fine, OOP for dummies.

First you need to make a class.
Code: [Select]
<?php
class Box
{
    
//In here comes all the class information, methods etc
}
?>


Are you still with me? Good.
Now lets add something to our little class:
Code: [Select]
<?php
class Box
{
  var 
$contents;

  function 
Box($contents) { 
    
$this->contents $contents;
  }

  function 
get_whats_inside() {
    return 
$this->contents;
  }
}

$mybox = new Box("Jack");//Now $mybox is object called Box and we can use the class methods
echo $mybox->get_whats_inside();
 
?>


Got it?


I can send you pics of my cocks if you want reference.


Offline pavansss91

  • Level 18
  • *
  • Posts: 185
  • Reputation: +1/-0
    • View Profile
Re: ->set
« Reply #8 on: January 30, 2009, 08:20:17 PM »
yes thanks a lot.
bbgFramework v0.1.3
Sun Database Class v0.3

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal