Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 10.5 ('Real World 2012')
Instant purchase and download via GumRoad!

FEATURE

Intro to Fun

Towards Functional Programming with Real Studio

Issue: 10.5 (July/August 2012)
Author: Daniel Gross
Author Bio: Dr. Daniel Gross, the principal of Goal-oriented solutions (www.goalorientedsolutions.com), is a business and system analyst and a researcher with a keen interest in software requirements, architecture as well as software engineering methods. Dr. Gross recently discovered Real Studio while consulting a client on cross-OS development. The fun library is a result of some tinkering done to better understand REALbasic and fine-tune its impressive capabilities to produce software code that not only accomplishes its tasks, but is also easier to understand, maintain, and change.
Article Description: No description available.
Article Length (in bytes): 29,917
Starting Page Number: 43
Article Number: 10507
Related Web Link(s):

http://en.wikipedia.org/wiki/Lisp
http://en.wikipedia.org/wiki/Scala
http://en.wikipedia.org/wiki/F
http://en.wikipedia.org/wiki/Map
http://en.wikipedia.org/wiki/Filter

Excerpt of article text...

In recent years, functional programming, a programming paradigm almost as old as programming itself [1], has seen quite a revival. New multi-paradigm languages, such as Scala [2] and F# [3], which offer both object-oriented and functional language facilities, are gaining a large and enthusiastic following amongst Java or .Net programmers. The promise of functional programming is software code that is particularly well suited to run in parallel on multiple CPU cores, and that is often easier to understand, maintain, and change than traditional imperative code written in procedural, or even, object-oriented programming languages.

In this article I focus on the latter traits and make use of a little functional programming library (fun) I implemented to illustrate how functional programming can benefit REALbasic programmers. I first illustrate a typical programming task using standard REALbasic programming techniques. Next I show, in a stepwise manner, how the software code can be rewritten to use a functional programming style. Then I discuss the software engineering advantages, but also possible liabilities, of the functional approach I illustrated. I then conclude the article with a short implementation discussion of the functional library used in the example.

So, let's dive right in.

How to process selected rows in a Listbox: the imperative way

Figure 1 shows a Listbox with a number of selected rows. Let us assume that each row stores in its RowTag a reference to a Contact object. Suppose, further, we subclass the Listbox and implement a function in the subclass that returns for all selected rows the RowTag object. Code listing 1 shows how one typically accomplishes this task:

...End of Excerpt. Please purchase the magazine to read the full article.