Transitioning to new framework: text as (old) dictionary key

For many of us the transition to the new framework will be gradual. Larger projects can’t be easily ported between the two frameworks so it only makes sense to do it bit by bit. I’m already running into potentially major speed bumps along the way.

Here’s one example: I’m trying to convert all string properties in one class to text properties. The class is used throughout the entire project. One of these properties is a “uniqueID” string. This variable would be used in many places, including as the key in dictionaries for some caching/loading logic.

Converting to text basically breaks all of this functionality because to the dictionary, a text object isn’t the same as a string object. This can create some pretty confusing situations such as:

[code] dim ss as string = “aaa”
dim tt as text=“aaa”

dim d as new Dictionary
d.Value(“aaa”) = “someValue”

dim b1 as Boolean = d.HasKey(ss) ///returns true
dim b2 as Boolean = d.HasKey(tt) ///returns false
[/code]

Is there really no way to smoothly move over to the new framework without having to go all-or-nothing in a project?

See also conversation Old vs New framework

I’ve done the transition for two large desktop projects (one with approx. 100 different windows) in less than a week.

  • For Core, IO, Introspection and Net I have replaced all declarations in one go, and then spend days adjusting things. The most work I had to spent on MemoryBlocks.
  • For Auto I have developed a module called Auto (as Auto is not a keyword), which mimics the constants and methods (Function Type() As Integer) of the Variant module in the Xojo framework (with the help of introspection).

The worst thing was that there is no possibility AFAIK for Using clauses for the whole application. You must add them to all modules, classes, etc. manually (unfortunately you can’t copy and paste them). It would be great if one could for example add Xojo.Core.Introspection globally to the whole application.

This was a month ago and I have not had any complaints in my company for which I have developed these applications four/five years ago.

[quote=193421:@Tom Iwaniec]For many of us the transition to the new framework will be gradual. Larger projects can’t be easily ported between the two frameworks so it only makes sense to do it bit by bit. I’m already running into potentially major speed bumps along the way.

Here’s one example: I’m trying to convert all string properties in one class to text properties. The class is used throughout the entire project. One of these properties is a “uniqueID” string. This variable would be used in many places, including as the key in dictionaries for some caching/loading logic.

Converting to text basically breaks all of this functionality because to the dictionary, a text object isn’t the same as a string object. This can create some pretty confusing situations such as:

[code] dim ss as string = “aaa”
dim tt as text=“aaa”

dim d as new Dictionary
d.Value(“aaa”) = “someValue”

dim b1 as Boolean = d.HasKey(ss) ///returns true
dim b2 as Boolean = d.HasKey(tt) ///returns false
[/code]

Is there really no way to smoothly move over to the new framework without having to go all-or-nothing in a project?[/quote]

This dictionary thing looks like a bug. Since Text to String is implicit, you should not have different results with ss and tt. You probably want to file a report.

I do not really believe in smooth transition. My best experience has been so far porting an app from OS X to iOS. Since string simply does not exist there, I converted everything to Text, wrapped a few new framework commands in older syntax with methods to avoid having too much to rewrite, and off it went. The most difficult was less code than UI.

If I had kept strings, I am sure I would have never known exactly what was string and what was text, a sure recipe for difficult to find bugs.

Would love to be able to do it all at once, but as an example, there are 24,000 matches for “string” in one of these projects.