sparkfun / SparkFun_Toolkit

Toolkit of common functionality for use within SparkFun Libraries
https://docs.sparkfun.com/SparkFun_Toolkit/
MIT License
2 stars 0 forks source link

Define final SparkFun Arduino class name pattern #30

Open gigapod opened 6 months ago

gigapod commented 6 months ago

Current thoughts are:

**SparkFun_**[Upper_Camel_Snake_For_Product_Name]

SFE-Brudnerd commented 6 months ago

If we're following Microsoft for our style conventions then it should be first letter capital camel case.

Ex: SparkfunAs7331ArdI2c or SfeAs7331ArdI2c

Note this is different than what I'm currently doing in that UV sensor library.

sfe-SparkFro commented 6 months ago

FWIW I've personally started leaning more towards snake case in general. I think it's overall more readable, and then you don't have to do funky things with back to back acronyms. I don't have any strong opinions on how to capitalize, but having_underscores_between_words mimics natural writing more than crammingABunchOfWordsTogether.

Also, I would vote for an "SFE" prefix instead of "SparkFun".

gigapod commented 6 months ago

Focusing on Arduino:

From what I see in Arduino Library Land, Library Names seem to follow {Company/Org name}{Library Functionally Name}, but it's also all over the map. And the include file for the library follows the library name. So from a Library Naming standard, we use the above suggestion: SparkFun[Library Specific Name] ... Same for the header. TBH I don't like it - too long and too beginner focused - but it's Arduino and that seems to be the style.

For Library Class Names, the Arduino Library class name seems to be the same has the include file, which is the same as the library name/folder. While Arduino (as far as I can find) doesn't explicitly call this pattern out, they imply it in this document by referencing a library that does it. https://docs.arduino.cc/learn/contributions/arduino-library-style-guide

I suggest we do this for our Arduino Libraries (folder, main header/impl and main overall class): **SparkFun_***[UpperCamelForProduct]

It's basically what's in place now.

Anything beyond that, we just use the sfeTk pattern. (lower camel).

SFE-Brudnerd commented 6 months ago

When you submit a library to the Arduino library registry you will get warnings about those sorts of things from the github actions linter. See here: https://github.com/arduino/library-registry/pull/3744