The tag has no wiki summary.

learn more… | top users | synonyms

8
votes
7answers
1k views

How did OOP evolve to include the notion of Properties

I've come from a C++ background and am going all out C# in my current job and I've just been reading a lot of Q&A about what's the difference between public fields and properties and all the back ...
0
votes
1answer
86 views

Async properties in interfaces to cater for the possibility of expensive first-time evaluation: Is this a good idea?

First of all, sorry if this post is too long. I'll start with the… Short version: Is it generally advisable or a good idea to design an interface property as asynchronous simply because we cannot be ...
2
votes
3answers
126 views

.NET Framework standard container type for multi-value property?

I'd like to create a simple class property which can contain multiple values set from the outside. (Values are of the same type.) Example of property name and contained items: KnownHidScanners ...
0
votes
2answers
119 views

Inheritance is a null property in the parent a bad practice?

I am not a very experienced programmer. So I ask. The field in question is the "Amount" field. I store an amount only in a couple levels of the derived class. The code is a slice of the POCO ...
2
votes
2answers
96 views

Should we test the values of objects returned from the methods being unit tested?

Being new to unit testing I would like to know if I am supposed to test the values of objects returned from methods when doing unit testing. As an example, consider the following classes: public ...
5
votes
3answers
1k views

Why does C# allow properties in interfaces?

In C#, the following code is valid interface I{ int property{get;set;} } Which doesn't make any sense to me. This seems to break one of the most important principles of interfaces: lack of ...
2
votes
2answers
143 views

Property or Method to obtain information about a collection?

Suppose I have a MyList class which extends ObservableCollection<MyObject> where MyObject has the Boolean Property Enabled. Let's say I want the number of MyObject objects that have the ...
4
votes
2answers
205 views

Where to store global enterprise properties?

I'm faced with a crowd of java applications, which need different global enterprise wide properties for operation, for example: hostname of the central RDBMS, hostname and location of the central ...
0
votes
2answers
246 views

.properties files in regular src folder okay? [closed]

I work on a Java project with a suggested structure (separate src folders for java files and resource files). After moving the message / text related properties files to that folder, the externalize ...
2
votes
1answer
123 views

Accessing a private array when I have an extension method

I'm trying to make a number of data classes for my C#/XNA game, which would essentially be a wrapper around T[,]: public interface IGrid<T> where T : struct { Point Size { get; } T ...
4
votes
2answers
420 views

Should I expose a “computed” value as a property or a method?

I have a C# class that represents a content type in a web content management system. We have a field that allows a web content editor to enter an HTML template for how the object is displayed. It ...
0
votes
1answer
187 views

Read-only class properties [duplicate]

When is recommended to use read-only properties -- if the language allows me? Are public read-only properties meant to replace getter methods or at least the Magic Methods like what is available as ...
2
votes
4answers
259 views

Why do some projects have getters and setters for public instance variables?

I was looking into an open-source game framework project written in Java. It has several classes that: Have public instance variables. Have getter/setters for such variables. Generally, I write ...
7
votes
3answers
227 views

What are common patterns for handling possible pluralization in message properties?

Obviously users like to see text properly pluralized, and pluralization schemes vary in the various written languages one may encounter. When internationalizing an app, what pattern(s) are useful for ...
5
votes
4answers
589 views

Are trivial protected getters blatant overkill?

Something I really have not thought about before (AS3 syntax): private var m_obj:Object; protected function get obj():Object { return m_obj; } private var m_str:String; protected function get ...
3
votes
3answers
228 views

Throwing exception from a property when my object state is invalid [duplicate]

I am aware that for the general case, the answer to "should I throw an exception from a property" is "generally don't, but in some special circumstances it is OK to do so". There is a Microsoft ...
0
votes
2answers
731 views

Basic Objective-C Questions

I'm new to objective C, I'm following "Objective C 5th Edition Stephen Kochan and I don't have anyone to ask my doubts to. I'm confused with this question: Q. Is it necessary to use "-" or "+" before ...
15
votes
3answers
1k views

Is it poor practice to name a property/member the same as the declaring type in C#?

For instance, a class like: class Dog { } //never mind that there's nothing in it... and then a property like: Dog Dog { get; set; } I've been told that if I can't come up with a more ...
9
votes
4answers
481 views

How would I design an interface such that it's clear which properties may change their value, and which will remain constant?

I am having a design issue regarding .NET properties. interface IX { Guid Id { get; } bool IsInvalidated { get; } void Invalidate(); } Problem: This interface has two read-only ...
-1
votes
3answers
325 views

Is it possible to encapsulate the object itself within a dynamic property?

I ask this question out of curiosity. Lets say the class Foo is a singleton and I want to call Foo instead of Foo.Instance to access the static object. Would it be possible to encapsulate the ...
1
vote
4answers
3k views

Best alternative of Property file in Java

Hey I an working on the product which is live at multiple portals. The product is developed in GWT, JAVA, Hibernate. My question is : Whether there is any alternative of using property file in java. ...
8
votes
2answers
497 views

Property proper naming to represent string starting with number

Looking at some camera metadata on Windows File Properties there are (along with a few more) two Properties named Focal length and 35mm focal length. I'm developing software that will make use of ...
0
votes
5answers
425 views

Does “Property” in C# cost much?

I have a class created in some namespace, like SomeNameSpace.SubNameSpace.StaticClassName Here is a code snippet from other code file where I want to use this class many more times, so I created a ...
6
votes
1answer
479 views

JavaFX - the right way to use Properties with domain objects

JavaFX has provided a bunch of new Property objects, such as javafx.beans.property.DoubleProperty which allow you to define fields which can be automatically observed and synchronised. In many JFX ...
1
vote
2answers
1k views

Ongoing confusion about ivars and properties in objective C

After almost 8 months being in ios programming, I am again confused about the right approach. Maybe it is not the language but some OOP principle I am confused about. I don't know.. I was trying C# a ...
9
votes
2answers
2k views

Properties under ARC: Always or public-only?

After reading an article humbly named "The Code Commandments: Best Practices for Objective-C Coding" by Robert McNally a little less than two years ago, I adopted the practice of using properties for ...
-8
votes
6answers
4k views

Function like C# properties?

I've been thinking about how C# properties work and could work. I know the purpose that C# properties were originally designed for, which is certainly useful. However instead in this question I'm ...
0
votes
1answer
802 views

Reference public exposed property or private field in other parts of a class [duplicate]

Possible Duplicate: Private variable vs property? I have a public property with a get and set accessor. Associated with this property is a private field. Is it best practice when ...
5
votes
5answers
1k views

Using a SetProperty method to prevent accidental changes to a property

Is it good/bad practice to do the following: public class MyClass { public MyType MyProperty { get; private set; } public void SetMyProperty(MyType myProperty) { MyProperty = myProperty; } ...
3
votes
3answers
4k views

Customer wants to modify the .properties files packaged in our WAR file

I have a customer who wants the ability to modify the .properties files packaged in the web applications WAR file so that they have the control to modify environments at settings. They will be ...