I'm wondering if I should use PascalCasing
or camelCasing
for my modules names, so far I've always used PascalCasing, i.e: Ayolan.Engine.Rendering
instead of Ayolan.engine.rendering
(I keep PascalCasing for the container, since I want the global object name to be Ayolan
and not ayolan
).
I haven't found any headline on this, found that thread from 3 years ago but not really useful.
I'm wondering because I'm working with Java developpers and to them it makes more sense to use camelCasing
, but that's not what I've seen so far with TS.
In TypeScript & JavaScript, the camel case convention is used to signify that a token is a variable, function, method, parameter, or property.
Screaming snake case is used for variables. Scripting languages, as demonstrated in the Python style guide, recommend snake case in the instances where C-based languages use camel case.
Camel case and Pascal case are similar. Both demand variables made from compound words and have the first letter of each appended word written with an uppercase letter. The difference is that Pascal case requires the first letter to be uppercase as well, while camel case does not.
PascalCase is a naming convention in which the first letter of each word in a compound word is capitalized. Software developers often use PascalCase when writing source code to name functions, classes, and other objects. PascalCase is similar to camelCase, except the first letter in PascalCase is always capitalized.
In TypeScript, we use the same standards as JavaScript, because we are working with many JavaScript libraries (and potentially being consumed by JavaScript code too).
So we prefer PascalCase for modules and classes, with members being camelCase.
module ExampleModule {
export class ExampleClass {
public exampleProperty: string;
public exampleMethod() {
}
}
}
The only other style rule I can think of is that constants are ALL_UPPER.
You will notice that this blends in nicely with the following code:
Math.ceil(Math.PI);
Most importantly of all - keep consistent with the style you use as the style can imply meaning, so if you aren't consistent it will cause confusion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With