Wednesday, January 28, 2015

What is advantage of categories? What is difference between implementing a category and inheritance? 

. You can add method to existing class even to that class whose source is not available to you. You can extend functionality of a class without subclassing. You can split implementation in multiple classes. While in Inheritance you subclass from parent class and extend its functionality.

In a way you can say that Category are better option than to use inheritance but, The reason inheritance is still exist is you can not add member variables in Category only methods but inheritance makes it possible.

0 comments:

Post a Comment

About

Blog Archive

Powered by Blogger.

Blog Archive