==== Lecture ====
Section 2 Module 1 Part 7: Programming Bound Services with Messengers (Part 1) (10:50)
two-way communication
A pair of Messengers are used conurrently.
e.g., A Unique ID generator App.
The activity calls bindService() on onStart().
The service returns a reference to a Messanger via the onBind().
The activity receives this reference via the onServiceConnected().
The activity send a message containing a reply Messenger by using this reference.
The service receives the message via the handleMessage().
The service returns a message and the activity displays the result.
Broker & proxy pattern.
How to stop a bind service? => unbind(), unbindService().
If all clients is disconnected from the service, unbind() is called.
"hybrid" with Bound & Started Services => rebind().
Section 2 Module 1 Part 8: Programming Bound Services with Messengers (Part 2) (12:51)
It is easy to understand what the bound service do with the diagram on this Lecture.
If the service carshes, onServiceDisconnected() is called.
Section 2 Module 1 Part 9: Overview of the Android Interface Definition Language and Binder Framework (12:48)
AIDL & Binder: mimics Java object.
ex. Async/Sync Download Application
remote procesure call, serialize (marchaling, demarshaling)
Marchaling is tedious & erro-prone, so AIDL is needed.
AIDL is similar to Java interface. AIDL Compiler makes stubs and proxys.
Apps rarely access the Binder directly.
The Binder Driver runs in the Linux kernel.
AIDL is used on Java, as well as C/C++.
The default is sync. (two-way)
It is can be possible to do async opration with one-way methods.
To avoid race condition is needed by developers.
AIDL apply Broker pattern.
Section 3 Module 1 Part 1: The Monitor Object Pattern (Part 1) (12:45)
Minitor Object is used by Moniter Condtion and Monitor Lock and etc.
It gives sync method to other object.
acquire, release, wait, notify, notifyAll
Monitor Object can be used on C++.
Drawback: scale, multiple shared object
Section 3 Module 1 Part 2: The Monitor Object Pattern (Part 2) (12:14)
LikedBlockingQueue
public methods => ex. syc put() ,syc take()
private methods => ex. enqueue, dequeue
Monitor Object has Monitor Lock and Monitor Condition.
AtomicInteger is used.
Thread Safe Interface pattern
Guarded Suspension pattern => put() uses this pattern to wait for space to became available. take() also uses this pattern.
Monitor Object Pattern is implemented with java.util.conccurrent classes rather than java's built-in monitor objects.
Invariants => the values is not changed by others as long as lock is acquired.
Object-specific invariants must hold as threads suspend & resume their execution.
Week 7 Assignment 6: Solution Walkthrough
To fix the manifest, It is OK to add 'export="false"' or add a permission or just remove the intent-filter.
To fix LoginActivity, It is also OK to get the password by GUI or something each time instead of storing the login.txt on the storage.
==== Quiz ====
1st attempt: 31/32
2nd attempt: 32/32
==== Assignment ====
[Week-8-Assignment-7]
synchronize? => not used.
try/catch? => for the functions throwing exception only.
e.printStackTrace or log or toast? => printStackTrace because it can be printable on Android logcat.
try/finally, final, this, private, volatile, Lock, 初期化, fair, non-fair
static, join, interrupt, @Override
constructorはlock不要。(W2-A1と同様)
volatileを使えばcacheの一貫性は保てる? => yes.
Uninterruptiblyでもtry/finallyするべき? => yes?
countのreturnでもlock必要? => no. volatileなら不要。
ローカル変数も初期化すべき? finalをつけるべき? => yes? 講師はfinal派?
thisはつけるべき? => 付けていない人の方が多い感じなのでつけないで命名規則で。
インスタンス変数にはmXxxxの名前にすべき? => yes.
importのunusedがある場合は親クラスとして使うかもしれない。
weekreferenceはgetで本体を取り出せる。
とにかくLectureに大体は例がある。
さらにForumをみれば大体疑問点は出尽くしている。
VOHでは提出済のモノは詳しい説明あり。提出前のモノは簡単な説明ある。
Your work was submitted. Review your work to make sure everything looks OK.
のリンクから提出状況を確認できる。submit直後のみ。
[Evaluation]
Self
ClassName.this is used as a concext.
printStackTrace() is used.
S1
getBaseContext() is used as a context.
S2
getApplicationContext() is used as a context.
Throwing the exception is added instead of catching the exception.
S3
Null checking to stub variables is added.
S4
Log.e() is used.
S5
Null checking to stub variables is added.
getApplicationContext() is used as a context.
[Results]
I've got 18 points and one suggestion below.
// Use an AsyncTask so the twoway mDownloadCall doesn't
// block the UI thread and displayBitmap is called on
// the UI thread.
==== Etc ====
[Eclipse]
.classpath was modified by Eclipse when the file was imported as an eclipse project.
I checked the other assignments' .classpath and .classpath of this assignment seems wrong.
I also checked the forum of this course but only one unresolved topic is about this...
Should I post something about this on the forum?
==== log ====
2014/06/30 00:40 Lecture
2014/07/01 00:40 Lecture
2014/07/02 00:20 Quiz
2014/07/02 00:45 Lecture & Quiz
2014/07/06 00:30 Assignments
2014/07/11 00:40 Lecture
2014/07/13 02:30 Assignments
2014/07/13 00:10 Assignments
2014/07/19 01:00 Evaluation
2014/07/20 01:00 Evaluation
2014/07/22 00:10 Result
0 件のコメント:
コメントを投稿