Rule 9 in Object Calisthenics by Jeff Bay (RTF) is:

Rule 9: No getters/setters/properties

The last sentence of the previous rule leads almost directly to this rule. If your objects are now encapsulating the appropriate set of instance variables but the design is still awkward, it is time to examine some more direct violations of encapsulation. The behavior will not follow the instance variable if it can simply ask for the value in its current location. The idea behind strong encapsulation boundaries is to force programmers working on the code after you leave it to look for and place behavior into a single place in the object model. This has many beneficial downstream effects, such as a dramatic reduction in duplication errors and a better localization of changes to implement new features.

Another way this rule is commonly stated is “Tell, don’t ask”.

I get the point of the rule. But I find it only useful in garbage collected environments where modifying a reference is very simple.

Will this be of any help in Objective C? Because it's always important to let only setter change the ivar and let it also take care of retaining new value and releasing the old one. and use the setter anywhere inside methods to alter ivars which are pointers.

1 Answer 1


I think this rule is about public getters/setters/properties.

It's OK to let objective-c properties handle retaining/releasing providing that you don't make them public. You can use categories to make properties private.

That way you have the best of both worlds:

  • you don't break encapsulation
  • you manage memory properly and easily

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.