i dont get why people try to hide class variables at any cost. of course its wise to hide as much variables as possible, but why writing a shitload of getters and setters instead of simply calling the variable itself.
Name:
Anonymous2006-07-19 1:54
I'ts induestries best practice to do so
Name:
Anonymous2006-07-19 3:35
>>10
it's supposed to be self contained. each object is supposed to be treated as a whole object that interacts with other objects rather than a data structure with support for member functions.
Name:
Anonymous2006-07-19 18:02
>>10
It's called encapsulation dipshit. Say you have a Shape object and, like the noob you are, you make its position variable public and use it all over your code. Then a year later you decide to extend Shape into a Triangle, where position doesn't make sense unless you go do some lengthy calculations to find its centroid. Way to go, now you need to encapsulate your triangle's vertices and re-check them every time in case someone fucked with your public position.
Encapsulate it properly, and you can write the vertex deltas into the setPosition method you extend. No wasted calculation time.
gb2/encapsulation/
Name:
Anonymous2006-07-19 18:22
>>13
encapsulation my ass. im glad classes like Ogre APIs Vector3 and many other got public variables, just so i dont have to write .getX instead of .x. xD
>>14
doesn't mean encapsulation sucks, just that languages without properties suck.
Name:
Anonymous2006-07-20 7:45
it's supposed to be self contained. each object is supposed to be treated as a whole object that interacts with other objects rather than a data structure with support for member functions.
And then some people look at it as an infallible holy grail and you end up with shit like Java.
Name:
Anonymous2006-07-20 7:57
>>16
Java isn't a purely object oriented language. Have a look at Smalltalk for how it's supposed to be done.
Name:
Anonymous2006-07-21 9:40
>>17
But Java is how it's done wrong, from forcing square pegs into non-existant holes
>>20
Hilarious, it's totally not posted by one person in total!
Name:
Anonymous2008-04-23 17:18
gb2/REchan
Name:
Anonymous2008-04-23 17:19
do{
hax(my.anus)
}while(true);
Name:
Anonymous2008-04-23 18:11
Getters and setters are for when you want to hook extra functionality to get/set or generate the result for the get on the fly. People like to put them in up front because when you go from direct field access to a getter, you don't have to rewrite everything that calls it.
If you have a getter/setter pair surrounding a variable, it is NOTENCAPSULATED, dipshits! Anybody has free reign to read and change it!
Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy