User Tools

Site Tools


clarion_programming_concepts.htm
Navigation:  User's Guide and Tutorials > Getting Started with Clarion! >====== Clarion Programming Concepts ====== Previous pageReturn to chapter overviewNext page

At the foundation of Clarion (the development tool) is the Clarion programming language'a fourth-generation, general-purpose (fully object-oriented) programming language, which has been highly optimized since its inception for business (database) application development. The Clarion language is the real tool that you now hold in your hands. But Clarion is much more than just the Clarion language'it is also a complete toolset designed specifically for business database application creation and maintenance.

On top of the Clarion programming language is the Clarion development environment'a completely integrated set of tools that are specially designed for Rapid Application Development (RAD), Rapid Application Maintenance (RAM), and Rapid Application Enhancement (RAE). These tools are all geared towards generating Clarion language source code for you, so you don't have to write it yourself. That's what makes Clarion so powerful'although you can write your own Clarion language code, the toolset can generate (and re-generate) most “standard” code for you, leaving you free to concentrate on your application's design issues.

Levels of Abstraction

There is a principle that, the further you can get away from the “bare metal” of the computer (pure binary), the more productive you can be.

A Bit of History

The very first digital computers were programmed in binary, one machine langauge instruction at a time, and the programmer's job was very difficult. Then Assembly language came along to make the programmer's job easier by making the program code readable by a human being. Each Assembly language statement generated exactly one machine instruction.

Early Assembly programmers noticed that they were consistently writing the same sequences of instructions to perform standard tasks. Therefore, they created Third Generation languages (3GL'like Fortran, C, PL/1, etc.) so that each 3GL statement would generate multiple machine instructions for these standard tasks and make programmers more productive. By doing this, they started operating at a higher level of abstraction away from the “bare metal” of the computer. The drawback was that only “standard” sequences of machine code were generated, so some of the total flexibility that's possible when you work directly in Assembly language was lost.

Present Day'4GL

This same basic process has occurred to bring about the advent of Fourth Generation languages (4GL) like Clarion. For example, the Clarion language automatically handles all the standard Windows chores (such as re-painting the screen) that programmers are required to write for themselves in 3GL languages. In Clarion, a “Hello World” program is just 9 lines of source code, while in C/C++ you must write over 80!

The Secret of Productivity

The Secret of Productivity (you've all heard this before) is working smarter, not harder. That is exactly what Clarion is designed to allow you to do with its Template-driven programming paradigm'Clarion writes the standard code for you so you don't have to write it yourself, and then it is still flexible enough to let you add the “bells and whistles” (the fun part).

The secret to real programmer productivity without loss of flexibility is this: always operate at the highest level of abstraction that can get the job done the way it needs to be done. The “problem” with operating at higher abstraction levels is the loss of flexibility to always do things exactly the way you want. With Clarion, this problem is solved.

The Clarion toolset contains multiple abstraction levels'allowing you to always operate at the best abstraction level to do exactly what you need to do. You're never “stuck” at a high level or forced to always “muck around” at a low level. The toolset generates object-oriented Clarion source code for you using Clarion's Application Builder Class (ABC) Library (the high level), and when you need to, you can also add your own code (lower level) to augment the standard template-generated functionality.

Generally speaking, the higher the level of abstraction a programmer works at, the more productive they can be. At each higher abstraction level, the programmer becomes more productive by letting the computer do more of the work for them'generating standard code for standard tasks. This is the fundamental principle behind Clarion'and we implement this principle through Template-driven programming.

Template Driven Programming

Clarion's Application Generator is “template driven.” This means that it is a tool that changes based on the requirements of the template you are using to generate your code. Clarion's Procedure, Control, Extension, and Code Templates all write Clarion language source code for you, giving you a tremendous productivity boost. Clarion's templates provide many of the benefits of object-oriented programming, especially reusability, and the default template set generates truly object-oriented Clarion code for you using the Application Builder Class (ABC) Library. This makes Templates the real key in Clarion to Rapid Application Development.

What is a Template?

In Clarion, a template is not just a “one-time” tool generating code that you must then maintain yourself (like the things that some other languages call “templates”), but is a continually interactive tool that asks specifically for the information it needs to generate your source code. Changing the information you provide to the template causes different source code to generate the next time you make your application. This interactivity makes Clarion's Templates the key to Rapid Application Maintenance.

Clarion templates allow you to insert your own Clarion source code into their generated source at any of the many Embed Points available to you within each template. This makes it unnecesssary for you to maintain all the generated code in order to customize the procedure's behavior. It also guarantees that your special customizations aren't overwritten the next time you generate source'the template simply generates your code inside its standard code. This easy customization makes Clarion's Templates the key to Rapid Application Enhancement.

All the templates are stored in the registry file (TemplateRegistry.TRF). This file contains the pre-written executable code and data structures which you customize and reuse. You can use the Template Registry to modify the design of each template's default window or report to the way you want them to appear when you first create a procedure.

You can modify the Clarion templates. You may also add third party templates, or write your own, and use them in addition to, and along with, the Clarion templates. This makes the Application Generator an infinitely extensible tool.

How do you use Templates?

When you create a new procedure, you identify the Procedure template that generates code that does the task you need to perform, then you customize it with the development tools. These Procedure templates include elements such as “browse windows” for viewing groups of rows, and “form windows” for editing one row at a time. If the procedure is for a window with a menu, the menu actions are automatically added to the application's procedure tree, and marked “ToDo,” as any other procedure call would be.

The usual way to customize a procedure is to call one of the formatters. The Window and Report Formatters are visual design tools that allow you to “point and click” to design windows and reports. You just pick a control from a toolbox, click to place the control, then right-click to modify its properties.

Once you have created a procedure you can also use the Control, Extension, and Code templates to add even more functionality to the procedure. Control templates contain controls and generate all the standard executable code needed to use and maintain them. All the pre-populated controls that appear in the default window designs for the Procedure templates are actually Control templates that perform all the functions of the procedure.

Extension templates add executable code that increases the functionality of the procedure. Each typically provides you with on-screen instructions on what information to “fill in” to incorporate its functionality into the application.

Another way you may customize a procedure is to add your own embedded source code. The Application Generator displays a tree displaying all of the Embed Points that you have: before, during, and after the procedure's main logic, and for every event the window or controls in the procedure can generate. You can also directly edit your embedded source within the context of all the generated source code. This allows you to pick the precise logical point at which to execute the code, then “hand code” it, or tell a Code template to write code for you. The Application Generator generates all your application's source code from the templates and all your customizations (including embedded source code).

Clarion provides a rich assortment of standard templates with which you can rapidly develop applications. Just as the Quick Start lesson introduced you to the Wizards, the Application Generator lesson in the Learning Clarion document introduces you to using Clarion's Templates to produce any Windows application you need.

Clarion's Levels of Abstraction

At this point in your introduction to Clarion, you've already worked with Clarion's highest abstraction levels: the Wizards. You'll work with most of the following features later in the Learning Clarion lessons.

Dictionary Editor and Dictionary Diagrammer

Your Data Dictionary is a single repository for all the table definitions and their default data entry control settings. For existing data, defining your tables can be as simple as importing the table's definition into the Data Dictionary directly from the table itself!

Application Wizard

Generates a complete “standard” application for you in just minutes, based on the table definitions and settings in your Data Dictionary.

Procedure Wizards

Generate “standard” procedures for you (like a Browse list, or data entry Form) based on the settings in your Data Dictionary.

Procedure Templates

Generate “standard” procedures for you (such as the application Frame menu, or a Report), based on the window or report design you create in Clarion's Window Formatter and Report Formatter, and the options you select for the Template's prompts for information about your procedure.

Control Templates

Add “standard” controls to your window or report design (such as a related tables Tree control) and generate all the code needed to “drive” the behavior of the control.

Extension Templates

Generate additional code into a procedure to provide functionality unrelated to any specific window control (such as a Date/Time display in the application Frame's status bar).

Code Templates

Generate code into a procedure that usually performs a single task related to a specific window control (such as Data Entry validation).

Embedded Source Code

You can write Clarion language source code of your own in any of the very numerous Embed Points in each procedure to customize and/or modify the behavior of the Template-generated code.

Source Template

A Template which allows you to completely write your own Clarion language procedures while still maintaining the application in the Application Generator.

Windows API and C Standard Library

In any Clarion language code that you write (whole procedures or into Embed Points), you can directly call Windows API functions or C standard library functions, if you really need to. A utility program will generate the Clarion language Windows API function prototypes, and C Standard Library prototypes are documented in the Programmer's Guide.

C/C++ or Modula-2 Code

Write any SoftVelocity C/C++ or Modula-2 functions that you need to and link them into your Clarion application. These compilers are included and are invoked by simply adding a .C, .CPP, or .MOD source code module to your Clarion project (also sold separately).

As you can see, the levels of abstraction available to you in Clarion span every level from the Application Wizard right down to writing C code (or even Assembly, if you want to work that hard).

The Clarion Key to Maximum Productivity

The key to making Clarion work for you is to always work at the highest abstraction level possible:

blueck.jpg Let the Application Wizard write a “starting point” application for you.

blueck.jpg Use the Procedure Wizards to add new procedures, as needed.

blueck.jpg Modify what you need to in each Procedure Template using Clarion's two-way interactive tools (like the Window and Report formatters).

blueck.jpg Add Control, Extension, and Code Templates as you find you need their functionality.

blueck.jpg Customize it all with some Embedded Source Code.

blueck.jpg When you find you need to do something that no template does for you, use the Source Template and write it in the Clarion language (or get a third-party Template that does what you need).

blueck.jpg Dive all the way down to the Windows API and C/C++ levels only when you absolutely must.

This is the Clarion philosophy of working smarter, not harder, by letting the toolset do the “drudge” work. Do this, and you'll find that your productivity soars compared to any other tool you've ever used.

Clarion's Development Environment

The development environment contains several main tools, all of which are accessible from the others. When using the Application Generator, buttons and menus in the various dialogs lead to the other tools.

The following Application Development Flow chart shows how all the tools common to both Professional and Enterprise Editions of Clarion interact with each other and the template registry, with the Application Generator at the center of the whole process:

This section provides a description of each tool, in the order that a typical programmer using the Application Generator might encounter them. Each tool contains dialog boxes which the programmer fills out to describe the Application's functionality to the Application Generator. On your command, the Application Generator generates the specified source code, and the Project System compiles and links it to make an executable program.

Common Tools

Programming in Clarion is, in many ways, a personal journey through a series of dialog boxes. There is no mandatory sequence to follow through the dialogs, though some are prerequisites for others. The following are brief descriptions of the tools common to both Professional and Enterprise editions of Clarion.

The Dictionary Editor

The Data Dictionary (a .DCT file), maintained by the Dictionary Editor, holds a description of the database, including its tables, keys, indexes, database drivers, file relations, columns, column validation rules, referential integrity constraints, and more. This is the first file you create when you design your application.

You can create the table definitions from scratch, or you can import definitions from existing tables. The other tools of the development environment use the information in the Data Dictionary to let you, for example, easily place columns in a dialog box you design for the end user. The Application Generator creates code for all the statements that access the tables based on how you construct the Data Dictionary. In fact, the Application Wizard can generate a fully functional application based solely on your Data Dictionary!

The Application Generator

The Application Generator generates your application's source code, one procedure at a time, based on the templates you pick from the template registry. It lets you add global and local memory variables, and customize the procedures with visual design tools and embedded source code.

The Application Generator provides access to the other tools of the development environment so you can customize the look and functionality of the windows, menus, reports and other user interface elements of your application. The templates provide their own controls (which appear within the Application Generator) allowing you to provide the information with which the template customizes the requested functionality.

The Window Formatter

Visually design your application's windows and controls'everything the end user sees'in the Window Formatter. It automatically generates the source code for the elements you visually design on screen.

The Report Formatter

The Report Formatter works with the Application Generator in much the same way as the Window Formatter. You place controls in a sample report page. At run time, the print engine processes the rows, handling page breaks, group breaks, headers, and footers as specified.

The Text Editor

The Text Editor is a fully functional programmer's editor which you can use to write any source code your application needs. Most likely, when using the Application Generator, you'll use the Text Editor to create embedded source code to customize the way a procedure operates. Or, you can write entire applications from scratch (if you really want to work that hard).

The Text Editor features color coded syntax highlighting, making it easier to identify the different parts of the Clarion language statements for editing purposes. It also has full text search and replace capabilities, along with all the standard editing tools.

The Formula Editor

The Formula Editor helps you quickly generate and manage simple or complex assignment statements based on any kind of mathematical or string expression. The Formula Editor provides syntax checking, plus instant access to all the variables, functions, and operators, so that the formulas generated are always syntactically correct.

The Project System

The Application Generator automatically creates the project file (.PRJ) for the application for you. The project file contains compile and link options, such as whether to include debug code, optimization choices, external files, the source code files, libraries and other external files included in the compile and link process.

The Debuggers

Debugging a program usually requires running the program and repeatedly stopping it at various points during execution to examine the value of different variables to determine the cause of logic errors in the program. The Clarion Debuggers (both 16-bit and 32-bit) have a number of windows which display source code, variable contents, active procedures, and much more.

There are three lessons on using the Debuggers contained in the User's Guide. We recommend that you go through them after finishing Getting Started and Learning Clarion lessons.

The On-Line Help

Clarion provides extensive on-line context sensitive help from almost every screen. Click on the Help button, or press f1.

The Common Questions section of the on-line help provides instructions and examples for performing common application tasks. You can cut and paste example code directly from the help system into your program. Choose Help Contents, then press the FAQ button.

The Clarion on-line help system includes a main help file, plus auxiliary files. The on-line help files are searchable by keyword and by index. To perform keyword or index searches on an auxilliary file, open the file directly with the Windows Explorer or Program Manager.

Enterprise Edition Tools

The following are brief descriptions of the tools which are in the Enterprise Edition of Clarion and are not available in Professional Edition, except as add-ons (in certain cases). These tools are all fully documented in the core help'including lessons for each.

Dictionary Synchronizer

The Dictionary Synchronizer allows you to synchronize one data dictionary to another (available only in Enterprise Edition). You can synchronize two Clarion data dictionaries (.DCT files), or synchronize a Clarion data dictionary with an SQL back end's data dictionary (either direction). This allows you to get all the table definitions and relationships at once from the SQL backend database and eliminate a lot of front-end work and keep the Clarion data dictionary in synch with the SQL RDBMS at all times, no matter what changes the SQL Database Administrator makes.

Dictionary Diagrammer

The Data Dictionary (a .DCT file), can also be maintained by the Dictionary Diagrammer (also available as an add-on to Professional Edition). This is a visual data modeling tool, allowing you to view your database design from an entity-relationship diagram perspective.

Business Math Library

The Business Math Library is a set of standard business and statistical functions which you may use (also available as an add-on to Professional Edition). There are also a full set of templates which make implementing these functions in your programs very easy.

Where to Next?

clarion_programming_concepts.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1