Making the Transition to Clarion 4’s ABC Templates
You now have a vastly improved development tool at your disposal: Clarion 4, with its new Application Builder Class (ABC) Templates and ABC Library. These new tools write Object-Oriented (OOP) code for you using the same template interface that you’ve grown accustomed to in Clarion 2.003. This article provides answers to the most common questions about making the move to ABC/OOP.
So, the first question you’II probably ask yourself (after doing the tutorials in Getting Started and Learning Clarion to become familiar with the new features) is: “How can I leverage what I already know to get up to speed with Clarion 4 ABC as fast as possible?” That’s the overall question that this informal article answers. You’II probably be surprised at how much is still the same, how many resources are at your disposal, and how much more power Clarion has put in your hands with the change to OOP technology.
For those of you who don’t write embedded code (or very little) and mostly let the templates handle all the coding, the answer to the question is: you’re already leveraged, you already know it – just keep on working with Clarion 4 as you always have. You may notice a reduction in the size of your EXEs and an increase in your applications’ performance, but you don’t really care how we achieve that, now do you! This article will be the most benefit to those of you who do a substantial amount of coding for yourselves in embed points.
I’ve heard that OOP is really hard to learn.
Like all generalities, this one has a grain of truth at its core. The fact is that, like all new concepts, it will certainly take some work to really “get” the OOP concepts firmly in place, but it really is not as difficut as it’s commonly made out tobe. lt’s said that “OOP only takes one mimJte to understand, but that one minute might not come for a couple of weeks.” lt just takes a bit of stt.dy and a bit of working with it for yourself to get to the essential “Ah Ha! That’s what OOP is all about” bolt of enlightenment.
The biggest difference between writing OOP versus Procedural code is in how you think about the code you write. As David Bayliss is fond of pointing out, in Procedural code you normally think, “How can I perform this task on this thing?” while with OOP code the thought process should be, “I am a thing. How should I perform this task?” These are very different questions representing very different viewpoints.
For example, a Procedural coding thought might be, “How do I make a window refresh when I want it to?’ while the corresponding OOP thought should be, “I am a window. How do I refresh myself when necessary?” You need to change your perspective frorn an external (doing things to ob,iects) to an intemal ( each ob,iect does its own thing) viewpoint.
To help you learn the basic theoretical concepts of OOP, TopSpeed has two articles in the Programmer’s Guide (this book is on your Clarion 4 CD in the C4-PG.PDF file): “Easing into OOP” and “Object Oriented Programming.” These two articles both explain the fundamental concepts of OOP theory and how they are implemented in the Clarion Language. The Language Reference documentation of the CLASS structure and its related components also covers this same ground in a more formal manner.
OOP, once you’ve leamed the meaning behind all the “buzzwords”, is actually pretty simple – if’s just not very easy at first. The OOP concepts, while simple, are fundamentally different from Procedural coding concepts. That very difference is what makes OOP seem difficult at first, but it is also that basic dfference that gives OOP its power. The result is worth the effort required to attain it.
I’ve heard that the ABC generated code looks very different.
Yes, that’s certainly true. The ABC templates only generate a single line of code (GlobalResponse = ThisWindow.Run()) into a generated PROCEDURE. All the code to accomplish the functionality of the PROCEDURE is contained either in the ABC Library, or in overridden methods of the ABC Library. These…