設計思想

「設計思想」の編集履歴(バックアップ)一覧に戻る

設計思想 - (2007/11/27 (火) 19:58:36) の編集履歴(バックアップ)


アンドロイドアプリケーション設計思想

たとえプラットホーム自体がひどく異なるとしても、新しいAPIのためにアプリケーションを造る方法を学ぶプロセスはかなり類似しています。

Generally, there are two phases: first, you learn how to use the APIs to do what you want to do; later, you learn the nuances of the platform. Put another way, first you learn how you can build applications; later, you learn how you should build them.
通常、2つの段階があります:
最初にしたいことをするためにAPIを使用する方法を学びます;
次にプラットホームの差分を学びます。

これとは異なる方法として
最初にどのようにアプリケーションを構築することができるかについて学びます
次にどのようにそれらを造らなければならないかについて学びます


That second phase — learning the right way to build applications — can often take a long time, and frequently means "paying your dues", making mistakes, and learning from them. Well, that's not a very efficient process, so this page and the links below aim to give you a helping hand.

その第二段階 — アプリケーションを構築する正しい方法を学ぶこと —
長い間「あなたの会費を払ったうえで間違った方法を学んでいることはよくあります。
れはあまり効率的なプロセスでないので、このページと下のリンクはあなたに援助の手をしようとします。


Before we dive into it, a quick word. Successful applications will offer an outstanding end-user experience. While the Android team has built a robust core system, the vast majority of the user experience will come from users interacting with your applications. As a result, we encourage you to take the time to build an outstanding user experience.

An outstanding user experience has three key characteristics: it is fast; it is responsive; and it is seamless. Of course every platform since the dawn of computing has probably cited those same three qualities at one time or another. However, each platform achieves them in different ways; the information below explains how your apps can achieve them on Android.

顕著なユーザー経験には、
3つの鍵となる特徴があります:
  • 速い
  • レスポンスに優れる;
  • シームレスに動きます。

もちろん、かつてコンピューティングの始まりからあらゆるプラットホームは、その3つの特性をおそらく掲げているだろうが、各々のプラットホームは、それら異なる方向において成し遂げます;

下記の情報は、アプリがどのようにAndroidの上でそれらをできるかについて説明します。

Fast
An Android application should be fast. Well, it's probably more accurate to say that it should be efficient. There is a tendency in the computing world these days to assume that Moore's Law will solve all our problems — eventually. When it comes to embedded applications, though, Moore's Law is a bit more complicated.

Androidアプリケーションは速くなければなりません。速くするには効率的でなければならないと言うことは明白です。
ムーアの法則がこれらの問題を解決すると仮定するとして、近頃のコンピューティングの傾向である。
組込形アプリケーションに関しては、ムーアの法則はもっと複雑である


Moore's Law doesn't really apply to mobile devices in the same way as to desktop and server applications. Moore's Law is actually a law about transistor density — that is, it says that you can pack more circuitry into a given chip size, over time.
ムーアの法則は、デスクトップとサーバーアプリケーションにと同様にモバイル機器に本当にあてはまりません。
ムーアの法則は、実はトランジスタ集積についての法則です
それは、時間とともにより多くの回路を決められたチップサイズに集積することができると言うことです。


For desktop and server applications, this means you can pack more "speed" into a chip of roughly the same size, resulting in the well-known performance increases. For embedded applications like cell phones, however, Moore's Law is usually exploited to make chips smaller. That is, the tendency is to use the increased density to make the same chip smaller and consume less power, to make phones smaller and make batteries last longer.
デスクトップアプリとサーバーアプリのために、同じサイズのチップでも速度をに集積することができることを意味します。
知ってのとおりパフォーマンス増加に終わります。
しかし、携帯電話のような組込形アプリケーションのでは、ムーアの法則は通常チップをより小さくするために利用されます。
つまり、傾向は同じチップをより小さくして、より少ない力を消費するために増加した密度を使うことです。
電話をさらに小さくして、バッテリーを長く持続させます。


As a result, embedded devices like phones are increasing in actual, raw speed much more slowly than desktop systems. For embedded devices, Moore's Law means more features and better battery life; increased speed is only an afterthought.

That's why it's important to write efficient code: you can't assume that phones will see the same speed increases as desktops and servers. Generally speaking, writing fast code means keeping memory allocations to a minimum, writing tight code, and avoiding certain language and programming idioms that can subtly cripple performance. In object-oriented terms, most of this work takes place at the method level, on the order of actual lines of code, loops, and so on.

The article on Writing Efficient Android Code will give you all the detail you need to write fast, efficient code for Android.

Responsive
It's possible to write code that wins every performance test in the world, but that still sends users in a fiery rage when they try to use it. These are the applications that aren't responsive enough — the ones that feel sluggish, hang or freeze for significant periods, or take too long to process input. In Android terms, applications that are insufficiently responsive will frequently cause the system to pop up the dreaded "Application Not Responding" (ANR) message.

Generally, this happens if your application cannot respond to user input. For example, if your application blocks on some I/O operation (frequently a network access), then the main application thread won't be able to process incoming user input events. After a time the system will conclude that your application has hung, and give the user the option to kill it. Similarly, if your application spends too much time building an elaborate in-memory structure, or perhaps computing the next move in a game, then again the system will conclude that your application has hung. It's always important to make sure these computations are efficient using the techniques above, but even the most efficient code still takes time to run.

In both of these cases, the fix is usually to create a child thread, and do most of your work there. This keeps the main thread (which drives the user interface event loop) running, and prevents the system from concluding your code has frozen. Since such threading usually is accomplished at the class level, you can think of responsiveness as a class problem. (Compare this with basic performance, which was described above as a method-level concern.)

The article on Building Responsive Android Applications discusses responsiveness in detail.

Seamless
Even if your application is fast and responsive, it can still annoy users. A common example is a background process (such as an Android Service or IntentReceiver) that pops up a UI in response to some event. This may seem harmless, and frequently developers assume that this is okay because they spend most of their time testing and using their own application. However, Android's application model is constructed explicitly to allow users to fluidly switch between applications. This means that when your background process actually fires up that UI, the user could be way over in another part of the system, doing something else — such as taking a phone call. Imagine if the SMS service popped up a dialog box every time a text message came in; this would annoy users in no time. That's why the Android standard is to use Notifications for such events; this leaves the user in control.

That's just one example; there are many more. For example, if Activities don't correctly implement the onPause() and other lifecycle methods, this will frequently result in data loss. Or, if your application exposes data intended to be used by other applications, you should expose it via a ContentProvider, rather than (for example) using a world-readable raw file or database.

What those examples have in common is that they involve cooperating nicely with the system and other applications. The Android system is designed to treat applications as a sort of federation of loosely-coupled components, rather than chunks of black-box code. This allows you as the developer to view the entire system as just an even-larger federation of these components. This benefits you by allowing you to integrate cleanly and seamlessly with other applications, and so you should design your own code to return the favor.

This is a component-level concept (as opposed to the class- and method-level concepts of performance and responsiveness, described above.) The article on Integrating with the System provides tips and best practices for writing code that cooperates nicely with the rest of the system.
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。