How do you name a class and the name should stand ...
# announcements
r
How do you name a class and the name should stand for: iPhoneX, iOS ? Do you name them IPhoneX and IOS? or how do you name a class if the name in real world starts with lowercase letter?
k
Always, without exception, start class names with an uppercase letter.
2
r
Why so?
g
Because of Coding Convention
r
Why than is not restricted by compiler?
k
Because we rely on capitalization to tell us whether something is a class or a variable/function.
Because it's not helpful to enforce such a thing.
g
Kotlin is not so strict about it, you can use own, but official convention requires that
r
Because it's not helpful to enforce such a thing.
it is helpful, compiler can be much simpler
g
simpler?
There are a lot of tools that can force you to specific coding convention
r
yeap, when you parse a string, if it starts with capital you already know that it must be a class
g
I don’t think so, because other identifiers can use capital letters too, for example objects, constants etc
c
hm... word
class
is quite a giveaway, even before you notice a capital letter 🙂
r
but in function body you don't have
class
c
and in places other than class declaration Andrey's comment applies, you can't rely on capitalization there.
r
we can inforce variables and function to start with lowercase
methods and properties start with lower case
than we for sure know what it should be
g
See comment from Dmitry Jemerov about strict coding convention https://github.com/yole/kotlin-style-guide/issues/14#issuecomment-222932510
r
so, everyone agree to start class with capital, but do not enforce that in compiler, okay
g
@rrader Also, I’m not a professional in compilers, but I’m very sceptical that naming convention could some how help to compiler
r
well,
class
somehow helps in parsing, in same way this will help
g
class is a keyword that cannot be used anywhere except class creation, lower or capital letter can be used everywhere, including keywords