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.
87
questions
4
votes
1answer
51 views
Coroutine-based two-in-one properties
Over the holidays I played around with coroutines and their use as two-in-one getter and setter methods:
...
5
votes
2answers
187 views
(de)serializing c++ object almost automagically
Here's one way to solve the serialization problem in c++20, using a json library:
...
6
votes
4answers
699 views
Section 2: Classes - Design a StackOverflow Post
Design a class called Post. This class models a StackOverflow post. It should have properties
for title, description and the date/time it was created. We should be able to up-vote or down-vote
a ...
5
votes
5answers
4k 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 ...
1
vote
1answer
67 views
Minimal Property system in c++17
So I needed to represent by objects in terms in ini format and change their values from the ini as well, so I thought why don't implement a property system for this. I want it to be bit fast so I ...
8
votes
1answer
208 views
WPF BindableProperty<TValue> to Reduce Boiler Plate
I'm sure anyone who has used WPF is familiar with the irritating boilerplate code surrounding properties, usually of this form.
...
0
votes
2answers
76 views
6
votes
1answer
475 views
Change tracking POCO entities
Description
In a time where thin clients, web browsers, web services and micro services are prevalent, we tend to forget we still have to deal with thick and smart clients. Many applications in B2B ...
6
votes
1answer
7k views
Tracking which entity properties have changed
There are a number of topics pertaining to entity change tracking. All the ones I've seen involve either 1) notifying when a property has changed or 2) merely determining whether or not an entity is ...
5
votes
3answers
119 views
javascript property extractor optimisation
This is a very simple nested property extractor. I wonder if it can be optimised further?
...
5
votes
1answer
122 views
C++ bare getter setter with dispatch
I am trying to achieve a getter/setter behaviour that will reduce code in C++. The interface I would like to achieve is for example:
...
0
votes
1answer
1k views
Python decorator to support static properties
Classes in Python do not have native support for static properties. A meta-class can rather easily add this support as shown below. Are there any problems programmers might experience if they use this ...
2
votes
1answer
581 views
Create a csv of file attributes recursively from a directory parameter in PowerShell
I'm a bit new to PowerShell (version 5) and was wondering if there are any improvements I could make to the following script. Any suggestions for style, code, etc. are all welcome.
The script creates ...
5
votes
2answers
1k views
If non-array property exists convert it to one and push new value
Is there a simpler/shorter/better way to do this?
...
2
votes
1answer
87 views
Is this a proper way to cancel an onMouseOver which uses setTimeout? (Vanilla JS)
I've got a working solution for an onMouseOver event which rolls over a set of images and replaces them in the element. Due to my lack of knowledge in JS I would ...
6
votes
1answer
724 views
IQueryable Extensions working on expression for collection property
Followup to Repository searching code duplication
My goal currently is to make the current implementation of my repository's IQueryable filtering less duplicative. First, I looked into passing ...
0
votes
1answer
110 views
Chaining ConstrainableSet<T> [closed]
Based on feedback on my previous question, I made many small adjustments to the code, added more APIs and tried to follow through with delivering on the excellent advice I have received in regards to ...
4
votes
1answer
109 views
Constraining a property setter fluently
The below code is aimed at providing you the most amount of control and flexibility with control which value gets set to a property.
I Introduce to you, the ...
1
vote
2answers
172 views
Typed properties in Java
I tried to build a "typed" property system in Java and this is what I came up with: first the class Properties that any class can use as an attribute (demo code in the end).
...
1
vote
0answers
29 views
0
votes
1answer
109 views
Factory to instantiate and configure Selenium WebDriver
I, also, need to know whether this is a valid implementation of the factory pattern.
The amount of effort which goes into configuring DriverFactory to simply get a ...
3
votes
1answer
59 views
Read a single int from an optional .properties file
I am no newcomer to Java. One thing that confounds me is why it is so messy to load values from .properties files.
I have an application where, if the .properties file is found, then the value if ...
-2
votes
1answer
491 views
Method to populate a dictionary from properties
I have a class with some properties. In the class I have a method that is "collecting" all the properties in a specific instance of the class to a dictionary, with the properties name being the ...
19
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
2answers
247 views
Javascript extend object
I'm looking for a review of the Javascript code which has this specifications:
Given two objects, the function "extend" adds properties from the 2nd object to the 1st object.
Notes:
Add any keys ...
2
votes
0answers
202 views
Setting many properties in a PHP class
I'm trying to define parameters for my API. It's a super basic one and the first I've made. I'm trying to instantiate my class and set parameters but to me it seems super messy. Is this really the ...
7
votes
3answers
5k views
How to Make Strongly-typed References to Web.Config? [closed]
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:
...
1
vote
2answers
347 views
Class for course information
Here's what the question asks:
Build a class called Course.java. This class should have 4 properties: CourseId, CourseName, Description, and credit hours. Also add the appropriate set and get ...
1
vote
1answer
62 views
Class Property Definition to Prevent Unnecessary Database Calls
The challenge I'm facing is creating a class for a Loan object which contains a number of properties, some of which are classes in and of themselves with similar ...
3
votes
1answer
1k views
Attempting to make my properties an enum based singleton
I was attempting to implement my first singleton using an enum, was a bit of a struggle for me and I'm not sure if its right and more importantly thread safe?
Property provider enum:
...
2
votes
1answer
3k views
Testing multiple logins using Selenium listed in a property file
Excuse please review my code. I am working in automation testing. I did a automation testing for my login page. I am using selenium with page object pattern. I wrote here my code. I am using java ...
4
votes
1answer
72 views
Excel VBA object with validated bounds for an interval
I'm working through a problem I have with Excel VBA. I have two object classes. Class clsLoadStep stores three copies of class clsLoad objects. Class clsLoad simply stores a value and a string stating ...
-1
votes
1answer
301 views
Dependent properties in C#
BountyHunter has a secure line named JobLine that provides them with Prey to hunt.
The Prey can be changed at any time, either from the JobLine or changing circumstances that make the bounty hunter ...
3
votes
2answers
3k views
Using attributes with properties in asp.net MVC
I have an auto generated partial class in my Model folder with lots of properties and I need to modify some of the setters in these properties(annotate property), to ensure that I don't repeat myself ...
2
votes
2answers
4k views
Enum with associated value as stored property in Swift extension
I have a service which connects to server using socket and stays connected,
I used this enum to manage connection state:
...
4
votes
2answers
354 views
Lazily forward properties
I want to have a object where I can reference another object's properties dynamically while they are still considered properties. If I try to do a simple setattr I'll only get the current state when I ...
2
votes
1answer
51 views
One method for changing one of the properties
I have a few resources set in my class – coins, diamonds, hearts, enum of these resources names, and method for increasing specified resource. I want to make single "Increase" method for all resources ...
1
vote
1answer
63 views
Class to help dealing with files, with lazy properties
I have the following class to help me deal with files:
File class:
...
4
votes
1answer
739 views
Jinja2 template loader
I am playing around with building my own back end with python 2.7 and jinja2/cgi. Originally I was defining some of my environment and loader variables at the top but figured this was not the best ...
3
votes
1answer
104 views
Loading configuration properties from XML
I would like a review of the transformation of the first method to the updated one below:
...
2
votes
2answers
1k views
Property value from an asynchronous operation
I have an app which has a session mechanism. When a user creates an account in the app initially, the API returns an access token, the expiry date of that access token and a refresh token which can be ...
7
votes
1answer
7k views
Python proper abstract class and subclassing with attributes and methods
The goal of the code below is to have an abstract base class that defines simple methods and attributes for the subclasses. This is part of an application that provides the code base for others to ...
0
votes
2answers
163 views
Assigning properties
I am leaving my first job because I always worked alone on projects from my day one, which was both useful but also taught me some bad practices some of which I managed to realize but many others are ...
0
votes
1answer
2k views
Copying properties between two classes
I have an ASP.NET MVC 5 app and I map properties between model and viewmodel and vice versa.
I could use automapper to do this but since I don't need mapping rules to convince me to use it as I ...
3
votes
2answers
340 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 ...
4
votes
3answers
3k views
Reading properties from file during standalone application startup
I've a standalone Java application, which basically starts and manages two socket servers. I'd like to configure server ports in a .properties file using the ...
5
votes
3answers
325 views
Reading and working with a large number of XML attributes
I'm currently facing the problem of unmarshalling a huge number (47) of attributes to a Java object. Changing the format of the XML file to be more structured is sadly not an option.
The following ...
4
votes
1answer
374 views
Getting enum values of Pseudo-Enum classes
By "Pseudo-Enum" classes I mean cases where someone's used a class with public static properties to emulate enum behaviour; e.g. as described here.
Per the example below, this is useful for classes ...
4
votes
1answer
311 views
ViewModel base class supporting property notification, error notification and property value history
I've created a general purpose ViewModel base class in what I believe it's purest
behaviour. It features property notification, error notification and property value history. Please take a look at it ...
1
vote
3answers
93 views
Instantiating a property when the required attributes have been set
I have a simple class which holds my product. Someone can add a serial to this product and also a purchase id. On change of the properties, I want to check whether both properties are set, and get the ...