Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which format Android Studio default code style scheme follows?

If you go to: Android Studio -> Preferences -> Editor -> Code Style -> Java/Groovy/XML you find Default Scheme.

Or on MacOS: /Users/raiym/Library/Preferences/AndroidStudio3.1/codestyles/Default.xml

Where it comes from? Couldn't find which style guide Android Studio follows.

like image 549
raiym Avatar asked Oct 03 '18 06:10

raiym


1 Answers

I've done quite a lot of researches, but in the end, I haven't reached a very satisfying answer: probably it's just a code style for IntelliJ.

The first thing I did was trying to compare the IntelliJ style with something else, but I always found some differences.

It doesn't follow Google's style because they don't fully qualify import, in fact, IntelliJ will try to unify imports by putting *, like writing import foo.*; instead of import foo.Bar;.

It doesn't follow Oracle's guidelines either since the switch statement is formatted in a different way:

switch (condition) {
    case IDEA:
        statements;
        break;
case ORACLE:
    statements;
    break;
}

At this point, I've started looking for something else, but found even less. In fact, IntelliJ doesn't tell about the code style used in their software anywhere. Instead, they just explain how to change it.

Moreover, there are plugins for every possible code style! If one of them was the actual style in IDEA a plugin shouldn't be needed...

To make things worse, even for Kotlin, a language created by IntelliJ, they differentiate between "Kotlin Coding Conventions" and "IntelliJ IDEA default code style".

What I think is that they made a code style that works for most languages supported by their IDEs with little differences, and this is what Android Studio ended up using by default.

like image 147
Marco Fincato Avatar answered Sep 30 '22 03:09

Marco Fincato