Understanding the difference between __getattr__ and __getattribute__

Some basics first. With objects, you need to deal with their attributes. Ordinarily, we do instance.attribute. Sometimes we need more control (when we do not know the name of the attribute in advance). For example, instance.attribute would become getattr(instance, attribute_name). Using this model, we can get the attribute by supplying the attribute_name as a string. … Read more

What is the visibility of @synthesized instance variables?

A synthesized ivar is completely invisible to all code that cannot see the @synthesize line (which basically means anything outside of the .m file). It’s not @protected, it’s not @private, it’s simply unknown. With a @private ivar, other code trying to access it will be told that it’s private, but with a synthesized ivar, other … Read more

How to choose between private and protected access modifier to encapsulate members between base and childs classes?

Why don’t I have an error message, when I set ID value in daughter class, the sentence this.id=value is executed, but how can can I access to it from my child class if it is private? When you call a public method on a class, that method can access private members of that class: public … Read more

Effective C++ Item 23 Prefer non-member non-friend functions to member functions

Access to the book is by no mean necessary. The issues we are dealing here are Dependency and Reuse. In a well-designed software, you try to isolate items from one another so as to reduce Dependencies, because Dependencies are a hurdle to overcome when change is necessary. In a well-designed software, you apply the DRY … Read more