Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code style guide and template #97

Closed
barbeau opened this issue Jan 21, 2014 · 2 comments
Closed

Add code style guide and template #97

barbeau opened this issue Jan 21, 2014 · 2 comments

Comments

@barbeau
Copy link
Member

barbeau commented Jan 21, 2014

As discussed here, we'd like OBA Android to follow similar code style guidelines as Android itself:
http://source.android.com/source/code-style.html

We can use the AOSP style guide template for IntelliJ from latest Android code with Android Studio:
https://android.googlesource.com/platform/development/+/master/ide/intellij/codestyles/AndroidStyle.xml

Based on this SO post, you can drop this AndroidStyle.xml file into the Android Studio codestyles directory, which for me is in my user preferences directory C:\Users\barbeau\.AndroidStudioPreview\config\codestyles.

@paulcwatts Thoughts on officially adopting this code style, and adding guidance to README and CONTRIBUTIONS to use this style for contributions? This might result in several initial formatting commits to fully bring the project in line with the style guide.

@paulcwatts
Copy link
Member

That's fine, I know some of the code could be cleaned up.

@barbeau
Copy link
Member Author

barbeau commented Jan 22, 2014

I'll submit a PR for this shortly for you to review. Actually not as many changes as I would have thought after applying the template, you're very consistent, and I guess I've blended in reasonably :).

From a quick scan of the changes, most seem very reasonable. There are some changes that decrease code density, which I'm not a big fan of, but IMO consistency is more important in the long run:

  1. Adds blank lines between variable declarations
  2. Cascades lines that slightly exceed allowed line width to the following lines
  3. Expands BuildConfig.DEBUG logging statements to three lines (as opposed to one)
  4. Cascades NO-OP methods to three lines (as opposed to one)
  5. Single-line IF statements are surrounded by braces (this I actually like)

If any of the above are deal breakers for you we could look at modifying the AndroidStyle.xml template, although we'd need to do this every time we re-import the template (I'm including the XML file in the repo as well, so we're all working off the same style guide, without external dependencies, until we check in a new version).

paulcwatts added a commit that referenced this issue Jan 25, 2014
Fix #97 - Add AndroidStyle.xml code style template and apply this templa...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants