The past few weeks have been a bit intense with work and personal projects, I’ve been at the keyboard quite a far bit to get my first real app out. I’ll have another post later on, closer to the date when I can actually release it. Of course, it won’t be the cleanest release, but there will be regular updates (in fact that means I need an updating mechanism which will make life easier for the people who do end up using the software). I’ve spent a bit of time refactoring my current project before I started the new tasks. I felt that there was a bit of code smell and well as performance issues. One simple example would be to create a local instance for any values which are calculated within loops.

dim a(100) as string
for i = 0 to Ubound(a)
	//do something
next

Instead of doing that, it would make the loop just a tad bit faster by creating j to be the value of Ubound(a) UNLESS of course, you are changing the length of the array within the loop itself (which I then recommend at least changing the for loop from going “to” to “downto”. This step also allows for you to run through the debugger and find out what j is at that particular time.

dim a(100) as string
dim i as integer = 0
dim j as integer = Ubound(a)
for i = 0 to j
	//do something
next

OR if you are changing the number of elements to the array

dim a(100) as string
dim i as integer = 0
dim j as integer = Ubound(a)
for i = j  downto 0
	if a(i) <> nil then
		if a(i) <> "aaa" then
			a(i).remove
		end
	end
next

I’ve got an app which demonstrates small changes to your code which will improve your performance (if you haven’t adopted these practices already). I used it as a demonstration at work and it is similar to what was presented at the REALBasic Summit. I’ll upload that in time.

I’ve just put down a deposit to get a new mountain bike (Kona Caldera 2009 model) from the Bike Barn out at Paramatta. They were having a sale on Kona 09 models and so I picked it up for $1000. I’ll get it at the end of the work and give it a work out then.

Written by Milton Lai

Leave a Comment

Your email address will not be published. Required fields are marked *