Udacity Code Review Suggestions

来源:互联网 发布:淘宝分享链接打不开 编辑:程序博客网 时间:2024/04/30 13:13

昨天提交了Udacity Android Developer Nanodegree Program的第一次作业,今天给了答复,还有些批注。其实就是一个针对我个人代码风格的及其具有针对性的专业化建议,实在是个好东西,这里必须记下来。

  • Similar to how it is a good practice to keep your labels and prompts inside of the Strings.xml file, it is also a good practice to keep your colors inside of the colors.xml file.

  • Nice choice for the identifiers names. Good selection of identifiers makes a huge difference when your application gets more complicated.

    <Button        android:id="@+id/spotify_btn"        ............>
  • Your buttons share a lot of common attributes. It may be a good idea to create a Style and place all of the common attributes inside of that style. Doing so you will achieve two things:

    1. If you decide to change the style of your buttons one day you will be able to make the change across the whole application by making a change in the single place
    2. Your layouts will become a lot shorter, because you will be able to remove repetitive lines of code.

    (style相当于把多个view的相同属性提取出来,而且更方便的是,个别view有例外的属性时可以像之前一样定义,不受影响。)

0 0
原创粉丝点击