All Questions
7 questions
3
votes
1
answer
678
views
Is Content Observer an implementation of Observer Pattern?
Observer Pattern is defined by the 'Gang of Four' Design Patterns book as a "one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated ...
10
votes
2
answers
3k
views
Is the observer pattern suitable when the observers are not independent of each other?
I have a class Car which has 2 properties: int price and boolean inStock. It also holds a List of abstract class State (empty class). There are 2 states which can be applied on the car and each is ...
2
votes
2
answers
2k
views
What preconditions should be checked while adding/removing a listener?
Imagine the following interface:
interface Service {
addListener(Listener l)
removeListener(Listener l)
}
Should I check for null values while add/remove? Is it a good idea on remove to check ...
4
votes
1
answer
1k
views
I'm always reimplementing observer/subject code in Java. Is there a better option?
I'm always writing observer/subject interfaces in a particular Java project, e.g.:
/**
* Registers the receiver to the dispatcher.
* When data arrives that the receiver can process,
* it will be ...
17
votes
4
answers
47k
views
Which design pattern is more suitable for logging?
I should log some events in a program but as far as I know it would be better to keep the logging code outside the program because it is not about the real functionality of the program. So may you ...
1
vote
1
answer
549
views
how to model a connection to a resource, with rudimentary event processing
For my simple MUD client I'm using Apache Telnet (no, not ssh). A mud client is a strange beast:
Generally, a MUD client is a very basic telnet client that lacks VT100 terminal emulation and the ...
4
votes
1
answer
799
views
Mutual observer pattern in Java
I want to improve my multi-threading and design pattern skills. As such I'm designing an Instant Messaging server.
I'm writing the Server first.
My plan so far is to have Client "Proxy" Classes to ...