I was reading on OOP and was curious if anyone could explain the differences as to why there's so many different names for variables?
So far I've seen,
variable (outside of a class)
data member (in a class)
property (in a class)
attributes (in a class)
essentially they're all something that stores data, but what's the differences?
variables, properties, data members, etc, why so many names?
Moderator: General Moderators
-
aschlosberg
- Forum Newbie
- Posts: 24
- Joined: Fri Jan 23, 2009 10:17 pm
Re: variables, properties, data members, etc, why so many names?
The difference between those in and out of a class is that there can be multiple instances of the former as they are specific to a particular instance of the class. The different naming aids in designating the difference between them.
As for the various names for those inside a class I'm not actually sure.
As for the various names for those inside a class I'm not actually sure.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: variables, properties, data members, etc, why so many names?
Member and Property are often used interchangeably but there's a subtle difference. Member can refer to either a property, or a method.
Method and Property clarify what you're referring to. Attributes, yeah, yet another term. I suspect all these terms have arisen from different languages.
PHP tends to call them Properties and Methods. Java does too. C++ often calls them members... blah, it's all messed up
Method and Property clarify what you're referring to. Attributes, yeah, yet another term. I suspect all these terms have arisen from different languages.
PHP tends to call them Properties and Methods. Java does too. C++ often calls them members... blah, it's all messed up
Re: variables, properties, data members, etc, why so many names?
Some of them can be attributed to hotshots wanting to be the one who chose the 'next big name' or just to put their own flavour on it *cough*Microsoft*cough* others are just differences in languages (spoken languages, not syntax) where the literal translation of names can be lost, such as literally translating property from English to another language and back again may come out as member.
Re: variables, properties, data members, etc, why so many names?
In javascript members are properties. In PHP you could store the name of a method as a property ( and use it to reflectively call the property )