I am currently working on three Vaadin applications and I really feel like I miss something. I used to work with Spring MVC before, where architecture is clear and decoupled, you inject services to controllers and don't couple controller to UI and so on.
Now in Vaadin that's different story. So if there are any Vaadin specialists out there, let me ask you few questions:
Question 1:
Question 2:
Question 3:
I'd like to learn as much as possible about good design with Vaadin before my code turns to Spaghetti, so any suggestions, experience and best practices would be appreciated.
We've had very good luck using the MVVM pattern (aka Fowler's PresentationModel). His docs are a bit old, but a good starting point.
After you've read that, my answers may make more sense
No. Inject your services into your ViewModel. The ViewModel will be a Facade (and can encapsulate Adapters, Decorators, Caches and any other Patterns you decide you need)
I didn't see a question here, but we do have a situation similar to what you're describing. We use Guava's EventBus to communicate between decoupled components. In this way, if you need to pop up a new window, you can: eventBus.post(new NewWindowRequest(theComponent))
And your main application can be subscribed to the same event, then pop up the window.
MVVM and cautious use of EventBus can help. Also, Vaadin's BeanItem and ObjectProperty can be used to propagate changes, as they're part of Vaadin's built-in observer/data-binding pattern.
I recently did a presentation on MVC vs MVP vs MVVM. The example code may help you understand the shift from MVC to MVVM. It is written in JavaScript, but it is simple enough that I believe most anyone can follow it. I welcome any feedback you might have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With