(no) Properties in Java?

There is a “standard” pattern for getters and setters in Java, called Bean properties. Basically any method starting with get, taking no arguments and returning a value, is a property getter for a property named as the rest of the method name (with a lowercased start letter). Likewise set creates a setter of a void … Read more

Difference between _ and self. in Objective-C

self.myString = @”test”; is exactly equivalent to writing [self setMyString:@”test”];. Both of these are calling a method. You could have written that method yourself. It might look something like this: – (void)setMyString:(NSString*)newString { _myString = newString; } Because you used @synthesize, you don’t have to actually bother writing that method, you can just allow the … Read more

How to write C++ getters and setters

There are two distinct forms of “properties” that turn up in the standard library, which I will categorise as “Identity oriented” and “Value oriented”. Which you choose depends on how the system should interact with Foo. Neither is “more correct”. Identity oriented class Foo { X x_; public: X & x() { return x_; } … Read more

Java Getters and Setters

I’m not sure if you’d consider it ‘standard’, but Project Lombok addresses this problem. They use annotations to replace much of the verbosity of Java. Some people are looking at alternative Java sibling languages, such as Groovy or Scala. I’m afraid it will take some years -if at all- before the JSR figures out a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)