Object Oriented Programming
Posted by Chris on Aug 19, 2010 in Programming | 0 comments
When I first began programming, I learned the old and easy language of BASIC. BASIC was fun and not overly difficult for a novice programmer. I remember I bought a Learn to Program in BASIC CD at one of the book fairs. The CD had plenty of walk-throughs and sample code that let you create interfaces all the way to simple games. This language is known as a “procedural language” which simply means that the program follows a set procedure during execution. The language is very “English-like” and is very easy for nonprofessionals to pick up on. Unlike Object Oriented Programming, Procedural follows a set procedure with commands like GOTO, and GOSUB. By issuing a goto command you are essentially telling your program to jump to this line of code. With OOP you simply call your method with any values you wish to send and voila your method executes. The methods in OOP are similar to functions in PP. With OOP the main focus is on well Objects. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects. Each object can be viewed as an independent ‘machine’ with a distinct role or responsibility. Whereas PP follows a structure of code OOP allows programming logic to be reused by various objects.
Object-oriented programming has roots that can be traced to the 1960s. As hardware and software became increasingly complex, manageability often became a concern. Researchers studied ways to maintain software quality and developed object-oriented programming in part to address common problems by strongly emphasizing discrete, reusable units of programming logic . The technology focuses on data rather than processes, with programs composed of self-sufficient modules (“classes”), each instance of which (“objects”) contains all the information needed to manipulate its own data structure (“members”). This is in contrast to the existing modular programming which had been dominant for many years that focused on the function of a module, rather than specifically the data, but equally provided for code reuse, and self-sufficient reusable units of programming logic, enabling collaboration through the use of linked modules (subroutines). This more conventional approach, which still persists, tends to consider data and behavior separately. (http://en.wikipedia.org/wiki/Object-oriented_programming)
One of the best features of OOP is inheritance. All Object in Objective-C originate from the NSObject class. What does this mean? Simply that all objects inherit the methods and properties of NSObject. By having all objects originate from the same place you can guarantee certain ideas about the objects. If you follow hierarchy tree for various objects you can see where they originate from and what they may conform too. For iSupplement I create a new Object called Supplement. This object has its own class file which defines the attributes, properties, and methods that the object will conform to. Since the Object originates from the NSObject class we know that Supplement has various methods from its parent. With iSupplement my Supplement object is actually a NSManagedObject because the app uses Core Data and sqlite. By making Supplement a child of NSManagedObject it conforms to the methods for our managed object context. Meaning that it can be written to and retrieved from our sqlite database. Now since Supplement is a child of NSManagedObject it also means that it is a child of NSObject (which is a parent of NSManagedObject) so like every object in Objective-C it is able to call [super method]; Which informs the parent to perform its method.
The idea of using objects has allowed very complex programs to reuse programming logic instead of having to follow a set procedure. This makes OOP languages very dynamic and easy to update. I will expand more on these ideas in future posts so chew this over for a while and like always enjoy!
For the comments: what features do you find to be the most helpful in OOP languages?
Related posts:


