Git Product home page Git Product logo

android-playbook's People

Contributors

damian-lopata avatar ealmdahl avatar sindrenm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

waysas bendikv

android-playbook's Issues

Brackets and ifs

Standardize how we do bracketing in general and ifs in particular.

//oneliners
if (foo) doSomething();
else doSomethingElse();

//no brackets
if (foo)
    doSomething();
else
    doSomethingElse();

//brackets
if (foo) {
    doSomething();
}
else {
    doSomethingElse();
}

Tips for application that might be skinned.

  • Never hardcode color/textColor/textSize in XML layout. (source code is not allowed either)

  • Use styles, but don't combine layout related attributes. Such the following

    <item name="android:layout_width">match_parent</item>

  • For resources names (both file names & entry names) such as layout, drawable, styles and color, use prefix, if it's a project comprises multiple modules, to avoid naming collision.

Indentation

I'm guessing we all agree on using spaces, not tabs, for indentation, right? Good. 👍

However, while the Java convention for indentation is four (4) spaces, I personally think that's a bit overkill. Two spaces for indenting code blocks actually feels more readable to me and also keeps lines shorter (so I guess it sort of ties into #3 in that sense). Would love to hear your thoughts on this.

data classes

What do you think about the formatting for data classes ? Which one do you prefer ?

data class ProductColorBlock(val title: String, val description: String, val products: Array<Product>,
                                                val colors: Array<String>, val link: String)

vs

data class ProductColorBlock(
        val title: String, 
        val description: String, 
        val products: Array<Product>,
        val colors: Array<String>, 
        val link: String
)

Kotlin: lazy initialization

Per the current guidelines, we should “always” lazily initialize member variables. However, I'm not sure if this is a good idea. I agree that we should lazily initialize final members that cannot be initialized in a constructor (quite common in Android, due to the framework not being available until a hook method like onCreate has been called), and in those cases the lazy delegate is awesome. But for cases where you can directly initialize members in a constructor (init { ... }) or even directly when declaring it, I prefer those methods.

Kotlin: Null checks in control statements

As far as I can see, there are two main ways of doing null checks in if statements and the like:

fun main(args: Array<String>) {
    val swag: String? = null

    // The King of Rock way
    if (swag?.isNotBlank() ?: false) {
        println("Hello, world!")
    }

    // The standard/Java way
    if (swag != null && swag.isNotBlank()) {
        println("Hello, world!")        
    }
}

Which one do you prefer? Albeit a teensy bit strange, I definitely think I prefer the second example with the Elvis operator.

Establish guidelines and conventions for open-source modules

It would be nice to have naming conventions, application structure conventions and version conventions, as well as guidelines and walkthroughs as to how to create new modules in Android Studio, how to handle deployment, where to deploy etc. 😃

Avoid using butterknife

I propose to avoid using butterknife. Because they can't be used in modules, which means if we are going to refactor some code as a reusable module, it would be painful.

Create a format file for Android Studio

This ties into issue #1 (and maybe also #2?) and puts whatever we figure out there in a format file for Android Studio. By importing that file once, we'll be able to use the auto-formatter to make the file look the way it's supposed to look.

Establish testing guidelines

It's supposed to be relatively simple to automatically test Android apps these days. Let's dig into that and see if we can figure out some good conventions and best practices, then jot them down here for future reference. 😃

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.