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
12508project.zip Updated: 2014-09-05 10:52:40
Related Web Link(s):
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
someof 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.
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
...End of Excerpt. Please purchase the magazine to read the full article.