Properties – in the sense I use the term – are a late addition to OO. Wikipedia and InformIT (search for the 3rd occurrence of the word) both offer good definitions of the term “property”. Being an older OO language, Java doesn’t have properties. What it offers is a bean convention of prefixing methods with “get” and “set” (amongst others) to enable Java tools to pretend they are properties. These pseudo properties are known as getters and setters. To my mind, it is important to distinguish between first class properties and the method-based getters and setters of Java. Thus my previous comment about it being erroneous to refer to properties as getters and setters. Just to add to the confusion, both getters/ setters and properties are sometimes referred to as assessor methods, though this term has a much more general meaning to others.
Previously I mentioned UML uses the term “attribute” to refer to fields or member variables. Just to confuse things more, C# uses the term attribute to describe what Java calls annotations and ActionScript calls metadata. No doubt other OO languages use other terms too.
So what is the point of this ramble through confusing terms? Well as I often talk about these aspects of OO within my posts, I thought it about time I defined what I mean when I use these terms. In no way am I claiming these are the one and only correct definitions. Also they are not supposed to be detailed descriptions. They are designed to explain how I’m using the terms to other folk who know OO. The following definitions are simply the way I use them and in future I’ll be able to refer back to them in other posts.
A cohesive package of date and the means of manipulating that data. If may be abstract and thus cannot be used to create instance objects, or concrete, in which case in can be used to create instance objects.
A field, method or property of a class or object. Class members – also known as static members – only ever have one copy and are accessed via the class, not via an instance. Instance members have a copy per instance of the class.
One or two functions or code blocks that are accessed syntactically as if they were a single field. If both the get and set functions are defined, then it can be fully treated syntactically as a field. If only the set function is defined, it may only be written to, not read from. If only the get function is defined, it may only be read from, not written to.