Active Forums => QB64 Discussion => Topic started by: Pete on March 22, 2019, 01:44:14 pm
Title: This is what getting old is like for me...
Post by: Pete on March 22, 2019, 01:44:14 pm
I used to make single letter variables in QB45, to save memory. I had a few hundred variable names in some larger apps, and I honestly could remember what each one represented. Towards the end of the QB era, I made a cheat (hash) sheet, as it was getting a little hard to instantly recall those same variable letters. When QB64 came along, I slowly started naming variables, first as single words, and then a few years back, I started using compound words to make understanding the function easier. Now, I find myself wanting to do something like this...
Easier to site read with underscores or dots, right? Well, since I've never used this type of naming, I was not surprised the underscores were accepted, but I thought dots would have been reserved for TYPE defined variables. I'll probably go with he underscores, just to avoid that confusion when sharing code.
Comments welcomed, unless it's about my age... then $%^&_OFF.
Pete
Title: Re: This is what getting old is like for me...
Post by: FellippeHeitor on March 22, 2019, 01:51:42 pm
I usually go with camel case for naming my variables. Same for procedures and custom types, but then I start with a capital letter as well:
TYPE Object x AS SINGLE y AS SINGLE END TYPE
DIM object(1000) AS Object
replaceDecimalPoint$ = a$
DoReplacements
SUB DoReplacements
END SUB
Title: Re: This is what getting old is like for me...
Post by: Pete on March 22, 2019, 03:16:36 pm
Camel case? What, you only code on Wednesdays?
Kidding aside, I'm an unconventional typist, and I avoid mixing case as it tends to slow my coding speed down. It's a good method for readability. It is especially good for displaying domain names like: dialupass.com or sandhillsexpress.com... DialUpAss and SandHillSexPress, right? Oh well, like I said, it messes with my typing.
I have entertained using TYPE. One thing I like is that reusable subs and functions can just have one variable nae associated with the TYPE like: decimal_tracker. So decimal_track.x, decimal_track.y, etc. The TYPE definition is the hash table, so to speak. This makes the odds of duplicating a variable in other modules you associate these"library" routines virtually null; especially if you use global variables.
Now I would use GOSUB instead of a sub call, just so the library routine only shows up as a single sub, but...
If I did want to use a sub call, how would the variable, in the example above, get passed to the sub without DIM SHARED?
Pete
Title: Re: This is what getting old is like for me...
Post by: SMcNeill on March 22, 2019, 03:30:14 pm
SUB do_replace_decimal_point (whatever AS Object)
Then you pass the variable via whatever.
SUB do_replace_decimal_point (whatever() AS Object)
Then you pass the whole array via whatever().
SUB do_replace_decimal_point (whatever() AS Object, index AS LONG)
Then you pass the array via whatever(), and use the index to track the specific index you want to work with.
Title: Re: This is what getting old is like for me...
Post by: Pete on March 22, 2019, 06:49:06 pm
Cool, thanks! I don't know if I'll get into it much, but I do have to start making some changes if I want to squeak out a few more years of coding. That darn string math thing I'm working on is going to be around 500 lines. I'll probably give the TYPE style a shot on something smaller.
Unfortunately, my local politician is a Democrat, and he can't count that high.
Pete :D
if you had a Democrat and a Republican and as them to count as high as they could, how high would they count?
They wouldn't even get to 1 cause they would never stop arguing where to start.
DIM SHARED Poly_Ticks(537) AS _BYTE 'They sure DO!
I tend use the Underscored Camel Case anymore myself. Now if I'm trying to make a SUB or FUNCTION that I may use in more than one program I will typically use short generic naming, sometimes even single letter.
Title: Re: This is what getting old is like for me...
Post by: Jack002 on April 04, 2019, 02:50:56 pm
Everyone knows what the opposite of PROgress is....