Questions tagged [properties]

A property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method. Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls.

Property, in some object-oriented programming languages, is a special sort of class member, intermediate between a field (or data member) and a method.

Properties are read and written like fields, but property reads and writes are (usually) translated to get and set method calls. The field-like syntax is said to be easier to read and write than lots of method calls, yet the interposition of method calls allows for data validation, active updating (as of GUI visuals), or read-only 'fields'. That is, properties are intermediate between member code (methods) and member data (instance variables) of the class, and properties provide a higher level of encapsulation than public fields.

See:

18121 questions
7
votes
2 answers

C# field vs. property

Possible Duplicate: Difference between Property and Field in C# I thought that basic properties ({ get; set; }) where the same as public fields, with only the advantage of being able to change them without breaking binary compatibility. Following…
Baruch
  • 20,590
  • 28
  • 126
  • 201
7
votes
1 answer

use class getters or class properties? (PHP)

What's considered best practice writing OOP classes when it comes to using a property internally. Consider the following class;
Roland Franssen
  • 1,038
  • 1
  • 11
  • 22
7
votes
3 answers

Know if Fields/Properties of an object are "simple/primitive" types or other objects?

I got the following code that generate a DLL (sample exemple) : public class PluginClass { private string _MyString; public string MyString { get { return _MyString; } set { _MyString = value; …
Guillaume Slashy
  • 3,554
  • 8
  • 43
  • 68
7
votes
1 answer

Objective-C: access private propertys in a inherited class

I'm trying to access private properties on a inherited class. Is that possible with that naming convention apple gave me? Header: #import @interface FooBar :…
lenn1
  • 73
  • 1
  • 3
7
votes
5 answers

Collect property of objects in collection

In C# I can do this: IEnumerable ids = things.select(x => x.Id); In Java I have to do this: Collection ids = new ArrayList(things.size()); for(Thing x : things) ids.add(x.getId()); Have to do this sort of thing quite a lot now…
Svish
  • 152,914
  • 173
  • 462
  • 620
7
votes
1 answer

Auditing and validating changes to C# class and structure properties in a high-performance way

I have several c# structs that give shape to structures in a very large data file. These structs interpret bits in the file's data words, and convert them to first-class properties. Here is an example of one: [StructLayout(LayoutKind.Sequential,…
Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
7
votes
3 answers

classloader.getSystemResourceAsStream returns null

I'm trying to load a properties file without using the actual path of the file. I've already done that on some other simple apps using: InputStream inputStream = ClassLoader.getSystemResourceAsStream(PROPERTIES_FILE); props.load(inputStream); But…
Lancelot
  • 2,417
  • 12
  • 39
  • 46
7
votes
4 answers

Replace property for perfomance gain

Situation Similar to this question, I want to replace a property. Unlike that question, I do not want to override it in a sub-class. I want to replace it in the init and in the property itself for efficiency, so that it doesn't have to call a…
Spycho
  • 7,698
  • 3
  • 34
  • 55
7
votes
7 answers

python read-only class properties

Is there a way to make read-only class properties in Python? Ex. in Unity3d you can do this: transform.position = Vector3.zero Vector3.zero returns an instance of the Vector3 class where x, y, and z are 0. This is basically the same…
topher
  • 83
  • 1
  • 5
7
votes
4 answers

CSS style specific characters inside a text input

I have a script that generates text when a user press a button. This text is sent to an input box, so when I press the button some text appears in one input box. I would like to know if there's any CSS property to style the color of all the "-"…
Maria
  • 71
  • 1
  • 2
7
votes
1 answer

Getting date/time of creation of a file

This seems like a pretty straightforward question but I haven't been able to find a definitive answer anywhere online. How can I get the date/time a file was created through Java's file manager? Aside from just the name of a file, what else can I…
Brian
  • 7,955
  • 16
  • 66
  • 107
7
votes
3 answers

Objective-C: Defaults to atomic for scalar properties?

A friend told me that the @property default for scalar properties (BOOL, NSInteger, etc.) is nonatomic. I.e., @property BOOL followVenmo; defaults to @property (nonatomic) BOOL followVenmo; But, I was always under the impression that the default…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
7
votes
1 answer

Replace Property Getter/Setter with Reflection or similar (no 3rd party libraries) in c#

I've got a property contained in a class for example public class Greeter { private Hashtable _data; public string HelloPhrase { get; set; } public Greeter(data) { _data = data; } } What I would like to do is add an Attribute to…
Mike Miller
  • 16,195
  • 1
  • 20
  • 27
7
votes
6 answers

Why are C# auto-implemented properties public?

In all the examples I see, C# auto-implemented properties are made public, even in the MSDN documentation examples. Coming from a C++ background, I've always been taught that it is a good idea to make member data private, unless there is a good…
InvalidBrainException
  • 2,312
  • 8
  • 32
  • 41
7
votes
4 answers

template of template c++?

i've managed to create some preperty class with all the thing we expect from one. I mean when using it you don't need to call functions just using operator = will do all the work. but there is only one thing I guess it would be nice if we could…
Ali1S232
  • 3,373
  • 2
  • 27
  • 46