IsMemberOfClass Terminology - Why is it called as it is?

I have to read this by saying that I came from a Java / Android background that colored my understanding of the word “member”. However, I am starting to learn Objective-C, and I came across the isMemberOfClass method, and that confuses me.

I understand that isMemberOfClass returns a boolean value indicating whether the receiver is an instance of this class. However, I do not understand why it is called isMEMBER when it checks if it is INSTANCE.

Is there anything about the language protocol that I don’t know that it makes sense to call it that? Does the element have something different in Objective-C than in Java?

As I understand the definition of a member, this is something of a HAS class (method or data), and not something like an IS class (type).

Can anyone clear this seemingly strange naming convention for me? Thanks for helping the newbie!

+4
source share
3 answers

The concept of a member as a component of a class (method or data) does not exist within iOS. The framework is also built around detailed and often long method or variable names to promote “added readability” (in quotation marks because this is not always necessarily the result).

It can easily be called isInstanceOfClass , but it can cause some confusion with subclasses. isMemberOfClass simply turns out to be a simple method name that does not isMemberOfClass with any principles of the iOS structure and is understandable. I do not think logic goes beyond that.

+2
source

I believe that the term “member”, used to mean either an instance variable or a method (sorry, member function) is returned to C ++. I personally have never heard that it was used with Java, but my hearing may not be the best.

Objective-C is almost everything that C ++ is not - and vice versa. Objective-C has historically been based on and inherits most of this environment capable of doing things. Alan Kay, one of the “inventors” of Smalltalk, quotes the words “I invented object-oriented programming, and C ++ is not what I had in mind” to illustrate the feelings between the two camps.

So, to answer your question: Yes, “member” has a different meaning in Objective-C and C ++, and don't be surprised if you find other words with different meanings when you delve into Objective-C.

+2
source

Source: https://habr.com/ru/post/1502099/


All Articles