B4J Question B4J Crashing with DBUtils

cklester

Well-Known Member
Licensed User
I'm getting a crash (nothing in log, so have to use screenshot):

1611895340499.png


A search for issues lead me to this comment. Yes, I have a module exactly called "DB."

Do I need to rename it?! That's a scary proposition. It's referenced all over the place. :oops:

Maybe with search/replace, it won't be so bad. But still... I'm sweating. šŸ˜
 

cklester

Well-Known Member
Licensed User
OK, that literally took 10 seconds. I renamed the Module to "AppDB." Then I did a search/replace for "All Modules" from "DB." to "AppDB."

Now it works.

Anyway, was that what was necessary here? Was that the only and/or best fix?
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Anyway, was that what was necessary here? Was that the only and/or best fix?

I would say yes ...

Following a similar instance / error I had with one of my projects.
The project contained a myriad of references to the GoogleMaps lib ... and also contained a module "Map" ... not healthy.

You should avoid creating Modules with the name of an existing Class Or Keyword. In this case Map
 
Upvote 0

cklester

Well-Known Member
Licensed User
I would say yes ...

Following a similar instance / error I had with one of my projects.
The project contained a myriad of references to the GoogleMaps lib ... and also contained a module "Map" ... not healthy.

How is anyone supposed to know in advance what names to avoid? That's an interesting puzzle...
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
How is anyone supposed to know in advance what names to avoid? That's an interesting puzzle...

In the end , it was a good reason to start adopting a naming regime that avoids the possibility of a clash / crash.
clsMap , mMap , modMap etc etc.
 
Upvote 0

cklester

Well-Known Member
Licensed User
True. How would you have named a DB class without knowing DB might exist already? I changed it to AppDB, but even that isn't perfect.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
How would you have named a DB class without knowing DB might exist already?
YOU are the AppAuthor arenĀ“t you? You already should know what you are using in your code. If not: add a Naming regime and check for existence if you are unsure it exists.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
How would you have named a DB class without knowing DB might exist already

Whilst I have a (bad ?) habit of keeping class / module names short , (ie: Map), I don't think I would resort to using 2 letter initials as a naming practice.
But this is now all in hind-site ....

mDataBase , clsDatabase ... but would you not then immediately turn round a type Dim DB as clsDatabase :oops:
 
Upvote 0

cklester

Well-Known Member
Licensed User
YOU are the AppAuthor arenĀ“t you? You already should know what you are using in your code. If not: add a Naming regime and check for existence if you are unsure it exists.

In this case, I had an app built before I needed to use DBUtils. So, having a class named DB was no problem. It wasn't until I added that library that the problem arose. Not sure how I was supposed to avoid using a class name that was going to cause a conflict in the future with a library I didn't know I was going to use.

But, you're right! I need a better naming scheme anyway! "DB" is a horrible class name! :D
 
Last edited:
Upvote 0
Top