variables, properties, data members, etc, why so many names?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
FunkyDude
Forum Newbie
Posts: 8
Joined: Mon Dec 15, 2008 5:19 pm

variables, properties, data members, etc, why so many names?

Post by FunkyDude »

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?
aschlosberg
Forum Newbie
Posts: 24
Joined: Fri Jan 23, 2009 10:17 pm

Re: variables, properties, data members, etc, why so many names?

Post by aschlosberg »

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.
User avatar
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?

Post by Chris Corbyn »

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 :lol:
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: variables, properties, data members, etc, why so many names?

Post by Jenk »

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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: variables, properties, data members, etc, why so many names?

Post by josh »

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 )
Post Reply