accessors

Objective-C, class abstraction and accessing those variables

I have a lot of experience with java and c++ development, so classes and abstracting data is pretty easy for me. I only started objective C a short time ago, and i was mostly working with in class globals, and everything was progressing smoothly. I just decided to abstract a large portion of my code in an effort to make it less spaghetti...

acces members in a private class

Hello I have a situation when I need to access the private members of a class in an embedded private class. How can I do it efficiently. public partial class Form1 : Form { // this private label will be used only in this form private class MyFormLabel : Label { MyFormLabel() { this.BorderStyle ...

What is the point of defining Access Modifiers?

I understand the differences between them (at least in C#). I know the effects they have on the elements to which they are assigned. What I don't understand is why it is important to implement them - why not have everything Public? The material I read on the subject usually goes on about how classes and methods shouldn't have unnecessa...

Access owner members in a nested class

Hello. I have a special label in my form, that should show in a tooltip some text. The label is declared as private class in the form (nested control), and should "see" the ToolTip control of the parent form. Here is the code. Surely, I obtains errors here, because the constructor is called before the private control addition in the ...

Should I access Ivars directly within a class implementation?

I've been sort of on the fence on this one for a while, but I'd like to know what people think about accessing instance variables directly from within an Objective-C class implementation? Using accessors and mutators makes a lot of things easy, but for simple things, is it bad to access the instance variable directly? Is the best practi...

static/Shared in VB.NET and C# visibility

Hello. I have faced with a situation in VB.NET and C# (.NET2) with the visibility of the static/shared members. It seems to me a little strange in VB.NET: public class A { private static A instance; public static A Instance { get { return instance; } } public string Name {...

Setting a value in one entity programatically from another entity. Core Data questions...

I'm fairly new to Core Data, have looked through many tutorials and forums and haven't found the elegant solution to my problem: I've got three entities in my model: Worker, Task, and SubTask. Each has a to-many relationship to the entity below it and a to-one inverse. Worker has many Tasks, each Task has many SubTasks, each SubTask has...

How to use getters and setters in PHP domain objects and transfer them correctly with Zend_Amf

I just started to use Zend_Amf and thus far I'm really happy with it for sending objects from Flash to the server. Sending my objects from the server back to my Flash environment is causing me a slight headache. My PHP objects mostly contain private properties that have a custom getter and setter method. How do I make Zend_Amf aware of t...

How do I safely access the contents of an NSArray property from a secondary thread?

I have an app (using retain/release, not GC) that maintains an NSArray instance variable, which is exposed as a property like so: @interface MyObject : NSObject { NSArray* myArray; } @property (copy) NSArray* myArray; @end I want to access the contents of this array from a secondary thread, which is detached using -performSelector...

How to implement this feature in PHP?

When accessing member that doesn't exist, automatically creates the object. $obj = new ClassName(); $newObject = $ojb->nothisobject; Is it possible? ...

Can I create accessors on structs to automatically convert to/from other datatypes?

is it possible to do something like the following: struct test { this { get { /*do something*/ } set { /*do something*/ } } } so that if somebody tried to do this, test tt = new test(); string asd = tt; // intercept this and then return something else ...

C++ wrapper with overloaded = operator

I'm trying to develop a pretty simple (for now) wrapper class around int, and was hoping to overload the = operator to achieve something like the following: class IntWrapper { ... private: int val; } int main ( ) { IntWrapper a; int b; a = 5; // uses overloaded = to implement setter b = a; // uses overl...

C#: How do I change accessibility on an accessor using CodeDom?

In C#, you can have more restrictive accessors on the accessors of a property like this: public List<String> Name { get; protected set; } How can I accomplish this when generating code using CodeDom? ...

Compiler optimization of repeated accessor calls

I've found recently that for some types of financial calculations that the following pattern is much easier to follow and test especially in situations where we may need to get numbers from various stages of the computation. public class nonsensical_calculator { ... double _rate; int _term; int _days; double mont...

In C#, can I hide/modify accessors in subclasses?

I'm not even sure what this principle is called or how to search for it, so I sincerely apologize if it has been brought up before, but the best way to do it is with an example. class Properties { public string Name { get; set; } } class MyClass { class SubProperties: Properties { public override Name { ...

How do you use the LINQ to SQL designer to generate accessor methods for subclasses?

Above is the LINQ to SQL designer view for my data context. Below is the relevant code that the designer generates: Accessor for the abstract ActivityBase class: public System.Data.Linq.Table<ActivityBase> ActivityBases { get { return this.GetTable<ActivityBase>(); ...

Empty accessors do matter? Regarding value types and their modification

Hi, I have following code that does not work due to "a" being a value typed. But I thought it would not work even without accessors, but it did: class Program { a _a //with accessors it WONT compile { get; set; } static void Main(string[] args) { Program p...

Why Automatically implemented properties must define both get and set accessors.

When we define a property like public string Name {get; set;} dot net can make our properties code. but when we use public string Name {get;} public string Name {set;} we face with 'Hajloo.SomeThing.PropertyName.set' must declare a body because it is not marked abstract or extern. Automatically implemented properties ...

What do you call functions which get and set?

The jQuery framework has a lot of functions which will either retrieve or mutate values depending on the parameters passed: $(this).html(); // get the html $(this).html('blah'); // set the html Is there a standard name for functions which behave like this? ...

C++ return a "NULL" object if search result not found

I'm pretty new to C++ so I tend to design with a lot of Java-isms while I'm learning. Anyway, in Java, if I had class with a 'search' method that would return an object T from a Collection< T > that matched a specific parameter, I would return that object and if the object was not found in the collection, I would return a NULL. Then in m...