Wish camelCase when generating type objects [SOLVED]

ilan

Expert
Licensed User
Longtime User
hi

it is not so important but is it possible to follow the camelCase rule when we auto generate type objects?

now the first letter is uppercase and everything else is lowercase. i always find myself fixing after generating type objects.
it's not super important but it would save some time ?




 
Last edited:

MikeH

Well-Known Member
Licensed User
Longtime User
How would it know where to put the hump?
 

ilan

Expert
Licensed User
Longtime User
In VB6, we have ProperCase which I more prefer type of naming convention.
my wish is that the "generate" function will keep the "type defination" string and this will do the job for everyone. who likes camelCase will get camelCase who likes ProperCase will get ProperCase etc...
 

ilan

Expert
Licensed User
Longtime User
B4X:
Dim varName As String = "fruitobj"
varName = varName.Replace("obj", "Obj")
?

sorry, but i think you misunderstood. i am talking about the IDE and not how to return a string in the app.
when i use the "generate type" function in the b4x IDE it changes the name of the type to lowercase and first letter to uppercase then i use this function a lot in my code but it starts to get unreadable.

EDIT:
i just realized that the IDE does keep the name the only thing is that it adds "Create" at the beginning and this messes up the look.
having the "create" string lowercase and the first char in the type definition uppercase would do the job but again if many does not like that then there is no reason to make that change to the IDE.

ok never mind. my mistake!
 

aeric

Expert
Licensed User
Longtime User
I normally use Type starts with Capital letter with plural noun and new object is singular noun. I think it has good readibility.
B4X:
Sub Process_Globals
    Type Customers (index As Int, Code As String, Name As String, Address1 As String, Address2 As String)
End Sub

' Assigning values from resultset
Dim customer As Customers
customer.index = index
customer.Code = RS1.GetString("Customer_Code")
customer.Name = RS1.GetString("Customer_Name")
customer.Address1 = RS1.GetString("Customer_Address1")
customer.Address2 = RS1.GetString("Customer_Address2")

when i use the "generate type" function
I see. I didn't realize it or have forgotten this feature. I normally typed out all the code and never initialize my Type like my above code.


B4X:
Public Sub CreateCustomers (index As Int, Code As String, Name As String, Address1 As String, Address2 As String) As Customers
    Dim t1 As Customers
    t1.Initialize
    t1.index = index
    t1.Code = Code
    t1.Name = Name
    t1.Address1 = Address1
    t1.Address2 = Address2
    Return t1
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
Type Customers (index As Int, Code As String, Name As String, Address1 As String, Address2 As String)
I wouldn't do that; the type should be singular, represent a single entity (in that case). So I would name it tCustomer (without the final s) and not put an index "field" in it.

Generally my variables start with a capital letter and, if made up of two or more words, the others will also be like this (StartPoint, FirstTime, ...). Exceptions: a variable declared at the module level has the prefix "m" (mCounter); a project global variable has "g" as prefix; in some cases, a prefix of 3 or 4 letters indicating the type (lowercase).
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…