Select case vs if then

And how they work …..

In a bug report I made I posted a tiny sample of code

Dim tokens() As String

Select Case True
  
Case tokens.ubound < 0
  
Case tokens(0) = "End"
  
Case  "Dim"
  break
  
End Select

(Not this code has a known bug in it – Case “Dim” is wrong but it illustrated the bug I was reporting) I’ve used this style for very long sections of code esp where I dont want to clutter it up with extraneous “if then” or “elseif”

But it gathered a curious comment that convinced me the writer of that comment isnt certain how SELECT CASE works.… Read the rest

Class vs Module

Should be a great WWE match up

Really the question was “should I use a class or a module?”

There’s not really global “Oh always use X” answer here.

But usually if you find yourself wiring code that passed data to a method and you have a group of methods that collectively define a “data type” then you probably want a class.… Read the rest

Working around things the IDE prevents

Sometimes when you want to subclass a control you want to retain the property name the Xojo control uses, but you want to add some custom functionality by putting a computed property in place in your subclass.

In the long run this makes your subclass a better drop in replacement. You dont end up with the case where the superclass has a property named one thing, like Text, and your subclass has a similar property named something else, like Caption.… Read the rest

Helping yourself debug

There are some really handy pragmas that can help you speed up your code a lot if you turn off the things they deal with.

Normally Xojo puts in extra checks to make sure you dont exceed array boundaries and dont overflow the stack on recursive calls. The list is on this page but I’ll repeat a few here

BackgroundTasks Enables or disables auto-yielding to background threads.In… Read the rest

Ptrs. And Memoryblocks. Oh My !

Sure I badly paraphrased the line from Wizard of Oz but this isn’t a word junkies blog. Or a Word© junkies blog either 🙂

Stupid tech jokes aside this one is about Ptr and Memoryblock and their interesting relationship.

In Xojo a memory block is just that – a chunk of memory acquired in one of many ways, that usually can be manipulated in lots of ways.… Read the rest

Whats your purpose ?

Methods should solve a single problem, answer a single question, or otherwise do one thing.

When you, the author, are asked “what is this code going to do ?” you should be able to say it in ONE sentence without the use of conjunctions or disjunctions – no ANDs and ORs required.

The upside to such a description is that this often can make method nice and short.… Read the rest

Single Static Assignment

Or “write once”

This is a form that LLVM uses for its IR when compiling. It makes certain kinds of analysis much easier to perform as its simpler to determine how variables are affected long term and what their life times are.

And Rust uses it for EVERYTHING – you literally have to tell Rust that a variable should be “mut” or mutable.… Read the rest

Whatever you think of him

Joel Spolksy has some great blog posts

Several I re-read from time to time just to refresh my recollection of them or to glean something new from them I may have missed on one of the tens of rereads I did.

I really like his blog posts about organization style, functional specs and other aspects of software development.… Read the rest

Enum extender updated

Yeah again 🙂

Fixed a bug where it would write the wrong value into the data on the clipboard and so it would create an incorrect enum to be pasted.

Thats been fixed

More things on the way !