![]() |
|
Published 1999-10-20 Printer-friendly version
Sometime during the alpha of C4....
David Bayliss: "With overriding and the new priority settings of embeds, you have, in essence, an infinite number of embed points."
LarryTeames: "Just not where we want them."
You know, I really hate TV dinners. I mean I despise them. What could be worse?
For those of you who don't know what I mean by TV dinners, let me try to explain. Around 40 years ago, a man named Clarence Birdseye experimented with freezing prepared food. The Swanson company took his research and came up with an individual meal all precooked and frozen. All you had to do was pop it into the oven for about 30 minutes and voilà, instant meal. The name "TV Dinner" was used because the marketers envisioned consumers glued to the front of their television sets and not wanting to spend a lot of time fussing over the stove. This was a meal you could prepare and eat and never miss a minute of television time.
TV Dinners come in a foil container with a foil lid so you never even have to open it or see it until it is done. And that is exactly what makes me hate them so.
You see, you're stuck with whatever is inside. Let's say you bought the great American meal, the turkey dinner. There is a bit of turkey meat with gravy in the first compartment, mashed potatoes with butter in the second, and green peas in the third. It has already been cooked, already seasoned, the choice of side dishes has been made for you. You really have no control. You may be able to sprinkle a little seasoning on it after you take it out of the oven but that's about it. How bland! How boring!!
What if you wanted to put a little bacon in those potatoes? The flavor will never be the same as it would have been if you actually cooked the bacon with the potatoes. Or maybe you wanted a white sauce and this sauce is brown. And did they stuff the turkey with the seasonings you enjoy so much? And what if you're allergic to peas?
That's the beauty of cooking things yourself. You can alter the combination of foods. You can add just the seasonings you like. And this process doesn't stop at the initial preparation. You can alter the recipe as you are cooking! Not salty enough? Add a little. Notice that the tomato plants in the garden have some ripe tomatoes? Just add them in. You have an infinite number of places that you can alter your cooking plan.
I think that is the reason why a lot of us like Clarion so much. The IDE in conjunction with templates, the wizards, and soon the wizatrons, generate a nice skeleton application. I can then interject my own code in various places to get just the flavor I'm looking for.
But can I really? Can I put my code anywhere? Is that a TV dinner I smell in the oven when the Clarion splash screen pops up?
I began using Clarion for Windows when it was first released in version 1.0. That was the beginning of the Legacy templates. The templates had those marvelous embed points scattered throughout. They had nice labels. I was really productive using them.
But times changed. The templates were modified, enhanced, enlarged, and made more complex. And I found that with my apps, I really couldn't place my code exactly where I wanted it. So, I began coding embed points with the OMIT statement. And dropping in IF tests to avoid executing some of the Legacy code. I was cutting and pasting generated code into my own embed points. Then, some of the embed points had very similar names. The embed points weren't documented so the only way I could learn what they did was to stuff some code in there and read the generated code.
Embeds in legacy provided you with an easy way to interject code but were poor in providing you with a mechanism to replace or enhance code.
There were some routines in most procedures but there were no embed points mapped directly to them. In other words, you couldn't tell exactly what routine you were modifying or where by adding embed code.
I could modify the templates and place my own embeds into the system. But there the maintenance nightmare began. Each new version of Clarion would force me to study the templates and repeat all my changes.
A procedure with only a window in it has about 61 embed points and 107 lines of code. That works out to an embed every 1¾ lines. When you're designing a splash screen 61 embed points are a lot. But that is a horribly small number when you are writing apps that have hundreds of controls on a single window. There are complex things happening that you really need to get inside of.
I could still do what I wanted to do but my productivity was falling as I wrote apps that were nontrivial.
Then along came ABC and the newer IDE. Everything looked so familiar and yet all of the old rules went out the window.
A procedure in ABC with only a window has about 240 embed points and 58 lines of code. That works out to an embed point every ¼ line of code. That is a seven fold increase over the legacy templates. How is this possible?
Because most of the work is now being done in classes, there is far less source code generated. These classes rely on methods (which are procedures) to do all of the work. There are few, if any, routines generated in your source. So does less code mean fewer opportunities to embed code? Did Topspeed give us less power with ABC? Nope. OOP comes to the rescue.
OOP allows you to override any method. This means that you can put your code in place of the code Topspeed has written and have it executed instead. No more OMIT. No more bracketing code with IF tests. This kind of functionality is built directly into an OOP language and ABC and the IDE take advantage of it. Every time you write embed code, you're really replacing a method that Topspeed has written with your very own. The code is custom and does what you need because you have written it.
But wait - if it replaces Topspeed's code, you don't want to rewrite everything, do you? The early alpha testers complained that putting a single line remark in an embed point caused a procedure not to execute. That remark literally replaced an entire method, and that method may have been an entire browse. But the templates do a really nice thing for you. They automatically insert a bit of code that says:
ReturnValue = PARENT.MethodName
This calls the original method, the Topspeed code, for you. So
you now have the power to write embed code before and after
Topspeed's code. All you have to do is place your code either
before or after the call to the parent's method. This means
two embed points per method, a before and an after. And you can
avoid Topspeed's code by placing your code before the parent
call and RETURNing before the parent is called.
You'll even notice that the procedures have template generated code that overrides the default behavior of the classes. Topspeed's templates are using the power of overriding and embedding just as you the programmer are.
Associating each embed with a method has a lot of other great side effects also. It means that you have an easy way to relate the embed point back to the generated source. If you can read the method name, you can easily search the generated source for that method and find your embedded code.
You don't have to cut and paste anymore either. You can just type:
Object.MethodName
And off you go, calling Topspeed's code where ever you feel like it. No more finding out that Topspeed fixed a bug in the generated code and you have to find everywhere you pasted it to fix it manually.
It also means that each embed point is easy to document. The method name can be descriptive but also easy for you to match up in the Application Handbook. The Application Handbook is the one Clarion manual I read every single day. It is rich in information that teaches you how methods relate to each other, how different ABC objects relate, and it has code examples that show you how the methods are used. It is available in PDF format on your Clarion 5 CD. I keep it installed on the hard drive of my development machines and I have a shortcut to it on the toolbar.
The IDE also has the Embeditor. With it, you can see your embed code in the context of Topspeed's code. Now you can really see exactly where your code is going to be and how it interacts with Topspeed's.
The IDE has priority settings for embeds also. You can think of
these as a mechanism to have "sub embeds" to the regular embeds.
And this gives you the power to insert embedded code between the
template generated bits that Topspeed is using to override the base
classes. The call to the parent method is always at priority 5000
so you know your code is before it if your priority is less than
5000 or after it if your priority is greater than 5000. But other
methods have even more code and more priority embed points. The
Init method for a window has priority settings at the
Open Files point, Open the window point, and a host of other
places.
I know, you like those old familiar embed names. Well, those are still there for you too. While in the embed tree, just press the button that looks like the Clarion for Windows 2.0 icon. Instant legacy embed points! And they are scattered throughout the ABC classes and embed points. This means that now you have an interactive tool that can teach you how your old embed points have changed and what their ABC equivalents are.
And this brings me to the two quotes at the top of the article. The dream of any Clarion programmer is to be able to embed code anytime, anywhere. This implementation of the IDE, classes, and templates does not do that. The developers at Topspeed's Development Centre will tell you that they don't want you to get between every little bit of code because you could break something. I feel that with powerful tools, there are always going to be dangerous ways to use them. We need to be given the choice and the power to touch every piece of code.
But there is a conflicting issue. The classes themselves may not be the final version we will see. Already, core portions of ABC have been totally rewritten between C4 and C5. The reason Topspeed could do this and not break all of our existing code is that the ABC methods have a defined and documented interface. As long as they give you the same interface and embed points, it is very easy for them to change the world around you and never have you miss a beat. But this implies that we don't step in those areas that they want to change.
Clarion isn't a home cooked Cajun meal if you're using ABC and the templates. But, in its current form, it is a far cry from a TV dinner and many miles ahead of Clarion for Windows 2003. Think of it as a care package from your mother. She cooks up some gravy, some soup, a little crawfish etouffee, some gumbo, and she freezes each in a separate container. You can just heat those up when you're hungry and you know it is going to taste better than you could ever make it. And she includes some Cajun sausage and some crawfish tails so you can cook some things for yourself. You can choose to mix and match what you are going to heat up and even cook something fresh yourself to go with it. And it tastes so good.
I always include a little lagniappe in every article. Lagniappe is that something extra someone gives you that you weren't expecting but that you can enjoy.
This time, it is a jambalaya recipe (pronounced jum buh LI uh) with plenty of embed points. You can choose exactly what you want to change and what you want to go in it. There are suggestions of various things you could use. And there is room for you to add your own ideas.
The Anti-TV Dinner
Recipe:
Chicken and Sausage Jambalaya
Okay. First, here's the recipe in standard form. Let's call this the Clarion ABC Wizard version.
3 cups chicken breasts
1 pound smoked pure pork sausage
2 large onions
1 large bell pepper
2 cloves of garlic
1/2 bunch green onions
2 8 ounce cans tomato sauce
1 can stewed whole tomatoes (Rotel)
2 cups raw rice
salt, cayenne pepper, black pepper
2 tablespoons butter
waterCut chicken up into bite size pieces. Season with salt, cayenne pepper, and black pepper. Brown chicken in pot with melted butter. Remove chicken. Drain any oil or drippings. Chop onions and bell pepper. Cut garlic finely. Brown onions, bell pepper, and garlic. Add tomato sauce and stewed tomatoes. Simmer 15 minutes. Add chicken and sausage cut into bite size pieces. Cook until chicken is tender. Add raw rice and chopped green onions. Stir ingredients thoroughly. Add enough water to cover ingredients by about 1 inch. Bring to a boil. Cover and cook on low heat for 30 minutes or until rice is tender.
Now for the embed points and overrides...
The chicken breasts are great if you are a non Cajun worrying about your diet. I would substitute 3 cups of cubed pork roast.
Or you could use duck instead of chicken for a richer flavor. You could even use seafood - shrimp or crawfish. Crawfish jambalaya is very good.
I like pure pork sausage because of its rich flavor. There may be reasons that you cannot eat pork (like religious ones) so you could substitute with turkey sausage.
If butter isn't at hand, margarine can be substituted.
Some folks don't like to use tomato sauce or stewed tomatoes. Try 24 ounces of chicken broth along with a little thickening agent like flour or arrowroot.
Maybe you don't have any chicken broth and arrowroot lying around. 3 cans of mushroom soup can suffice just fine.
Now, you've gone from a tomato chicken jambalaya to a crawfish and mushroom sauce jambalaya or a pure pork jambalaya, hold the garlic please!
Add what you like, leave out what you don't. That's the beauty of cooking on your own. You can adjust your recipe at any time. Try thatwith a TV dinner! And that's exactly what Clarion and ABC gives you: the ability to override or embed your own desired flavor at any point.
Andrew Guidroz II, when he isn't traveling around the countryside watching his 2004 National Champion LSU Fighting Tigers, writes software for all facets of the insurance and finance industries. His famous Cajun cookouts have become a central feature of Clarion conferences throughout the U.S. Andrew's Cajun website is www.coonass.com.
Copyright © 1999-2008 by CoveComm Inc. All Rights Reserved. Reproduction in any form without the express written consent of CoveComm Inc., except as described in the subscription agreement, is prohibited.
Clarion Magazine ISSN 1718-9942
One year: $159
(reg $189, save $30)
(includes all back issues since '99)
Renewals from $109
Two years: $249
(reg $289, save $40)
Renewals from $199