Right, interfaces... you'd benefit from using them for a simple reason: you can abstractly reference them like you would an actual object.
For example, let's say I have a method in a 'Weapon' class that is meant to deal damage to other objects, and let's say I want it to damage different types of object such as a 'Character', and a piece of Furniture, let's say a 'Door'. I implement the interface 'IDamagable' that contains the TakeDamage() method on both 'Character" and "Door" classes, that way the Weapon can directly interact with any object that implements the interface (hence the word 'interface' eh), both 'Character' and 'Door', and each of those objects manages how taking damage affects it internally. That's way better than a endless if-elseif-else litany of "if object type A then do damage method B, if object type C then do damage method E" on the 'Weapon' class.
To sum up: given a collision trigger is called, and the Weapon receives a callback with a colliding class object as a parameter...
With interface implemented :
> if colliding Type has interface IDamagable, call TakeDamage method.
Without interface :
> if Type is 'Door', do Method A, if Type is 'Character', do Method B, if Type is 'Balloon,' do Method C, and so on and so on.
Tyvm for the explanation, that actually makes things clearer. The thing I don't understand is how you can even write womething along the lines of:
if(object is of class that implements IDamageable)
call object.TakeDamage()
given the object
might not have such a method, the second line would be illegal, right ? Coming from C++ for example, a class either has TakeDamage(), which is known at compile time, or it doesn't. Here you're telling me these things aren't known at compile time but at run time? Or what you mean is you don't actually write the if, but the interface acts as a collection of types, and the compiler checks that the object is instantiated from a class that belongs to a collection of types that has TakeDamage()? Also how can a method perform on variable-typed objects ? I thought variables were typed. In that case the method that calls TakeDamage() has a Chair argument and just calls Chair.TakeDamage(), right?
I think it's pretty neat, but I must just be irreversibly alienated by the dogma of OOP gurus. Again it's pretty self-evident: an interface suggests utility in interaction, ofcourse there's no point implementing one if you are not planning for your object to have any sort of interaction with another.
it's not if you weren't told ! If I gave you a screwdriver and you'd never seen a screw, would you know what it's for? You'd understand its mechanical properties, how to hold it in your hand, but you wouldn't know what purpose it serves. That's what I'm talking about. Of course, if you carried that screwdriver around for a while, trying on every object to find a purpose for it, you might end up finding its intended use. Or you might instead use it to carve wood, who knows.
I don't know what this has to do with "culture", programming is a discipline of applied mathematics (or should be treated like one), there's no 'culture' of mathematics in the sense you're suggesting, there's not a german nor russian nor nigerian way to program or code. There's a bad way, a better way, and the optimal way.
By culture I don't mean the arbitrary but the transmitted from person to person. In that sense, mathematics is culture much more than anything else. Learning straight from textbooks is the exception rather than the norm. Let me give you a simple example. The textbook says,
" Let f:R->R, f is said to be continuous in x0 iff : forall epsilon > 0, there exists eta > 0, such that forall x in R, |x-x0| < eta implies |f(x0)-f(x)| < epsilon "
The professor says,
"A function is continuous in x0 if for f(x) to be arbitrarily close to f(x0) all you have to ensure is that x is close enough to x0"
According to you, which one is better, and faster, understood? Extrapolating from this, it's obvious mathematics as a whole is taught in the latter way better than the former. To give another, maybe more to the point, example. The differential is defined as such:
"f:E->F is said to be differentiable in x0 if there exists a linear application L0 such that for all x, f(x) = f(x0) + L0(x-x0) + O((x-x0)^2)"
which is all nice and dandy, but how do you go from that to the intuitive understanding of what a differential is? Again, human transmission, not logic but drawings, heuristics. Without these, that's just another definition you'd read, maybe remember, but never really understand the significance of. You might be able to apply it to test if a function is differentiable, but that wouldn't tell you why you'd want to do that.
Anyways, I got a bit off track. As for the definition of culture you were using, it also applies to mathematics and, I imagine, every branch of science.
What I'm trying to make you understand here, is that these things you find obvious are not, and sometimes people don't need help with what to write but rather why they'd write it. That little explanation you gave, though it led me to more questions, actually helped me more than any syntax I might have picked up or knowing what such and such keyword does.