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 16.3 ('XDC 2018')
Instant purchase and download via GumRoad!

COLUMN

Refactoring

Making Code Better

Issue: 16.3 (May/June 2018)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 12,361
Starting Page Number: 72
Article Number: 16306
Resource File(s):

Download Icon project16306.zip Updated: 2018-05-09 11:00:01

Related Link(s): None

Excerpt of article text...

Refactoring is one of those concepts that sounds complicated. I won't tell you it isn't complicated, but it's definitely not something you should fear. Refactoring is simply revising your code to make it better.

The trick is deciding what you mean by "better." There are many levels of better. For instance, you could simply rewrite your code to make it more readable. This could include changing the names of variables to identify their values more accurately, combining—or separating—code, and adding comments.

Let's look at an example of some code. Say we've got the following method, which calculates the average nutrients consumed over a series of meals:

Public Sub calcAverageMeal()

dim i, j, k, n, numberOfDays as integer

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