pokered icon indicating copy to clipboard operation
pokered copied to clipboard

Standardize the formatting of local labels

Open kqesar opened this issue 2 years ago • 8 comments

Standardize the name of functions (begin with . like .bagFull) in pascalCase

kqesar avatar May 15 '22 22:05 kqesar

It looks like you mostly focused on the scripts/ folder, but there are several more .PascalCase labels in audio/, data/, engine/, and home/.

dannye avatar May 16 '22 19:05 dannye

Yes for the moment all functions are in script folder.

I can continue on other directories if it's ok for the snake_case as case convention for functions

kqesar avatar May 16 '22 19:05 kqesar

At a quick glance it looks like roughly 25% (~1000) of our local labels are small 1-word labels (sometimes with numerical digits) that are irrelevant for this discussion (already lowercase and would never need to consider if they should be .camelCase or .snake_case).

Then roughly 55% (~2200) have no underscores, have at least one uppercase letter, and start with a lowercase letter (true .camelCase).

Then roughly 10% (~400) have no underscores and actually start with an uppercase letter (.PascalCase).

And the remaining 10% (~400) currently have at least 1 underscore, ie .snake_case (and a handful of .snake_Case or .Snake_Case). (on top of that, more than half of those ~400 .snake_case labels are actually .asm_xxxxx labels, so not even "legitimate" labels.)

I think we are all in agreement about changing .PascalCase to .camelCase (for insignificant inner labels).

Now, between .camelCase and .snake_case, my preference is for .snake_case, but given that it's only 10% of all local labels, I'd be okay with going all-in with .camelCase if that's what everyone else thinks.

dannye avatar May 16 '22 19:05 dannye

Ok @dannye , i keep the camelCase and use it for other folder :)

kqesar avatar May 16 '22 19:05 kqesar

Now, between .camelCase and .snake_case, my preference is for .snake_case, but given that it's only 10% of all local labels, I'd be okay with going all-in with .camelCase if that's what everyone else thinks.

I actually also prefer .snake_case for local labels. Whatever style we end up with, though, should be applied to all the repos (red, yellow, gold, and crystal). (yellow can probably merge the PR from red, but may also need some of its own labels updated, e.g. for Pikachu or GBC-specific code.)

I think we are all in agreement about changing .PascalCase to .camelCase.

Generally yes, but I think some of those might be in .PascalCase because they're more like independent sub-sub-routines than just local pieces of one large subroutines. So on a case-by-case basis we may want to make them non-local PascalCase labels instead, even if they're only called once or twice by the subroutine above them.

Rangi42 avatar May 17 '22 00:05 Rangi42

Generally yes, but I think some of those might be in .PascalCase because they're more like independent sub-sub-routines than just local pieces of one large subroutines. So on a case-by-case basis we may want to make them non-local PascalCase labels instead, even if they're only called once or twice by the subroutine above them.

That's fair. I was thinking a similar thing with some of the .snake_case local labels. I think there are a few local labels with underscores that -- even if we switched to .camelCase -- should keep their underscore for situation-specific reasons. Kind of like Evolution_LoadPic discussed above, but for local labels.

dannye avatar May 17 '22 00:05 dannye

I agree about Evolution_LoadPic and such.

Rangi42 avatar May 17 '22 00:05 Rangi42

Humble mention of https://github.com/pret/pokecrystal/blob/master/STYLE.md

mid-kid avatar May 23 '22 19:05 mid-kid