「mハンガリアン記法」について自ブログでも発射!!

以前から反対していましたが

Jake WhartonさんはTwitterを使っています: "Someone, somewhere made the decision to use hungarian notation for Android Java sources. I think they owe the community an apology."

ついに自ブログでも言及しています.

Just_Say_mNo_to_Hungarian_Notation_-_Jake_Wharton

Just Say mNo to Hungarian Notation - Jake Wharton

「Androidのサンプルコードが利用している」
→ サンプルコードはAPSPで生まれそのAOSPスタイルに固執しているだけ.

「コードレビュー時に役に立つ」
→ 変更時に更新忘れしたものかもしれない.

「開発時に役立つ」
→ IDEがそれぞれ正しく表示してくれる.
→ 変更忘れが発生する.

「Google のようにコードを書きたい」
→ GoogleやAOSPの一部の会社はハンガリアン記法を禁止している.

WikiPedia をみてみる.

システムハンガリアンを使っているソースコードを修正してデータ型を変更した際、同時に変数名も変更するコストがかかる。変更を怠ると、たちまち不整合となり、保守の障害となるだけで一利もない。

C++やC# のような言語では型付けが存在するためにシステムハンガリアンを使用することによる利点はない。移植性を阻害する。

総称型、メタプログラミングとの相性が悪い。

いわゆる良書と呼ばれるようなC++本で、現在システムハンガリアンを採用している例が皆無。

かつてMFCにおいてハンガリアンを全面的に採用していたMicrosoft自身が、.NET Frameworkではハンガリアンを禁止している。

日本では、情報処理技術者試験などのC言語の問題でシステムハンガリアンが使用されていない。

結局,「IDEの進化」が大きく影響しているといえそう.

間違えたコードが機械的に検出される手法が利用可能ならば、間違えたコードが間違えて見える手法より明白に勝る。

エラー検出に関連する技術は、ハンガリアン記法が考案され成功を収めた当時と比べ大きく進歩している。

コードを間違える原因の中で、変数の意味(=型)の取り違えに由来するものが下位にあるとは言い難い。

ハンガリアン記法 - Wikipedia

なので, Android Studio での設定を.

[Preference] から.

color

prefix

技術も開発手法も変わっていくものなのですね.

Android Code Style で インデントはスペース何個?


Android Studio 使えるエディタのテーマを「Color Themes」

IDEのエディタのテーマ集があります.

Color_Themes

Color_Themes 2

Color_Themes

Color Themes

ダウンロードしてインポートするだけ.

How to install a theme?

Select «File» → «Import Setting» from the main menu and follow the instructions. After the IDE restarted go to the Preferences, expand «Editor» → «Colors and fonts» tab and choose the installed theme.

IntelliJ IDEA に使えるということで AndroidStudio でも使えます.

Which IDEs are supported?

Themes on this site support fully all family of JetBrains' IDEs: IntelliJ IDEA, PhpStorm, PyCharm, RubyMine, WebStorm and AppCode.

y-a-r-g/color-themes


Android Studio「Instant Run」の適用範囲や条件

実際使ってみると, 編集したコードが反映されたりされなかったり.

でも確かに高速なときもある.

効果的に高速で動作してくれるためのコードの編集範囲・条件は何なのか.

Instant_Run_-_Android_Tools_Project_Site

Instant Run - Android Tools Project Site

分かりづらいので表に.

instantrun

なんだか...

it seems that this feature is not perfectly stable yet : sometimes the modified code is marked as “pushed” whereas the modification is not really applied on the emulator. It is currently stable when it comes to hot resources or xml file swapping. It is really a great improvement, as we generally have to perform numerous incremental builds when we are tuning our xml files.

Reduce your Android build duration | OCTO talks !

みんなも上手に「Instant Run」を使って高速にアプリを開発しよう!!


Android世界有名技術系タレントたちのブログをまとめて取得する

どうしても日本語の記事では量が少なく, 更新タイミングも少し遅くなる.

こんな有名なタレント群のブログをまとめてくれています.

ziem_android-development-blogs

ziem/android-development-blogs

OPMLやCSVでダウンロードできるのでRSSリーダやその他クライアントで一括で取り込んで読みましょう.

RSSフィード情報をOPML形式でインポート/エクスポートする | feedlyの使い方 | ぼくらのハウツーノート

私の Feedly はこんなんなりましたけど.

Android_Development

しかしこの人たちはすごいなあ.

あの「Hacker News」で ベストなストーリーを見つける方法


8.4.0 なのに「updating the version of com.google.android.gms to 8.3.0」

このように怒られ,

Execution failed for task ':app:processDebugGoogleServices'. Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 8.3.0.

build.gradle を見ると「8.4.0」

apply plugin: 'com.google.gms.google-services'
...
dependencies {
  ...
  compile 'com.google.android.gms:play-services-gcm:8.4.0'
  ...
}

こんな答えだと.

android - Version conflict updating to 8.4.0 - Stack Overflow

...
dependencies {
  ...
  compile 'com.google.android.gms:play-services-gcm:8.4.0'
  ...
}

// 最終行にもってくる
apply plugin: 'com.google.gms.google-services'

 

まとめ

build.gradle (project-top)

...
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
        classpath 'com.google.gms:google-services:2.0.0-alpha3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
...

build.gradle (app-module)

...
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    ...
    compile 'com.google.android.gms:play-services:8.4.0'
    ...
}
apply plugin: 'com.google.gms.google-services'

おつかれさまでした.

google-services_build_gradle_at_master_·_googlesamples_google-services

google-services/build.gradle