What is the difference between a property and an instance variable?

Iain picture Iain · May 1, 2009 · Viewed 7.1k times · Source

I think I've been using these terms interchangably / wrongly!

Answer

Hershi picture Hershi · May 1, 2009

Iain, this is basically a terminology question and is, despite the "language-agnostic" tag associated with this question, very language/environment related.

For design discussions sake, property and instance variable can be used interchangeably, since the idea is that a property is a data item describing an object.

When talking about a specific language these two can be different. For example, in C# a property is actually a function that returns an object, while an instance variable is a non-static member variable of a class.