Skip to content
Olmo Gallegos edited this page Mar 21, 2018 · 4 revisions

Welcome to the dagger2-clean-mvp-example wiki!

Here we will document some of the conventions followed during the Development

Naming conventions

Java

UI Classes conventions are the ones followed by Android, plus some more trivial ones

  • activities: Must end with Activity. e.g. UserDetailActivity, UsersActivity
  • fragments: Must end with Fragment. e.g. UserProfileFragment
  • CustomViews: Must end with View, e.g. GroupStatsView
  • renderers: Must finish with Renderer
  • layouts: everything lowercase, words separated by underscores, starting with layout type
    • view_group_stats.xml
    • row_user.xml
    • activity_users.xml
    • fragment_user_profile.xml
  • widgets: structure will be composed by:
    • screen name separated by underscores
    • type of widget (tv for Textview, et for EditText, iv for ImageView, lyt for Layouts)
    • semantic name of the widget, optionally separated by underscores
    • examples: user_profile_tv_name, user_detail_et_description
  • type of widget prefixes:
    • tv_ for TextView
    • iv_ for ImageView
    • et_ for EditText
    • btn_ for Button or ProgressButtonView
    • ibtn_ for ImageButton
    • v_ for View or exceptionally its semantic name
    • scrv_ for ScrollView or exceptionally scrollView *
    • pbr_ for ProgressBar or exceptionally progressBar *
    • rv_ for RecyclerView or exceptionally recyclerView *
  • naming exceptions:
    • If there is only one widget of a given type, exceptional names (*) can be used
    • A View can be named with its role in the layout, e.g. users_list_separator or user_detail_vertical_padding

Kotlin

In Kotlin we will be using anko, so widgets naming will be simpler. Rest will remain the same.

  • widgets: structure will be composed by:
    • widget type (tv, et, lyt, v, iv...)
    • semantic name (title, fullDescription, text)

We will always keep semantic names as simple as possible. For example, we will use text instead of fullDescription or descriptiveText

Spacing

We follow the checkstyle guide from square to manage the horizontal spacing, such as parentheses after if or block openings.

For the vertical spacing, we only use two kinds of vertical spacing: Consecutive lines and one-line spacing. The last one is used to separate blocks that are logically or semantically independent and may need differentation. For the rest, consecutive lines will be used. A two or more-line vertical spacing won't be accepted.

Clone this wiki locally