18/09/2006

Design Patterns-Model-View-Controller-Observer Pattern

1.1 OBSERVER TASARIM DESENİ
1.1.1 DESEN KATEGORİSİ
Davranışsal (behavioural) tasarım deseni kategorisinde yer almaktadır.
1.1.2 AMAÇ
1 - N ilişkisi olan nesnelerden, birinde durum değişikliği meydana geldiğinde, o nesneye bağımlı olan diğer nesnelerin haberdar edilmesi amacıyla kullanılır.
1.1.3 UYGULANABİLİRLİK
“Observer” tasarım desenin aşağıdaki durumlarda kullanılması uygundur.
· Bir soyutlamada birinin diğerine bağımlı olan bir yönü varsa. (Bu iki tarafı – bir taraf ve ona bağımlı olan diğer tarafı- farklı nesnelerde enkapsüle etmek onların bağımsız olarak tekrar kullanım şansını arttıracaktır.)
· “Subject” nesnesinin kaç tane “observer” nesnesine sahip olduğunu bilmediği durumlarda.
· “Subject” nesnesinin “observer” nesnelerinin kim olduğunu bilmeden onları bilgilendirmesi gerektiği durumlarda.
1.1.4 GENEL DESEN YAPISI
“Observer” arayüzündeki “notify()” metodu “ConcereteObserverA” ve “ConcereteObserverB” sınıflarımda farklı şekillerde gerçekleştirilmektedir. “Subject” arayüzünde ise “registerObserver(observer)”, “unregisterObserver(observer)” ve “notifyObservers()” metodları tanımlanmıştır.

OBSERVER PATTERN

In our new, more sophisticated windowing world, we often would
like to display data in more than one form at the same time and have all of the
displays reflect any changes in that data. For example, you might represent
stock price changes both as a graph and as a table or list box. Each time the
price changes, we’d expect both representations to change at once without
any action on our part.
We expect this sort of behavior because there are any number of
Windows applications, like Excel, where we see that behavior. Now there is
nothing inherent in Windows to allow this activity and, as you may know,
programming directly in Windows in C or C++ is pretty complicated. In Java,
however, we can easily make use of the Observer Design Pattern to cause our
program to behave in this way.
The Observer pattern assumes that the object containing the data is
separate from the objects that display the data, and that these display objects
observe changes in that data. This is simple to illustrate as we see below.

When we implement the Observer pattern, we usually refer to the
data as the Subject and each of the displays as Observers. Each of these
observers registers its interest in the data by calling a public method in the
Subject. Then, each observer has a known interface that the subject calls
when the data change. We could define these interfaces as follows:

abstract interface Observer {
//notify the Observers that a change has taken place
public void sendNotify(String s);
}

//=============================================
abstract interface Subject {
//tell the Subject you are interested in changes
public void registerInterest(Observer obs);
}

The advantage of defining these abstract interfaces is that you can
write any sort of class objects you want as long as they implement these
interfaces, and that you can declare these objects to be of type Subject and
Observer no matter what else they do.


4 comments:

Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

Anonymous said...

adjulficidali [url=http://wiki.openqa.org/display/~buy-cytotec-without-no-prescription-online]Buy Cytotec without no prescription online[/url] [url=http://wiki.openqa.org/display/~buy-motilium-without-no-prescription-online]Buy Motilium without no prescription online[/url]

Anonymous said...

Yes if the truth be known, in some moments I can phrase that I jibe consent to with you, but you may be making allowance for other options.
to the article there is stationary a suspect as you did in the decrease efflux of this demand www.google.com/ie?as_q=ultra mp3 to cd burner 1.6.0 ?
I noticed the utter you have not used. Or you profit by the dark methods of development of the resource. I suffer with a week and do necheg

Anonymous said...

маленький человек, когда он хочет работать, - непобедимая сила! Работай с умом, а не до ночи. Перед тем, как что-то сделать, - сначала подумай. Богу угодно качество нашего труда, а не его количество. Когда труд - удовольствие, жизнь - хороша! Не то забота, что много работы, а то забота, как ее нет. Бездельника и лентяя бог ничем не наградит. Кто ничего не хочет по жизни делать, тот только на это всю жизнь и работает.

[URL=http://vakansiy-ru.ru/wordpress-537.html]Работа для иногородних в москве[/URL] [URL=http://vakansiy-rus.ru/wordpress-341.html]Работа в маскве[/URL] [URL=http://mynmy.ru/wordpress-240.html]Работа сегодня вакансии[/URL] [URL=http://vakans-ru.ru/wordpress-85.html]Вакансии вахтовым методом в москве[/URL] [URL=http://vakansiy-russ.ru/wordpress-425.html]Работа сварщиком в москве[/URL] [URL=http://vakansii-russ.ru/wordpress-198.html]Работа север вахта[/URL] [URL=http://vakansii-rus.ru/wordpress-578.htm]Работа супервайзер[/URL] [URL=http://vakansii-rf.ru/wordpress-111.html]Работа в королеве мытищах[/URL] [URL=http://vakansiy-rf.ru/wordpress-368.html]Предложение вакансий[/URL] [URL=http://vakansii-ru.ru/wordpress-494.html]работа для девушек в москве[/URL]