If you do not have a computer science background, wading through the lingo of programming tutorials can be a challenge. So I took a detour in my app creation efforts to tackle some key terms to increase my understanding.
If you want to program an app for the iPhone or iPad using Apple’s Objective C programming language, it might help to back up and understand how object oriented programming is different from conventional programming. Why did Apple choose this language? What are its roots? How does it power the overwhelming response to app development for iDevices, which are pouring into the App Store at a tremendous rate?
Busting out books and searches on “Conventional Programming” and “Object Oriented Programming”, I discovered that conventional programming stems from a sequential list of tasks or commands. So the more complex programs become, the larger and more interdependent the code is to untangle if there is an issue. What comes to mind is a super long scroll like back in the olden days. If I had to reference something, I’d have to unroll the entire scroll.
Another approach is to chunk things out and organize them into similar groupings. This is where object oriented programming comes in, which segments code into discrete units that can be reusable. Each unit seems to have some sense of autonomy, like a set of instructions on how it can be put into action.
As soon as you start an iPhone programming tutorial, words like Method, Class and Object will come your way. When you look up a standard definition in a programming book, the non-programmer will come across something unhelpful like: “Object: A class that has been invoked and is active in your code.” Now, instead of having one term I don’t understand, I have two terms I don’t understand.
Thankfully, there are some Java tutorials (Java is an object oriented language) that provide real world analogies. I studied these real world analogies while looking at my unhelpful cat – and several of the concepts finally clicked into place!
CLASS: I think of class as a “type of thing”, like the blueprint from which a thing is created. My cat comes from the “cat” class. This class has certain characteristics, such as four legs, fur and whiskers. This class also has subclasses, which I’ll address further in “inheritance”.
OBJECT: A real world object, like my actual cat, which is a specific instance of the “cat” class. Objects have a state (purring) and a behavior (lazy and mainly concerned about food or birds). If I could package my cat into a data structure complete with instructions about its state and behavior, then I would have an Object in the world of object oriented programming.
METHOD: A method is how the object behaves or functions, like a command that the object can perform. My cat likes to bat the mouse toy. So my understanding is that a “bat the mouse” Method would make my cat bat the mouse toy.
INHERITANCE: The ability to re-use or to share code between classes. So for example, if my pet cat is from the Cat class, it has some of the same properties as a Lion, which is also from the Cat class. However, my cat is from the Domestic subclass, and the Lion is from the Big Wild Cat subclass. The similar properties (four legs, whiskers, tail) are all part of the Cat class. The differences (meow vs. roar) are instances where the behavior of the subclass overrides the default behavior in the class.
After finally getting a sense of Object, Method and Class, I ran into more terms, like Array and and String. I believe these are general programming terms, but once I started with a real-world example it was hard to stop…
ARRAY: A collection of cats, like the figurines my daughter has in her toybox. A systematic way of organizing all of those little plastic cats so they aren’t strewn all over her room.
STRING: A string is a set of characters (numbers, letters, symbols) like the ones in our names or on a label. The string/s for my cat are Oreo, Kitters, or simply, The Cat.
I hope you enjoyed reading this excursion into terminology as much as I enjoyed writing it. Please don’t believe anything I say until I run it by a few of my programmer friends and get their validation or edits on the above.