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.5 ('Yosemite')
Instant purchase and download via GumRoad!

COLUMN

Expanding Objects

How OOP can make enhancing your software easy

Issue: 12.5 (September/October 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): 28,529
Starting Page Number: 48
Article Number: 12508
Resource File(s):

Download Icon 12508project.zip Updated: 2014-09-05 10:52:40

Related Web Link(s):

http://www.xdevmag.com/downloads/xdc2014movies.zip

Excerpt of article text...

At XDC 2014, I gave a talk on object-oriented programming (OOP). My idea was to encourage people to use more OOP. The analogy I used is that OOP is like getting enough exercise or eating enough healthy foods: we all do some of that, but we can all do more. Too much of the time OOP feels like it's too much work to set up, so I showed an example of how OOP can really save you time.

For the presentation, I created a bare bones drawing program called SimpleDraw. I then gave the audience a choice of three tools for me to add during the session: a rounded-rectangle, picture box, or text tool. Because the program was object-oriented, adding a whole new tool only requires a few lines of code: most of the functionality is inherited from the previous tools!

For today's column, I'll walk you through some of my code and show you what I did.

SimpleDraw

Let me say that while "simple" is in the name, SimpleDraw is actually a pretty sophisticated core of a drawing application (see Figure 1). It already supports things like the selection of and movement of objects, zooming in and out, colors, object opacity, and even moving drawn objects forward or backward (layering). Granted, there's tons more needed for a "real" (saleable) drawing application, but the basics are here (see Figure 2).

The cool thing is that with the basic template built, you can now easily expand SimpleDraw. It's really easy to add new types of drawing objects (which I'll show you how to do today), but since all objects are built on a platform, you can even add new features to all the objects.

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