Interfacing with OOP
Using Interfaces to "Disguise" Objects
Issue: 12.3 (May/June 2014)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 14,008
Starting Page Number: 59
Article Number: 12308
12308.zip Updated: 2014-05-01 11:19:42
Related Link(s): None
Excerpt of article text...
At XDC 2014, I gave a talk on object-oriented programming (OOP). I wanted a quick way to explain one of the most complicated concepts of OOP: class interfaces.
Interfaces are one of the most important aspects of OOP, but also one of the least understood by beginners. Many just starting out completely avoid them. (It doesn't help that Xojo sort of hides the user interface to class interfaces.)
OOP Without Interfaces
What typically happens—this is what happened to me—is that when you first get started with OOP you quickly grok the idea of objects. That metaphor isn't too difficult to understand. What you
dowith those objects isn't terribly sophisticated, but you at least know how to create a class (or subclass), add methods and properties, and create new instances of the class in your application.
For example, you might use objects as a simple data structure. In Figure 1, I've created
aPersonClassclass that holds various properties about that person (name, location, sex, income, etc.). I've also create a simple array of
people()to hold such objects. Again, not sophisticated but simple and it works.
What happens next is that as this beginner's program grows, new methods are added to manipulate these "people" objects. At first this is simple: a method might accept a person object, increase the
annualincomeby a certain amount, and return the new object.
...End of Excerpt. Please purchase the magazine to read the full article.