In VB6 what is the difference between Property Set and Property Let?
Property Set is for objects (e.g., class instances) Property Let is for “normal” datatypes (e.g., string, boolean, long, etc.)
Property Set is for objects (e.g., class instances) Property Let is for “normal” datatypes (e.g., string, boolean, long, etc.)
I don’t see why an interface can’t define getters and setters. For instance, List.size() is effectively a getter. The interface must define the behaviour rather than the implementation though – it can’t say how you’ll handle the state, but it can insist that you can get it and set it. Collection interfaces are all about … Read more
What do you want to do with your custom setter? If you want the class to do something before/after the value is set, you can use willSet/didSet: class TheSuperClass { var aVar = 0 } class SubClass: TheSuperClass { override var aVar: Int { willSet { print(“WillSet aVar to \(newValue) from \(aVar)”) } didSet { … Read more
This is currently possible in environments with Proxies. That would be node > 0.6 run as node –harmony_proxies or >0.7 with node –harmony. Chromium Canary (not sure if it’s out of that yet) in about:flags at the bottom, experimental javascript. Firefox has had it for a while with no flags. So this probably won’t work … Read more
The WPF binding engine calls GetValue and SetValue directly (bypassing the property setters and getters). You need the property to be there so it can be supported in the XAML markup (and compile correctly).
Set and Get methods are a pattern of data encapsulation. Instead of accessing class member variables directly, you define get methods to access these variables, and set methods to modify them. By encapsulating them in this manner, you have control over the public interface, should you need to change the inner workings of the class … Read more
I don’t have a problem with Holub telling you that you should generally avoid altering the state of an object but instead resort to integrated methods (execution of behaviors) to achieve this end. As Corletk points out, there is wisdom in thinking long and hard about the highest level of abstraction and not just programming … Read more
Unfortunately, you can’t do exactly what you want. You can do this with interfaces though: public interface IInterface { string MyProperty { get; } } public class Class : IInterface { public string MyProperty { get; set; } } The way I would do it is to have a separate SetProperty method in the concrete … Read more
You should use the constructor approach, when you want to create a new instance of the object, with the values already populated(a ready to use object with value populated). This way you need not explicitly call the setter methods for each field in the object to populate them. You set the value using a setter … Read more
I think a bit of code will help illustrate what setters and getters are: public class Foo { private string bar; public string GetBar() { return bar; } public void SetBar(string value) { bar = value; } } In this example we have a private member of the class that is called bar. The GetBar() … Read more