Building Android Apps 30条建议

Building Android Apps — 30 things that experience made me learn the hard way

There are two kinds of people — those who learn the hard way and those who learn by taking someone’s advice. Here are some of the things I’ve learned along the way that I want to share with you:


  1. Think twice before adding any third party library, it’s a really seriouscommitment;
  2. If the user can’t see it, don’t draw it!;
  3. Don’t use a database unless you really need to;
  4. Hitting the 65k method count mark is gonna happen fast, I mean really fast! And multidexing can save you;
  5. RxJava is the best alternative to AsyncTasks and so much more;
  6. Retrofit is the best networking library there is;
  7. Shorten your code with Retrolambda;
  8. Combine RxJava with Retrofit and Retrolambda for maximum awesomeness!;
  9. I use EventBus and it’s great, but I don’t use it too much because the codebase would get really messy;
  10. Package by Feature, not layers;
  11. Move everything off the application thread;
  12. lint your views to help you optimize the layouts and layout hierarchies so you can identify redundant views that could perhaps be removed;
  13. If you’re using gradle, speed it up anyway you can;
  14. Do profile reports of your builds to see what is taking the build time;
  15. Use a well known architecture;
  16. Testing takes time but it’s faster and more robust than coding without tests once you’ve got the hang of it;
  17. Use dependency injection to make your app more modular and therefore easier to test;
  18. Listening to fragmented podcast will be great for you;
  19. Never use your personal email for your android market publisher account;
  20. Always use appropriate input types;
  21. Use analytics to find usage patterns and isolate bugs;
  22. Stay on top of new libraries (use dryrun to test them out faster);
  23. Your services should do what they need to do and die as quickly as possible;
  24. Use the Account Manager to suggest login usernames and email addresses;
  25. Use CI (Continuous Integration) to build and distribute your beta and production .apk’s;
  26. Don’t run your own CI server, maintaining the server is time consuming because of disk space/security issues/updating the server to protect from SSL attacks, etc. Use circleci, travis or shippable, they’re cheap and it’s one less thing to worry about;
  27. Automate your deployments to the playstore;
  28. If a library is massive and you are only using a small subset of its functions you should find an alternative smaller option (rely onproguard for instance);
  29. Don’t use more modules than you actually need. If that modules are not constantly modified, it’s important to have into consideration that the time needed to compile them from scratch (CI builds are a good example), or even to check if the previous individual module build is up-to-date, can be up to almost 4x greater than to simply load that dependency as a binary .jar/.aar.
  30. Start thinking about ditching PNGs for SVGs;
  31. Make library abstraction classes, it’ll be way easier to switch to a new library if you only need to switch in one place (e.g.AppLogger.d(“message”) can contain Log.d(TAG, message) and later realise that Timber.d(message) is a better option);
  32. Monitor connectivity and type of connection (more data updates while on wifi?);
  33. Monitor power source and battery (more data updates while charging?Suspend updates when battery is low?);
  34. A user interface is like a joke. If you have to explain it, it’s not that good;
  35. Tests are great for performance: Write slow (but correct) implementation then verify optimizations don’t break anything with tests.

If you have any questions drop me a tweet @cesarmcferreira!

 

form:https://medium.com/@cesarmcferreira/building-android-apps-30-things-that-experience-made-me-learn-the-hard-way-313680430bf9#.iz9oy4ekc

时间: 2024-07-31 01:03:36

Building Android Apps 30条建议的相关文章

JAVA代码编写的30条建议

JAVA代码编写的30条建议 (1) 类名首字母应该大写.字段.方法以及对象(句柄)的首字母应小写.对于所有标识符,其中包含的所有单词都应紧靠在一起,而且大写中间单词的首字母.例如: ThisIsAClassName thisIsMethodOrFieldName 若在定义中出现了常数初始化字符,则大写static final基本类型标识符中的所有字母.这样便可标志出它们属于编译期的常数. Java包(Package)属于一种特殊情况:它们全都是小写字母,即便中间的单词亦是如此.对于域名扩展名称

央行30条建议勾画自贸区金融改革:便利个人跨境投资

央行12月2日出台<关于金融支持中国(上海)自由贸易试验区建设的意见>(以下简称<意见>),就上海自贸区的金融开放提出30条建议.据21世纪经济报道记者了解,目前央行上海总部已经基本制定好<意见>的相关操作细则,接下来将会向人民银行总行汇报,获批后很快将可发布. 12月2日<意见>发布的当天下午,央行上海总部即召集自贸区内的9家商业银行.3家基金和其他在自贸区有牌照的多家金融机构负责人举行座谈,征求对<意见>的看法及对制定中的细则的意见建议.据与

JAVA代码编写的30条建议 选择自 chinaewolf 的 Blog

1) 类名首字母应该大写.字段.方法以及对象(句柄)的首字母应小写.对于所有标识符,其中包含的所有单词都应紧靠在一起,而且大写中间单词的首字母.例如: ThisIsAClassName thisIsMethodOrFieldName 若在定义中出现了常数初始化字符,则大写static final基本类型标识符中的所有字母.这样便可标志出它们属于编译期的常数. Java包(Package)属于一种特殊情况:它们全都是小写字母,即便中间的单词亦是如此.对于域名扩展名称,如com,org,net或者e

10条建议 着手开始Web2.0实施

专家精选10条建议助你着手构建一个更动态的Web站点,跃入Web2.0时代-- 如今Web2.0的宣传铺天盖地,很难找到一个可靠的策略来让公司的网站更加动态.在这里我们给出10条建议,这些建议均来源于领先的已经铺平道路的专家和IT经理.它们将帮助你接触Web2.0,并且理解它的生产力.力量和存在的问题. 1 使用WordPress或者TypePad开始blog 这两家网站提供免费的hosting和简单的.只需要几分钟就可以掌握的工具.值得关注的还有,两家公司还出售一种公司版本的博客软件(Type

Web入门者必看的HTML代码编写的30条军规

本文总结了30条html代码编写指南,只要在编写HTML代码的过程中牢记它们,灵活运用,你一定会写出一手漂亮的代码,早日迈入专业开发者的行列. 1. 一定要闭合HTML标签 在以往的页面源代码里,经常看到这样的语句: <li>Some text here.   <li>Some new text here.   <li>You get the idea.  也许过去我们可以容忍这样的非闭合HTML标签,但在今天的标准来看,这是非常不可取的,是必须百分百避免的.一定要注意

安全工程师们必看:加强网络环境的9条建议

本文讲的是安全工程师们必看:加强网络环境的9条建议, 在过去半个月中,WannaCry已经让那些网络安全系统管理员的颜面尽扫,只能事后做一些小修小补,客观地讲,截至目前就连安全专家们也无法预料WannaCry将会出现何种变种.对于配有专门的安保专家的大公司来说,网络安全最起码还有个基本的保障,但对个人用户来说,就只能靠自己来进行防护了. 在这篇文章中,我们就为大家提供9条建议,来加固你的网络环境,这9条建议对组织和个人用户来说,都非常有用,而且还易于操作. 建议1:简化你的补丁管理 许多攻击包括

将 Web 应用性能提高十倍的10条建议

将 Web 应用性能提高十倍的10条建议 提高 web 应用的性能从来没有比现在更重要过.网络经济的比重一直在增长:全球经济超过 5% 的价值是在因特网上产生的(数据参见下面的资料).这个时刻在线的超连接世界意味着用户对其的期望值也处于历史上的最高点.如果你的网站不能及时的响应,或者你的 app 不能无延时的工作,用户会很快的投奔到你的竞争对手那里. 举一个例子,一份亚马逊十年前做过的研究可以证明,甚至在那个时候,网页加载时间每减少100毫秒,收入就会增加1%.另一个最近的研究特别强调一个事实,

福布斯:给科技公司CEO们的7条建议

导语:美国<福布斯>杂志网络版周一撰文,给科技公司CEO们提出了7条建议,分别涉及环保.全球消费群体分析.消费和商用市场区分.创新.知识产权保护.汇率操纵和全球经济稳定七个方面. 以下为文章全文: 在一家公司中,CEO是整个公司的灵魂和责任承担者.虽然大家都在讨论团队的作用,但CEO才是公司形象的代表,也决定着一家公司的策略方向. 正因为如此,他们的薪酬也高的惊人.但即便如此,在安德森看来,大部分CEO都只是勉强合格或良好,距离优秀仍有一段距离.他们有时也会犯错,而且通常情况下这些失误带来的影

利用大数据取得成功的7条建议

就在您认为大数据不可能再变大时,它还在不断变大. 无论其实际大小,大数据正在显示价值. 各个地方的组织都有各种形态与大小的大数据. 这些组织意识到其重要性.机遇以及给予关注的迫切需要. 很显然,无论忽略与否,大数据都会不断发展. 已掌控大数据(在明了其价值前储存的多结构混乱数据)的组织正在提升组织效率.提高收益,并发展新的业务模式. 他们是怎样做到的? 这些机构成功的方法可以总结为七条建议. 1.以短期考虑促进长期考虑 担心能否跟上大数据的潮流的人,不止您一个. 一切都瞬息万变,因此无从知道今年