Abstract property with public getter, define private setter in concrete class possible?

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

What should a C++ getter return

You can provide both const and non-const versions: MyType & MyClass::getMyType() { return mMyType; } MyType const & MyClass::getMyType() const { return mMyType; } I wouldn’t provide a pointer version, since that implies that the return value might be the null pointer, which it can never be in this instance. The real point, however, is … Read more

Lombok getter/setter vs Java 14 record

Lombok, and the record feature of the Java language, are different tools for different things. There is some superficial overlap, but don’t let that distract you. Lombok is largely about syntactic convenience; it is a macro-processor pre-loaded with some known useful patterns of code. It doesn’t confer any semantics; it just automates the patterns, according … Read more

Public Data members vs Getters, Setters

Neither. You should have methods that do things. If one of those things happens to correspond with a specific internal variable that’s great but there should be nothing that telegraphs this to the users of your class. Private data is private so you can replace the implementation whenever you wish (and can do full rebuilds … Read more

Difference between @interface definition in .h and .m file

It’s common to put an additional @interface that defines a category containing private methods: Person.h: @interface Person { NSString *_name; } @property(readwrite, copy) NSString *name; -(NSString*)makeSmallTalkWith:(Person*)person; @end Person.m: @interface Person () //Not specifying a name for the category makes compiler checks that these methods are implemented. -(void)startThinkOfWhatToHaveForDinner; @end @implementation Person @synthesize name = _name; -(NSString*)makeSmallTalkWith:(Person*)person … Read more

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