Properties and Instance Variables in Objective-C

前端 未结 5 1133
借酒劲吻你
借酒劲吻你 2020-12-02 05:44

I\'m rather confused about properties and instance variables in Objective-C.

I\'m about half-way through Aaron Hillegass\'s \"Cocoa Programming for Mac OS X\" and ev

5条回答
  •  猫巷女王i
    2020-12-02 06:34

    I would suggest that modern development has made a very strong attempt to identify, define and apply best practices.

    Among these best practices we find continuity and consistency.

    Apart from arguing over use of accessors in init and dealloc methods, accessors should generally be used all the time (inside and outside of a class) for the benefits they offer, including encapsulation, polymorphic var implementations (which both allow for abstracting and refactoring) and to facilitate those best practices of continuity and consistency. The fundamental benefits of an object-orient language come into play when doing things in this way and exploiting the fullness of the language's capabilities. Always being consistent in one's coding is an oft undermentioned benefit, as any senior programmer will usually attest.

提交回复
热议问题