UPDATE:
Looks like the TS does not asking whether to pass interface
instead of class
to the presenter
, but whether the presenter
are communicating to the view
via another layer (let's call observable). It is simply try to reflect MVVM
pattern used in WPF
for the view management. If that's the case then all of my arguments before are invalid.
Personally, I think that the approach is bad and does not give many benefits instead of cons. Here is the points I would like to mention:
Humble view
is already enough for maintainabilityAs stated by the TS, humble view already sufficient for creating testable classes and modular enough for separation of concern / responsibility. You can see the revision of my answer stated that humble view is already maintainable.
It added complexity and learning curve
Unless your approach are supported by built-in distributed library such as WPF, then you are in doom for learning the approach. It is not common and new developers will find it hard to learn your design.
It reduces code discoverability
My experience with WPF is that without proper agreement in folder structure you will find it hard to discover the presenter (because it will refer to observable). WPF have some guidelines with folder structure (called conventions) so new developers which understand WPF will understand it.
Harder to debug
If the binding (listening point) is declared mistakenly, you will get a hard time finding the mistake. Most of the times the mistake gives you wrong exception. Even in WPF, newcomers will find hard to debug.
Harder to ensure property update and more risk for infinite cycle
During developing WPF I find it hard to ensure property update between the view and presenter (viewmodel).
MVVM
design which listen to changes such as Knockout and WPF have higher risk of infinite cycle occuring (change in prop A updates prop B which updates prop A and so on).You baypassed the compiler validation
What I don't like with
WPF
/MVVM
is that the compiler cannot help validate your binding. It means thatnull reference
anddata type error
can only be handled in runtime level.It is not implementable to web apps.
The observable layer may be useful in event-driven apps such as desktop app or even mobile app. However in web apps which structure based on
Request -> Response
it is just a useless layer of abstraction. I have yet found any presenter logic which can be used in both web and apps architecture. If it will be duplicated anyway, why not make it more simpler? MoreoverHumble View
approach may be used (not perfectly, but can) in web architecture.You will need BLL anyway
No matter what architecture you build, you still only handle the code in
PL
level only. You will still needBLL
in another layer to ensure the business logic can be reused no matter what the UI is (web / desktop).The benefit is just another layer of separation
I don't know what you want to approach in java. However in WPF I find it is easier and safer (in terms of not breaking the viewmodel / presenter) to modify the view.
Summary:
With MVP
using observable
, you violate KISS
/ YAGNI
. If you does not use distributed library, you also violate Reinvent the Wheel
. The only benefit is to support for DRY
(to manage data binding) but since it cannot be used in web structure, the benefit is not worth it.