Is subclassing in Objective-C a bad practice?

前端 未结 9 803
一个人的身影
一个人的身影 2020-12-13 05:42

After reading lots of blogs, forum entries and several Apple docs, I still don\'t know whether extensive subclassing in Objective-C is a wise thing to do or not

9条回答
  •  醉话见心
    2020-12-13 06:01

    my impression of ADC's emphasis 'against' subclassing has more to do with the legacy of how the operating system has evolved... back in the day (Mac Classic aka os9) when c++ was the primary interface to most of the mac toolbox, subclassing was the de-facto standard in order for a programmer to modify the behaviour of commonplace OS features (and this was indeed sometimes a pain in the neck and meant that one had to be very careful that any and all modifications behaved predictably and didn't break any standard behaviour).

    this being said, MY IMPRESSION of ADC's emphasis against subclassing is not putting forth a case for designing an application's class hierarchy without inheritance, BUT INSTEAD to point out that in the new way of doing things (ie OSX) there are in most cases more appropriate means to go about customizing standard behavior without needing to subclass.

    So, by all means, design your puzzle program's architecture as robustly as you can, leveraging inheritance as you see fit!

    looking forward to seeing your cool new puzzle application!

    |K<

提交回复
热议问题