Talk:Property (programming)

From Wikipedia, the free encyclopedia
Jump to: navigation, search

I would really like to see some mention of the negative of properties. In particular, the statement "properties provide a higher level of encapsulation than public fields" is really a stretch. Properties basically override encapsulation in the worst possible way. See, for example, http://elegantcode.com/2008/09/26/properties-a-false-sense-of-encapsulation/ — Preceding unsigned comment added by 99.226.116.206 (talk) 01:46, 12 July 2013 (UTC)

I'm reluctant to make a really radical change - yet I can't really see the point to the "See also" section when there are links in the first pp. - Jon Shemitz 10:33, 11 September 2006 (UTC)

Python example code issues[edit]

The python example doesn't cause an exception as claimed: >>> pen.readonly = "Something Else" # this fails (raises an exception) >>> pen.readonly 'Something Else' >>>

Also it would be nice to be able to copy and paste the python directly into a python shell. Currently there are indentation errors if a direct copy-paste is done.

Thanks.

Thanks for testing it out, I have fixed both. -- 58.187.94.8 (talk) 07:21, 22 December 2007 (UTC)

Language Support of Properties[edit]

The article states

"Some object-oriented languages, such as C++ and Java, don't support properties, and require the programmer to define a pair of accessor and mutator methods instead."

I won't speak to C++, but Java has had a persistent properties API available since it's release.

java.util.Properties has been available since 1.0.

java.util.Properties is a class for storing configuration about a Java application, see .properties. From this article: "In some object-oriented programming languages, a property is a special sort of class member, intermediate between a field (or data member) and a method. You read and write a property just as you read and write a field, but this is (usually) translated to get and set method calls." -- nothing to do with configuration. 217.205.94.62 10:50, 12 September 2007 (UTC)

What about Scala? Does it support properties (get/set, not this lib)? —Preceding unsigned comment added by 200.100.199.203 (talk) 04:08, 14 July 2010 (UTC)

History[edit]

Does anyone know who came up with the idea or what programming language first implemented them? Delphi was the first one I used that had them. I can't say that there wasn't something before that, however. --71.214.223.133 (talk) 19:50, 17 January 2010 (UTC)

C++ properties[edit]

The example given for C++ is short, but the code provided doesn't really offer support for getter and setter methods much less any additional stuff properties are good for.

  • The correct implementation of this (property class) is listed at CodeGuru, but this method is pretty RAM and CPU greedy.
  • A better, less RAM consuming method (using #define with subclassing) is listed at CodeProject
  • I myself have done some analysis and work on the subject and created a somewhat more complete implementation (also using the subclassing method) here. This sample also supports classes, containers and other complex types, which the above two samples do not. Additionally my implementation already declares a base property-enabled class (almost) equivalent to TObject in Delphi VCL - which was my goal.
  • Perhaps one should also mention Qt (framework) because their own preprocessor allows them to have properties supported very well.

Anyway, what I'm trying to say is that the sample provided doesn't really provide property functionality, it just strict-types the member. The above links provide much better functionality.

I also think these links should be mentioned in the C++ text with references to these pages so that the reader can be directed to proper solutions right away. The only reason I haven't done that myself is because I have "a personal interest" with my own implementation here.

Please discuss.

Velis74 (talk) 07:04, 20 March 2012 (UTC)