Replies: 2 comments 10 replies
-
Agreed, it was always surprising for me that we have |
Beta Was this translation helpful? Give feedback.
-
I vaguely remember our original conversations about this. We ended up here because "doc" is a universally recognized shorthand for "document" (no risk of confusion) and was also something that was going to end up getting typed a lot. "Collection" does not have a clear analogue -- "col" is a common abbreviation for "column" and "coll" doesn't really pop. "Snap" is reasonably clear for Snapshot, but it's not quite as universal. Would folks feel better (as a counterproposal without any thought behind it) if |
Beta Was this translation helpful? Give feedback.
-
While migrating my app to the new modulized sdk I've been running into some name clashes, espcially for the doc() method that clashes with my "doc" variable in the callback. While this is of course just a minor annoyance I've been thinking about the naming conventions in the sdk a bit.
I'd prefer a consistent naming scheme like this (which would also reduce the number of clashes with variable names that I guess are widely used with the old sdk):
Using either full or abbreviated method names, so either
collection(...) document(...) onSnapshot(...) setDocument(...) etc.
or
col(...) doc(...) onSnap(...) setDoc(...)
I'd prefer the full names, as it is nicer to read and I guess it will also not affect the generated bundle size.
The "Common use case" would then be much nicer to read as
const docSnap = await getDoc(docRef); // <- Using docSnap as doc would clash with the imported method
would become
const doc = await getDocument(docRef)
etc.
A new SDK version is a great opportunity to start with fresh and consistent naming schemes, so even though it may be just a matter of taste I think it is worth to provide some feedback.
Beta Was this translation helpful? Give feedback.
All reactions