In after someone confuses "in during" with an "in after", and in during someone points out >>6 confused "in during" with an "in after", and in before, after, and during this thread devolves into usual 4channery.
It was meant to be a vector addition function, but ... notice the multiplications. I did this right after I wrote the multiplication function and I guess my mind was thinking about round bouncing boobs and big giant dongs so I got distracted.
There's no need to be that fucking anal for mathematical objects, unless you're a professor who grades his students but himself hasn't done any programming since 1978.
Name:
Anonymous2006-09-11 23:58
I agree with >>14,especially when dealing with a language that has properties. Of course, C++ doesn't support that as part of spec yet. Booo.
In the case of Vector3D, all it's for is a wrapper to simplify mathematical transformations on the (well defined and understood) data contained within, so I don't see what's wrong with tossing getters/setters. Seriously, why would you need to hide x, y, z?
That's not to say getters and setters don't have their place.
Name:
Anonymous2006-09-12 7:25
>>15
Not to mention it is a bloody freaking vector. There is the expectation that you'll be able to dump whatever numbers in there and freely manipulate them; there is no need to "hide" anything.
Name:
Anonymous2006-09-12 7:53
>>13
Wow, you are a faggot. With your best practices (TM), people like you make software ugly to use and maintain.
Anyways, C++ is suboptimal for this kind of thing. In Python, you can declare properties and use them naturally, while, if necessary, they are actually get/set/del functions you define. The possibility of changing implementation with the syntactic elegance and conceptual simplicity of properties.
Name:
Anonymous2006-09-12 8:38
>>14 >>13 was (if not, I am now) pointing out that >>8 didn't understand why he would pass a const reference instead of a class. Thus, >>8 is a shitty programmer.
Name:
Anonymous2006-09-12 8:45
The possibility of changing implementation with the syntactic elegance and conceptual simplicity of properties.
This is what makes properties so awesome.
At first I thought the "Pythonic" (god I hate that word) way of directly accessing attributes was retarded, until I realized the effect that properties have.
Every OO language should have them. Of course C++ doesn't, but there's always D.
Name:
Anonymous2006-09-12 12:59
what the fuck are properties?
Name:
Anonymous2006-09-12 14:54
>>20
They're basically getters and setters that work with equalities. So instead of
object.setpoop(5)
or
x = object.getpoop()
A propery, like in C#, would be:
object.Poop = 5
or
x = object.Poop
And properties, even though they're accessed like equalities, are essentially functions just like getpoop() and setpoop() -- they're just syntactically nicer.
Name:
Anonymous2006-09-12 15:02
>>21
o okay. Anyway, I think getters and setters and properties are stupid for a simple 3D vectors. It's just 3 fricking numbers for god sake. You don't need to inherit them or dynamically allocate stuff inside of it. Just use a struct and be done with it. Overloaded arithmetic would go well with it too. That's pretty much it with 3D vectors.
Name:
Anonymous2006-09-12 18:22
properties are stupid for a simple 3D vectors.
Yeah, in this case they are. The reason why properties are useful is because if you start by accessing public variables directly, you can later change the class implementation without breaking all the code that uses that class.
For example (purely hypothetically!), one day you may decide that using a float for x, y, z isn't good enough, and want to replace it with a complex number implementation. Using properties this is simple, without having to fix all external references to x, y, z.
Name:
Anonymous2006-09-12 21:41
>>23
I agree. Compared to properties, getters and setters seem to be stupid.
Name:
Anonymous2006-09-12 22:40
How do you declare properties?
Do you define a get/set pair for a member variable and Python's smart enough to know figure out A.X is A.getX()?
Name:
Anonymous2006-09-12 23:54
For read-only, you can do a shortcut using decorators. It goes like this: class Example:
def __init__(self):
self._text = "foo bar"
@property
def value(self):
return self._textIf you want to be able to both read and write: class Example:
def __init__(self):
self._text = "foo bar"
def _getValue(self):
return self._text
def _setValue(self, value):
self._text = value
value = property(_getValue, _setValue)
∧_∧ ┌────────────
◯( ´∀` )◯ < lol __pythonic__
\ / └────────────
_/ __ \_
(_/ \_)
lll <- this is my penis
Name:
Anonymous2006-09-15 13:14
None of you can actually program, right?
That's why you keep dumping your anally retentive syntax and language wars here, because you just heard in class that your way is TEH WAY TO DO IT amirite?