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.

learn more… | top users | synonyms

3
votes
1answer
66 views

Setting various types of properties on a JCR node

This code checks value's type and cast it into appropriate type, then puts it into a javax.jcr.Node. The checking looks long and boring. Is there a way to refactor ...
3
votes
4answers
192 views

Property caching

Trying to figure out how to efficiently cache property calculations with dependency tracking to invalidate the cache. Here is the syntax I have at the moment (one ...
10
votes
5answers
290 views

Setting user permissions, where certain permissions imply other permissions

The purpose of the class is to set permissions for a user. These include delete, download, upload, view, etc. These properties often depend on other properties, and setting them has side effects. For ...
1
vote
2answers
67 views

Two classes to validate and store an e-mail address

I'm trying to improve my limited knowledge in PHP (7) and I wrote these two simple classes as a proof of concept. They both have just one (private) property ->email and they run validation before ...
0
votes
4answers
62 views

iOS SDK object to represent a place

I am building an iOS SDK to be consumed by apps. I am building an object that represents a physical place. The interface looks like so: ...
1
vote
2answers
57 views

Class to read the property files

I wrote the following code to read the config/property files. I will be exposing my api as jar to multiple application teams. Functionality: Reads the property files and returns the resource bundle ...
5
votes
1answer
106 views

Simulate a person who is working in a quarry with classes

I build my first "bigger" program with classes. Does this look good? Or do you see something, which I could do better? Do you think I could use a delegate for changing the stones to money here? And ...
3
votes
4answers
777 views

Checking the validation of a field through the Property mutator method `set`

I'm newish to C#, being mainly Java oriented. I have a field _config which needs to be a value from 1 to 8, and I have this code which checks to make sure I can ...
6
votes
2answers
151 views

A possibly-terrible alternative to conditionals full of null checks

I am always super annoyed when I have to write a bunch of if statements whenever I have to traverse an object graph of possibly null objects. As there is not yet a <...
4
votes
2answers
93 views

Property file loader

I have the following code: ...
3
votes
1answer
131 views

Properties File MRU Cache

I made an attempt to implement a Properties File MRU Cache with a limited cache size which are of the most recently used properties can only be held in. A read miss from this cache leads to a read ...
5
votes
1answer
82 views

Writing a class to hold Arduino Properties for an Arduino I2C Debugger

I have this class which mostly holds a bunch of properties and their setters. I also have wrappers for some functions of another module. Here is the class: ...
6
votes
3answers
158 views

C#-like properties

I'm studying metaprogramming I figured out a way to implement C#-like properties in C++. This is proxy object that performs a specified function when you try to receiving or assigning values. ...
1
vote
2answers
67 views

Lazy properties for the angle and length of a line segment

The code below shows the pattern I use to manage properties in my classes when I have the following requirements: Some properties are slow to calculate and are rarely used, so I want them to be lazy ...
2
votes
0answers
69 views

Making a default value a property

I recently asked a question on StackOverflow, looking for a way to more easily turn a class attribute into a @property, but only if no other value has been provided ...
4
votes
1answer
244 views

Enums for measurement units, with possible circular dependency

I have some enums that define measurement information, such as volume, mass, distance etc... They are defined as such: ...
1
vote
2answers
206 views

EF Code First Identity/Info Storage

I've built this EF for storing data for web scraping. Any ideas? What am I missing? ...
5
votes
2answers
127 views

Applying TrimSideSpaces() method to multiple string properties

I am looking for generic ideas and guidelines of how to improve the style of my coding and make it more readable and robust. ...
0
votes
1answer
164 views

Binding controls to properties in ASP.Net WebForms

In my application, we have a number of pages which provide an advanced search capability, with a large number of potential search options (some pages have as few as 3, some as many as 150). The HTML ...
3
votes
1answer
81 views

Correct practice for Python properties that depend on other attributes

When a property is essentially a boolean value for whether or not an attribute exists or is set a certain way, is it more appropriate to create an object that does not list the option attribute in its ...
4
votes
1answer
141 views

Downloading and Loading Remote Game Assets

On advice from an answer to my previous question, I have written some code that will allow my game balance properties to be loaded from a remote server. Right now I am just hosting the raw property ...
3
votes
2answers
271 views

DataTable to given type T simple mapper

I threw this together and would love any suggestions on how to improve on this simple DataTable to given Type T mapper. Anything ...
17
votes
3answers
1k views

Using C# properties for simple operations, where should I draw the line?

Should I be putting Linq statements inside of an objects properties? Is that a best practice or is that a no no? Also if that is ok, where do I draw the line with this? I assume db access is ...
3
votes
1answer
62 views

Updating properties and states

I am rewriting a VB.NET application in C#. This code was originally done in 50 lines and I am trying to clean it up. As you can see I have gotten it down to 10 but I still feel its ugly. I want to ...
3
votes
1answer
71 views
8
votes
2answers
2k views

How to Make Strongly-typed References to Web.Config?

Let's say I have a configuration file with a property in it: <add key="LoadedCode" value="L" /> I know I can reference this using the ConfigurationManager: ...
0
votes
1answer
82 views

How to make a class aware of the container class? [closed]

I would like to group some property from the class UserParameter into a subclass called MySubClassPar. Then I will add a property of type MySubClassPar to the UserParameter. All this for the SRP. The ...
10
votes
7answers
2k views

Inefficient code inside of getter?

I have two lists of the same type and I want to be able view a list of both lists: ...
2
votes
1answer
73 views

Create object-properties from an array

I'm writing a simple table-oriented storage for objects. The schema of a table is stored in the columns-array and the data in the ...
2
votes
1answer
224 views

“Property Container” design-pattern

I've tried to write my Property Container design-pattern implementation. Could anybody, please, tell me, if this code is really what I intended to write (follows ...
6
votes
3answers
308 views

How to refactor this code to get a source from property files?

I want to get the source of these files, but I don't know if I'm efficient. I get the source of the file, put the source in a list, so I put this in a ...
10
votes
2answers
294 views

Best way to handle elements of a private array [closed]

This feels like a simple question, but I'm wondering what the best way would be to manage the elements of a private, fixed-size array. Context: I'm making a simple particle engine, and my ...
3
votes
1answer
125 views

Generic Property class

Some time ago I wrote a little property class for a then abandoned project. I just stumbled over it again and I would like to know if the design is using good, efficient C++. ...
21
votes
4answers
47k views

Grouping elements in array by multiple properties

During work, I was given this task: to group elements with similar properties in the array. In general, the problem is as follows: ...
60
votes
9answers
5k views

Mutually exclusive properties

The question is probably quite simple, but I would like to hear what drawbacks we will have with our code. So, we had a simple implementation and interface for it: ...
1
vote
1answer
722 views

Recursive java.util.Properties references

Background A subclass of java.util.Properties attempts to recursively resolve configured properties: ...
8
votes
3answers
476 views

Class with a sometimes unused property

From times to times I stumble over the following situation: I have got a class with a property that's only used if another property has a particular value, for instance: ...
2
votes
1answer
250 views

Is it correct to use delegates as properties?

I need to create a class with two properties: LogOutput ExceptionOutput These properties (of type ...
2
votes
1answer
336 views

My implementation of javascript class library

I'm reading a book called JavaScript Web Applications. In first chapter, it introduces an implementation of class library. Here's an intermediate version: ...
2
votes
4answers
482 views

Is there anything wrong with this unusual NSMutableArray setter?

This behaves to an outside observer mostly like @property (copy), except it has the very nice property of automatically performing any side effects that may exist ...
4
votes
2answers
745 views

Immutable pure data classes with public setters on properties

I'm putting together some classes as a model for some information (that I'm currently pulling from a website). The classes are implemented in C# - because in the current version of F# there are no ...
14
votes
1answer
5k views

C#-like class properties

I am currently developing a new breed of 3D engine for my upcoming thesis and I really liked the C# properties, but now I am on C++11 for obvious reasons. Since I couldn't find it elsewhere, I tried ...