WeakRef usage

There was a good question from Markus in a recent comment on a different post of mine.

In children of a window we should keep track of the parent window by using WeakRef.
But what if I have a class cDepartment with a list of employees defined as Employees() as cEmployee – should that then better also be defined as WeakRef?

Read the rest

2019, The Lost Year, in review

2019 has been an interesting year to say the least.

Mine started off with the septic system needing to be replaced in the first week of January as the old system had been installed in a manner that it was not repairable and it had failed. So in the cold of January our yard was torn up and excavation work went on.… Read the rest

#if Targetxxxx

I’ve seen this a lot in posts on the forums and even in code submitted as part of bug reports

If TargetWindows Then
  // Windows only code not excluded from compilation.
End If

The code inside the if will only execute on Windows. However becuase this code is just a normal if it HAS to COMPILE on ALL targets even if the intention is that it only be used on Windows (which it obviously is)

If you intend some code to ONLY be used on Windows you’re better off to use this form

#If TargetWindows Then
  // Declares for example
#Endif

This code will ONLY exist in a Windows builds and so can ONLY execute on Windows.… Read the rest

Classes, Instances and Objects

There’s a fun “theoretical question” on the forums.

What is the relationship between a class, object, and instance?

Lets see if I can help any (or maybe just confuse the heck out of folks even more)

In Xojo in the IDE when you define a CLASS you are creating a “template” for how every item of this type will behave.… Read the rest

Silent readership

I’m curious about something. Actually I’m curious about a LOT of things; just ask my Canadian Skip Patrol instructors 😛
But I’m REALLY curious about one thing when it comes to this blog.

I can see there are a decent number of readers & views thanks to the stats that WordPress gives me. But, there’s very few comments.… Read the rest

Performance tweaks

In Xojo there are a number of things you can do to improve the performance of your code.

There are various pragmas you can enable that can improve speed – I’d suggest only doing this once you code is fully debugged and known to be working properly as turning these checks of can mean IF you have a bug your application just crashes hard.… Read the rest

Structures vs Classes

While structures & classes may seem to be very similar in most respects there aren’t many cases when I would suggest you use a structure instead of a class.

A class with public member properties isnt that different from a structure in terms of how your code uses it.

The biggest difference is that for a class you must use new to get a new instance.… Read the rest

Operator_compare

Ever wanted to define a class, maybe a vector class, and make it possible to write code like

dim v1 as new Vector(1,1)
dim v2 as new Vector(2,2)

if v1 v2 then
  // do something when v1 v2
elseif v1 < v2 then
  // do something when v1 < v2
else
  // do something when v1 = v2
end if

Perhaps you have some other kind of class you’d like to define that has some kind of custom mechanism to compare itself to other instances – or even other data types.… Read the rest