Slide 1

Slide 1 text

@MOLSJEROEN THE ART OF ORGANIZING RESOURCES

Slide 2

Slide 2 text

@MOLSJEROEN @MOLSJEROEN

Slide 3

Slide 3 text

DO YOU HAVE A STRATEGY TO ORGANISE RESOURCES? Jeroen Mols

Slide 4

Slide 4 text

@MOLSJEROEN SETTING UP A NEW PROJECT ▸ Architecture ▸ Unit tests ▸ Build flavours ▸ Code style ▸ Continuous integration & deployment ▸ …

Slide 5

Slide 5 text

@MOLSJEROEN SETTING UP A NEW PROJECT ▸ Architecture ▸ Unit tests ▸ Build flavours ▸ Code style ▸ Continuous integration & deployment ▸ … ▸ What about resources?

Slide 6

Slide 6 text

@MOLSJEROEN IMPORTANCE OF RESOURCES Facebook Twitter Hangouts Layouts 3167 1128 372 Strings 7995 3243 2982 Drawables 4907 2136 1703 Ids 7258 2276 1039 Dimensions 4842 1470 636

Slide 7

Slide 7 text

@MOLSJEROEN CHALLENGES ORGANISING RESOURCES ▸ No XML name spaces ▸ Huge amount of resources ▸ A lot of types: layouts, strings, drawables, ids,… ▸ Reuse across screens ▸ Tooling support

Slide 8

Slide 8 text

IF SOMETHING IS WORTH KEEPING, ITS WORTH KEEPING WHERE YOU CAN FIND IT. David Allen

Slide 9

Slide 9 text

@MOLSJEROEN GOALS ▸ Logical, predictable names ▸ Clean ordering, even in folders ▸ Leverage Android Studio autocomplete ▸ Strongly typed resources

Slide 10

Slide 10 text

@MOLSJEROEN • • • • GENERAL RULE fixed set of options per resource, often Android view class custom part Android view subclass or “all” differentiate multiple elements in one screen precise “xdpi" or bucket “small”, optional ___ ___

Slide 11

Slide 11 text

@MOLSJEROEN • • • • GENERAL RULE fixed set of options per resource, often Android view class custom part Android view subclass or “all” differentiate multiple elements in one screen precise “xdpi" or bucket “small”, optional ___ ___

Slide 12

Slide 12 text

@MOLSJEROEN • • • • GENERAL RULE fixed set of options per resource, often Android view class custom part Android view subclass or “all” differentiate multiple elements in one screen precise “xdpi" or bucket “small”, optional ___ ___

Slide 13

Slide 13 text

@MOLSJEROEN • • • • GENERAL RULE fixed set of options per resource, often Android view class custom part Android view subclass or “all” differentiate multiple elements in one screen precise “xdpi" or bucket “small”, optional ___ ___

Slide 14

Slide 14 text

@MOLSJEROEN • • • • GENERAL RULE fixed set of options per resource, often Android view class custom part Android view subclass or “all” differentiate multiple elements in one screen precise “xdpi" or bucket “small”, optional ___ ___

Slide 15

Slide 15 text

@MOLSJEROEN ADVANTAGES 1. Easy to use

Slide 16

Slide 16 text

@MOLSJEROEN • Examples STRINGS - articledetail_title - feedback_explanation - feedback_namehint - all_done _

Slide 17

Slide 17 text

@MOLSJEROEN STRINGS _ @MOLSJEROEN

Slide 18

Slide 18 text

@MOLSJEROEN ADVANTAGES 1. Easy to use 2. Ordering by screen

Slide 19

Slide 19 text

@MOLSJEROEN • Examples DRAWABLES - articledetail_placeholder - all_infoicon - all_infoicon_large - all_infoicon_24dp __

Slide 20

Slide 20 text

@MOLSJEROEN DRAWABLES __ @MOLSJEROEN

Slide 21

Slide 21 text

@MOLSJEROEN ADVANTAGES 1. Easy to use 2. Ordering by screen 3. Folder organisation

Slide 22

Slide 22 text

@MOLSJEROEN • • Examples LAYOUTS activity, fragment, view, item or layout - activity_main.xml - fragment_articledetail.xml - view_menu.xml - layout_actionbar.xml _.XML

Slide 23

Slide 23 text

@MOLSJEROEN LAYOUTS _.XML @MOLSJEROEN

Slide 24

Slide 24 text

@MOLSJEROEN ADVANTAGES 1. Easy to use 2. Ordering by screen 3. Folder organisation 4. Autocomplete - based on where and what - camel casing

Slide 25

Slide 25 text

@MOLSJEROEN • • Examples IDS name of Android/Custom view class - tablayout_main - imageview_menu_profile - textview_articledetail_title __

Slide 26

Slide 26 text

@MOLSJEROEN IDS __ @MOLSJEROEN

Slide 27

Slide 27 text

@MOLSJEROEN ADVANTAGES 1. Easy to use 2. Ordering by screen 3. Folder organisation 4. Autocomplete - based on where and what - camel casing 5. Strong typing

Slide 28

Slide 28 text

@MOLSJEROEN • 
 • Examples DIMENSIONS width, height, size, margin, padding, elevation, keyline or textsize - height_all_toolbar - keyline_all_listtext - textsize_all_medium - size_menu_icon ___

Slide 29

Slide 29 text

@MOLSJEROEN DIMENSIONS ___ @MOLSJEROEN

Slide 30

Slide 30 text

@MOLSJEROEN ADVANTAGES 1. Easy to use 2. Ordering by screen 3. Folder organisation 4. Autocomplete - based on where and what - camel casing 5. Strong typing 6. Can be supported by tools

Slide 31

Slide 31 text

@MOLSJEROEN CHEAT SHEET ANDROID RESOURCE NAMING CHEAT SHEET ___ LAYOUTS STRINGS DRAWABLES DIMENSIONS _.XML is activity, fragment, view, item or layout _ ___ __ “all” if reused in ≠ screens is width, height, size, margin, padding, elevation, keyline or textsize IDS __ is name of Android/Custom view class custom part Android view subclass fixed set of options differentiate multiple elements in one screen always optional e.g. activity_main.xml all_done e.g. main_intro [xdp] or bucket [small] main_background e.g. all_infoicon_small e.g. linearlayout_main_fragmentcontainer e.g. keyline_all_text choose the right one below @MOLSJEROEN

Slide 32

Slide 32 text

@MOLSJEROEN 1. Easy to use 2. Ordering by screen 3. Folder organisation 4. Autocomplete 5. Strong typing 6. Can be supported by tools CONCLUSION ___

Slide 33

Slide 33 text

@MOLSJEROEN REFERENCES AND IMAGE CREDITS • Blogpost http://jeroenmols.com/blog/2016/03/07/resourcenaming • Source code https://github.com/JeroenMols/ResourceNamingExample • Welcome image credit https://pixabay.com/p-642689/

Slide 34

Slide 34 text

@MOLSJEROEN MANY THANKS ▸ Jeroen Mols (Belgium) ▸ @MolsJeroen ▸ http://jeroenmols.com/blog