I don’t know if this is addressed later in the book or not, but I don’t understand why we need both BNRPerson.h and BNRPerson.m files. It seems that the information inside of @interface is repeated inside of @implementation.
I am guessing it has something to do with the way the complier works, but I am just curious if anybody can explain this a little.
Thanks
Sure-
The interface file is like a bill-board, or an advertising space. It says to other objects in your program, “Here are the properties that I have, and the the things I can do.”
The implementation file is private to the class itself- that is where the class keeps its knowledge of how to do those things (the method /implementations/, rather than just their /declarations/, which are in the .h file). It is also a place where additional properties and methods can me put without the rest of the program knowing about them.
In object-oriented programming, there is a philosophy called “separation of concerns”, that dictates that any object show know as little about another object as possible in order to be able to get its job done. The more your objects know about each other, the harder it becomes to maintain your code and fix bugs in the future.