Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 12.3 ('lJLaL')
Instant purchase and download via GumRoad!

COLUMN

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
Resource File(s):

Download Icon 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 do with 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 aPersonClass class 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 annualincome by a certain amount, and return the new object.

...End of Excerpt. Please purchase the magazine to read the full article.