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.
91 questions
3
votes
0
answers
136
views
Simulating Objects with Collections in VBA
Background
I am writing a VBA module which requires the functionality of a custom object. This object will support "regular" functions (UDFs) within the module.
Due to reasons beyond the ...
1
vote
0
answers
107
views
Storing multiple PyTorch tensors of different shapes with names that are not known by advance
I need to create a container for instances of torch.Tensor of different shapes, where I can call them by their name.
It is a use case for a dict except that:
I don't want to rely on the heavy syntax ...
0
votes
1
answer
404
views
Sanitize object to only include specific properties
Object Property Sanitization
I'm learning to code servers using JavaScript, Node, and Express. While writing controllers that create new entries in the database, the need to sanitize the user input ...
2
votes
1
answer
30
views
Pandas-style "indexer proxy" descriptor
The goal is to write a decorator that allows you to define "indexer proxies", which define properties with __getindex__ instead of normal method calls, ...
5
votes
3
answers
2k
views
A method for managing enumerations in VBA
I have for some time been frustrated by the limitations around enumerations in VBA. Googling didn't find anything really simple and comprehensive. So after a bit of head scratching I came up with the ...
3
votes
1
answer
69
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
2
answers
252
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
4
answers
2k
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 ...
1
vote
1
answer
334
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
1
answer
370
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
2
answers
103
views
Descriptor to restrict input [closed]
We start off we the following Person class:
...
6
votes
1
answer
2k
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 ...
5
votes
1
answer
618
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:
...
2
votes
1
answer
1k
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 ...
2
votes
1
answer
409
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 ...
4
votes
1
answer
14k
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 ...
0
votes
1
answer
116
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
1
answer
148
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
2
answers
494
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).
...
0
votes
1
answer
134
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
1
answer
69
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
1
answer
2k
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 ...
3
votes
2
answers
398
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
0
answers
216
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 ...
1
vote
2
answers
924
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 ...
3
votes
1
answer
3k
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:
...
1
vote
1
answer
84
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 ...
0
votes
1
answer
323
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 ...
5
votes
2
answers
2k
views
If non-array property exists convert it to one and push new value
Is there a simpler/shorter/better way to do this?
...
3
votes
2
answers
4k
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
2
answers
5k
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
2
answers
495
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 ...
4
votes
1
answer
88
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 ...
2
votes
1
answer
57
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 ...
4
votes
1
answer
914
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 ...
2
votes
1
answer
5k
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 ...
3
votes
1
answer
111
views
Loading configuration properties from XML
I would like a review of the transformation of the first method to the updated one below:
...
9
votes
1
answer
14k
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 ...
1
vote
1
answer
80
views
Class to help dealing with files, with lazy properties
I have the following class to help me deal with files:
File class:
...
2
votes
2
answers
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 ...
0
votes
2
answers
174
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 ...
4
votes
3
answers
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
3
answers
574
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 ...
6
votes
1
answer
1k
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 ...
4
votes
1
answer
721
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
1
answer
378
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
3
answers
120
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 ...
3
votes
1
answer
3k
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 ...
5
votes
5
answers
6k
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
5
answers
1k
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 ...