Friday, July 26, 2013

End Programming Nightmares: Event-Driven Programming with Magic xpa Application Platform

Have you ever had that nightmare where you arrive late for an event and don't know how-to handle yourself? Everyone else seems to know what's going on, but you haven't a clue. Here's how-to avoid programming nightmares with Java and C#: Don't program in Java and C#. Magic xpa Application Platform avoids these nightmare programming scenarios and gives you a platform for an event-driven dream come true instead. 

Event-driven programming in the Magic xpa Application Platform allows for the flow of the program execution to be triggered by events and handled in a desired manner. Event-based software development in Magic xpa is based on the very powerful Magic xpa engine.

The Magic xpa engine distinguishes the Magic xpa Application Platform from other approaches to application development and deployment. With pre-built capability to perform complex data manipulations that are transparent to the developer and end-user, the Magic xpa engine is key to the productivity and performance provide by Magic Software’s approach to application development and deployment.

The engine includes a set of operations for the developer’s use in creating applications. It also serves up a structure of execution steps called logic units, which work with the operations to perform tasks for the end-user. The developer doesn’t have to tell the Magic xpa Application Platform how-to do its job. The engine already knows how to perform such actions as opening files, reading records, sorting, displaying data on the screen, and more.

Contrast this with traditional 3GL and 4GL languages where the developer has to provide detailed instructions through program code to tell a program how-to implement each and every step, regardless of how tedious and repetitive they are. Programmers developing in Java, C# and other languages get very frustrated by the fact that they have to repeat programming done hundreds if not thousands of times before by others. Many throw up their hands on the whole process of programming and say “Been there, done that” while others almost seem to enjoy being slaves to their code. By contrast, Magic xpa saves the developer considerable amounts of time by supplying these built-in operations and execution steps.

Naturally, the Magic xpa engine includes extensive support for event driven programming. Events, triggers and handlers are built in concepts. Magic xpa lets you define the Magic xpa logic as a response to implicit and explicit events that may occur during the execution of a task.
In Magic xpa, an event is an abstract indication to the runtime engine that something has occurred within the running application. The runtime engine can either choose to ignore the event or respond to it. For example, a mouse click on a control issues an event in the runtime engine that a click has occurred. The runtime engine can then respond to this event accordingly.
Every event is triggered when the application runs. Some events can be triggered as a response to an external activation, such as when a key is pressed or when the mouse is clicked. Other events can be triggered when a certain stage in the application is reached, such as an elapsed time period. Some events can be defined as triggers of other events.
A handler is a logic unit that runs when an event has occurred. A handler is defined to handle a specific event.

For the Magic xpa developer, an event is simply a logical definition of an occurrence. An event can be handled by an event handler to perform a flow of operations that the developer chooses. An event can also be assigned as a trigger of another user-defined event. When the triggering event is raised, it triggers the user-defined event. But Magic xpa isn’t just aware of events, it also allows the developer to handle events very specifically. In Magic xpa, a handler is a set of operations designated to be performed when a specified event is raised.

There are a number of different event types managed by Magic xpa.

System events are triggered by defined keystroke combinations. Magic xpa developers can define keystroke combinations for system events in a dialog box.

A Magic xpa internal event is usually handled by Magic xpa itself. But you can define a new or additional handler for these internal events.

Additional user events can be defined in the Event repository by the developer.

Timer Events within Magic xpa are based on durations, so that for every time interval of a specified duration, the event is invoked.

Expression Events are vents that are triggered when an expression evaluates to True. If the expression evaluates to false, then the event is not triggered.

Error Events are invoked when database-related errors occur such as a duplicate index or record that has been changed by another user.

ActiveX events are still used in some programs that use COM objects and Active X. An ActiveX event is raised for COM objects. If the event has built-in variables, they are created in the handler. It should be noted that ActiveX events are not supported with rich client tasks.

.NET events are preferred in rich client mode, where Magic xpa includes full support for .NET variables and events. When an event has built-in variables, they are created as parameters in the handler with the relevant .NET type. You can also define an event handler without defining a variable. In such a case, you can write the object from which you want to select the event.

Magic xpa events can be project-related events, triggered during the execution of any of the project's programs or task-related events confined to a specific task in which they are defined or to the task and its subtasks.

An event can have more than one trigger and more than one handler. Each trigger can raise the event in a different scenario. One or more handlers can handle the event for each scenario. This allows for complex event driven programming while avoiding the complexity of line-by-line coding. An event handler logic unit is the actual response to an occurring event.

When an event is triggered, the runtime tree is scanned from the bottom-most task up to the Main Program for a handler that corresponds to the triggered event. (The runtime tree is the collection of all the tasks that are currently running under the same context. The task order in the runtime tree is the order in which they were opened.) The engine sequentially executes the operations defined for the handler once it has been found. After executing the last operation in the handler, the engine continues up the runtime tree looking for another matching handler. After reaching the Main Program and executing any handlers found, when the triggered event is an internal event, the engine looks for internal engine handlers for the triggered event. The Main Program is the parent program of all other programs in the project, and it is always at the top of the runtime tree at runtime. This means that a handler defined in the Main Program is a global handler for the entire project.

Handlers of the same event, which are defined in the same task, are executed according to their location in the Task Editor from the bottom upwards.

End Programming Nightmares. The Magic xpa application platform is available commercially from Magic Software Enterprises.

No comments:

Post a Comment