9
votes
Accepted
Angular 2 clock with RxJS Observable
Your service looks perfectly fine to me. As far as the Clock component goes, I can only recommend one thing.
When ...
8
votes
Accepted
Observer pattern written in C++
Overuse of abstract base classes
In your code, you have way too many abstract base classes. Most of them are not necessary. In fact, you only need a base class for the observer. Its ...
7
votes
Implementation of Observer Pattern in C++14
I'm not sure we really need a base Observable class to inherit from anymore, because with lambdas and function type erasure, this pattern has become more or less trivial.
But if you want to do it ...
6
votes
Accepted
Observer pattern using a set of observers and delegated properties
You don't need a wasPresent variable. MutableSet.add returns true if the ...
5
votes
Accepted
Scheduling using System.IObservable 2.0
1) int as time interval is ambiguous. TimeSpan is not. So I would use the latter.
...
5
votes
Accepted
Angular service for fetching and passing data with observables
One of the improvements would be to use an HttpClient instead of Http for making the API calls.
If you use ...
5
votes
Accepted
Simple event dispatcher
Design
Is there a need for IEventDispatcher? Defining it as an abstract base class doesn't provide much utility if there's only ever going to be one derived class.
...
5
votes
Accepted
Implementing the observer pattern for a stock exchange scenario
Make immutable class members const
If you have a member of a class that is set once at construction time, but will never change, then make it const. For example, in ...
5
votes
Accepted
Observer Design Pattern in C++ to model magazine subscriptions
Answers to your questions
I know using namespace std isn't good [...] Please tell me if I'm doing anything wrong or if there is anything that can be improved.
...
5
votes
Dependency problem with field changes
This is a tough one. I can see what you are trying to achieve, and your solution obviously works, but your own spider senses are already tingling that this is not the ideal solution. So why is that?
...
4
votes
C++ implementation of the observer design pattern
Design Review
Ownership
One of the advances of C++ over is C is ownership semantics. We understand who owns an object (and thus who is responsible for destroying the object). We do this by using a ...
4
votes
Accepted
Java Pub Sub implementation using broker
First of all, mutex should be final, since you are synchronizing on it. In the current state of your code, it wouldn't make much ...
4
votes
Generic Observer/Listener implementation in Java
API
Besides the obsever management (add/remove one), an Observable should only expose a get() and a ...
4
votes
Dependency problem with field changes
It's an interesting question, and the code is a little complex but not bad. Here are some things that may help you improve it.
Initialize all members
The constructor for Person initializes every data ...
4
votes
Accepted
My C++ Implementation of the Observer Pattern
About the observer design pattern
The design patterns from the "Gang of Four" focus heavily on solving problems using classes. However, in modern C++, there are other ways to solve the ...
3
votes
Accepted
3
votes
Observable Object
Avoid convenience aliases unless it really improves the code
You created the type alias enable_, but it is only used twice. Furthermore, if you wouldn't have seen ...
3
votes
C++ implementation of the observer design pattern
Potential Bugs
You don't define virtual destructors for Observer and Subject. This makes code such as
...
3
votes
Accepted
News reading application version 2
You were interested in a review in both the pattern as code style.
Note: I'm addressing subscribers also as listeners and observers in this review.
Code Style
Prefer ...
3
votes
Apply stock quote changes using observer pattern
1. If you are implementing this pattern for learning, then it is OK.
Otherwise, you can use built-in Observer Pattern of C#.
2. Think about readable:
...
3
votes
Accepted
Notify observers when object attributes update
To give you valuable feedback on your usecase, I would need more information, like: How do listeners listen? How does the caller look like?
How exactly does ...
3
votes
Generic Observer/Listener implementation in Java
Unit tests
Dive into that; it is relative simple. Then you are doing TDD, Test Driven Development. You can keep those tests in the project, and future changes with regression errors then will be ...
2
votes
Accepted
Reusable Implementation of the Publish-Subscribe Pattern
Receiver
Data is a placeholder denoting a generic type. In Java, generics are pointed out with a single-letter literal (most often, ...
2
votes
Accepted
WPF async ObservableTaskQueue class
So, there's a lot going on here. First things first, this class is really doing too much. It's running a queue of tasks one after the other, it's handling retrying errors, it's adding a delay ...
2
votes
Angular - reusing an observable for different queries
There's nothing (obviously) wrong with your code. You deal with observables the efficient way, IMO. Cache is good. The fact you're constructing a "base" observable in constructor without subscribing ...
2
votes
Accepted
Observable Logger
The only issue I see is the Subject class implements IDisposable and should be disposed of. Which would mean your ILoggerFactory now needs to be IDisposable.
(Taken from MS documentation)
...
2
votes
Accepted
Observable implementation
There is quite a lot of "almost similar" code due to the fact that you
treat "value observers" and "result observers" separately:
Two classes
...
2
votes
Observer pattern for temperature and pressure sensors
The way how you use pointers is quite dangerous and C++ has tools to make this totally safe.
The biggest problem of your implementation is the usage of possibly dangling pointers in your subject ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
observer-pattern × 100c# × 26
c++ × 23
design-patterns × 17
javascript × 15
java × 14
event-handling × 7
multithreading × 6
angular-2+ × 6
object-oriented × 5
c++11 × 5
typescript × 5
async-await × 5
timer × 5
scheduled-tasks × 5
rxjs × 5
rust × 4
generics × 4
system.reactive × 4
android × 3
template × 3
callback × 3
weak-references × 3
python × 2
beginner × 2