Friday, November 28, 2008

Understanding and Using Morfik Helper Methods

Morfik AppsBuilder 2.0 introduced a very interesting feature for those of us that have an interest in writing elegant code. This feature is called Helper Methods and it pretty much allows you to add methods to any type in the Morfik language.

With Morfik Helper Methods you can add new functionality even to primitive types of the language such as integers, strings and booleans. The following code snippet is a short Helper Method written in Morfik Pascal.

function Boolean.ToString: string;
begin
if Self then
Result := 'True'
else
Result := 'False';
end;

The same methods could be written in Morfik Basic as shown in the following code snippet.

function Boolean.ToString as string
if Me then
Return "True"
else
Return "False"
end if
end function

This topic is a bit too extensive to go into all the detail in a regular post, so I decided to make available for download a PDF version of longer article called Understanding and Using Helper Methods.

The information contained in this article is part of the material I have been putting together for the new book I am currently writing.

0 comments:

Post a Comment