properties

Clean Code: Should Objects have public properties?

I'm reading the book "Clean Code" and am struggling with a concept. When discussing Objects and Data Structures, it states the following: Objects hide their data behind abstractions and expose functions that operate on that data. Data Structures expose their data and have no meaningful functions. So, what I'm getting from this is th...

modify properties file in META-INF

I'm using maven and storing a properties file in src/main/resources which I can read fine like: properties.loadFromXML(this.getClass().getClassLoader(). getResourceAsStream("META-INF/properties.xml"); Is it possible to then write to this file when it is packaged up as a jar? I've tried the following: propertie...

Get property value of any entity in NHibernate in a generic way

Hi, I need to create a method like this: object GetPropertyValue(object entity, string databaseColumnName, int index); that will take any entity, a column name which is represented as a property in entity class and an optional index that is used if DB column is located inside collection property by some index. For example: Field e...

Use reflection or a property when unit testing?

This is a class I'm a bit concerned about. My goal is to unit test the addresses list: public class LabelPrinter { private readonly IEnumerable<Address> _addresses; public LabelPrinter(IEnumerable<Address> addresses) { _addresses = addresses; } public Document Create() { // ... Generate PDF, etc...

Strange Inheritance Issue with C# classes

public class DTOa { public int Id { get; set;} public string FirstName { get; set;} } public class DTOb: DTOa { public string Email { get; set;} public string Password { get; set; } } public class a { protected DTOa _DTO = new DTOa(); public int Id { get { return _DTO.Id; ...

C# custom property editor

Hello all. I have the following custom property in my code: public Dictionary<int, string> ServiceIdList { get { return ((Dictionary<int, string>)(GetValue(LoadSubscriptionList.ServiceIdListProperty))); } set { SetValue(LoadSubscriptionList.ServiceIdListProperty, value...

How to create a read-only class property in Python?

Essentially I want to do something like this: class foo: x = 4 @property @classmethod def number(cls): return x Then I would like the following to work: >>> foo.number 4 Unfortunately, the above doesn't work. Instead of given me 4 it gives me <property object at 0x101786c58>. Is there any way to achieve ...

How can I convert a java bean to a properties file?

What libraries are available that can do something like public class Person { private Long id; private Name; private List<Long> associations; // accessors } public class Name { private String first; private String last; // accessors } into something like id=1 associations=1,2,3,4,5 name.first=Franz name.last=See ...

How to detect system information like os or device type

The most important things i want to know are the device type, the os version, if it has a hardware keyboard and maybe the screen resolution. but if you know other useful debug information please add them :) i found this for the os version: string+="OS Version: "+System.getProperty("os.version"); how do i get the other properties? ...

How to properly define class properties?

When defining a new class within a project what is the correct/best practice for doing so? In the past I have created classes such as: public class MyClass { public string FirstName {get; set;} public string LastName {get; set;} } Normally I’d use a class such as this for the creation of collections within a proje...

How can I access variables belonging to one class from an outside class?

I am new to objective c and I guess it has to do with me not understanding pointers or something, but I cannot access a variable outside the class it was declared in. I know this is a ridiculous question, but I need help. I have something as simple as an NSString which depending on which tablecell row is selected it grabs the name an...

What is the real purpose of get,set properties in c#?

Possible Duplicates: Properties vs Methods C#: Public Fields versus Automatic Properties What is the real purpose of get,set properties in c#? Any good ex when should i use get,set properties... ...

error: writable atomic property cannot pair a synthesized setter/getter with a user defined setter/getter

I recently tried to compile an older Xcode project (which used to compile just fine), and now I'm seeing a lot of errors of this form: error: writable atomic property 'someProperty' cannot pair a synthesized setter/getter with a user defined setter/getter The code pattern which causes these errors always looks like this: // Interf...

Eclipse PropertySheetPage - Can it support a multi line property?

I want to use the Eclipse AdvancedPropertySection which uses PropertySheetPage to display and edit properties, but some of my properties are multi line (e.g. Description). Problem: I can't get the PropertySheetPage to display multi line properties. It displays them as a single line, like this: I tried using WrapTextPropertyDescripto...

How to set value in web.xml using property file

Hi all, I would like to know if there is possibility to set an attribute in web.xml by using property file. For example the web.xml: <context-param> <param-name>Map.MyJNDI</param-name> <param-value>java:comp/env/jdbc/${my.computer}</param-value> </context-param> and application.properties would be : # My computer...

Dynamically create Public Properties

How dan I dynamically create some public properties on a custom webcontrol. For example, web control has 5 TextBox controls. I need a public property for each TextBox control to be able to set a specific property of the TextBox control. I want to be able to loop the controls in the webcontrol and create a public property for each TextB...

spring write back to property file

Is there something in spring where we can write back to an property file ? Lets say , that we have a property "reportname=SOME REPORT". If we have a GUI where the user can change it to "reportname=SOME OTHER REPORT". Then, is there something in spring that can write that value back to the property file ? Also, is there a xml property...

How to make List's Add method protected, while exposing List with get property?

I have a class named WhatClass that has List field in it. I need to be able to read-only this field, so I used a get property to expose it to other objects. public class WhatClass { List<SomeOtherClass> _SomeOtherClassItems; public List<SomeOtherClass> SomeOtherClassItems { get { return _SomeOtherClassItems; } } } However it ...

alloc + init with synthesized property - does it cause retain count to increase by two?

I've seeen the following snippet quite a bit: In the header: SomeClass *bla; @property(nonatomic,retain) SomeClass *bla; In the implementation file: @synthesize bla; and then self.bla = [[SomeClass alloc] init]; I think that this assignment puts the retain count for 'bla' up by two; once through the alloc/init call, then throug...

Making a LazilyEvaluatedConstantProperty class in Python

There's a little thing I want to do in Python, similar to the built-in property, that I'm not sure how to do. I call this class LazilyEvaluatedConstantProperty. It is intended for properties that should be calculated only once and do not change, but they should be created lazily rather than on object creation, for performance. Here's t...