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 5.6

COLUMN

Don't Use Strings

Use Classes That Express Your Design

Issue: 5.6 (September/October 2007)
Author: Charles Yeomans
Author Bio: Charles is the author of "I Declare: Calling External Functions in REALbasic", available online at http://www.declareSub.com/
Article Description: No description available.
Article Length (in bytes): 6,107
Starting Page Number: 41
Article Number: 5615
Related Web Link(s):

http://www.declareSub.com/

Excerpt of article text...

If you have properties or variables in your code like TelephoneNumber as String, replace them with TelephoneNumber objects. You can get the compiler to do more work for you, and probably simplify your code.

It is, of course, quite convenient to add String properties to a class to represent telephone numbers, zip codes, or any other sort of data that you need in the course of writing an application. But when you assign to a String variable, how do you know that it's a telephone number? Why, you don't, unless you validate the data to determine whether it has the correct form. Even then, all you know is that the data is syntactically valid.

String, Integer, and other such datatypes are often referred to as "primitive" datatypes. You should think of them as building blocks for types that express the intent of your design. In REALbasic, one can define new types using classes, interfaces, or structures. For something like a telephone number, a class is the first choice.

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