B4J Question [BANano] Defining & Calling getTers & setTers with BANano v8+ & the possible technical debt

Mashiane

Expert
Licensed User
Longtime User
Good day

With BANano 7, i have been safely defining setTers and getTers with this kind of code, for example... Everything worked perfectly.

B4X:
'set Icon Color
Sub setIconColor(s As String)
    s = SDUIShared.CStr(s)
    ItemIcon(mName).Color = s
End Sub

and was able to call this with this code

B4X:
someComponent.IconColor = "black"

ItemIcon is a sub that returns a component... as defined with

B4X:
'get the icon
'<code>
'stats2.ItemIcon("likes").Large = True
'</code>
Sub ItemIcon(itemID As String) As SDUIIcon
    itemID = SDUIShared.CleanID(itemID)
    If BANano.Exists($"#${itemID}"$) Then
        ItemFigure(itemID).show
        Dim el As SDUIIcon
        el.AssignElement(mback, $"${itemID}_icon"$)
        el.show
        Return el
    Else
        BANano.Throw($"SDUIStat.Icon: '${itemID}' does not exist!"$)
        Return Null
    End If
End Sub

In the definition of SDUIIcon, I do have a seTter for color.

B4X:
'color constants
Sub setColor(s As String)
    Root.textColor(s)
End Sub

This worked well. Everything was fine.

With BANano V8, things are different, I get an error.

B4X:
[ERROR 28]: [seticoncolor: 170] color was neither found as global variable, nor method in sduiicon!

I have changed the code to be..

B4X:
'set Icon Color
Sub setIconColor(s As String)
    s = SDUIShared.CStr(s)
    ItemIcon(mName).setColor(s)
End Sub

Whilst I understand what I have to do to fix this bug in my code (a lot of technical debt) if i have to use v8, my question is, going forward. Is it recommended to use getters & setters in BANano? The b4j IDE does not pick this as an error at all (expected), up until BANano v8 transpiles the source code, then all hell breaks loose. I understand the need to enhance how BANano works and the improvements, these are appreciated, sadly this is a major breaking change across everything Ive done so far.

My solution to this is to rename all my get / set subs from using small s and small g to use big S and big G. This will make them subs and not getters and setters. This will enable me to see where i need to make updates on the b4xlib and also apps made so far. That will be a lot.

I should ask though, is there any better way that I can address this? I know I can just stick to V7, stopping growth.
 
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
a lot of technical debt
Wtf are you talking about?! You heard some buzz word and think this is applicable here? I told you we've rewritten the core engine and your specific case did not come up with our tests and I asked you for a test sample we could add to our test system which you did not provide.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Wtf are you talking about?! You heard some buzz word and think this is applicable here?
Wow. What a response.

Did it cross your mind that I was talking about me when I mentioned technical debt and not you?


Forget it, its fine.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
Update: I looked at the comparison between V7.37 and v8.19 output in debug mode of SithasoDaisy.

This is showing about 6 times ie. 6 sub routines in my code and affects the getters and setters. The classes being referenced have both a set and a get.

Left = BANano 7.37
Right = BANano 8.19

1700302314325.png


1700301520954.png


1700303288608.png


I hope this makes sense.

Yes, explicitly changing .Caption to .setCaption on my side fixes the error, but that would be a lot to do. At least now that I know where the problem is, I'm relieved. Phew. The strange thing is this affects a few cases as in other subroutines its transpiled correctly.
 

Attachments

  • 1700300909666.png
    1700300909666.png
    95.1 KB · Views: 41
Last edited:
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
We tested out every possible way we could think of but could not replicate this. There is no doubt something goes wrong and something is special in your code, but we can no longer spend time guessing what it is. Our company has already allocated resources almost a whole weekend trying to figure out what you can be doing so without specific code that replicates this problem, there is nothing more we can do.
 
Upvote 0
Top