A question about the MVP design in the Vaadin book

Hi there! It’s my first time using Vaadin and I was looking for a more MVC-centric approach when I saw
Chapter 11 of the Vaadin book
presenting the MVP pattern. I just have a question…

As the code sample shows, the CalculatorViewImpl created an ArrayList of CalculatorViewListeners and I was wondering why store it in a List if there’s going to be only one Listener?

I’m not sure if I understand correctly.

Hey Miguel,

it just fits to the common concept of listeners. In vaadin you always see a list of listeners instead of a single one. The upside is simple: you easily can extend your application if you need another listener. Also it feels more native if you see a addXYListener method when working with vaadin.
The dowside of course are the lost resources. But I think you can ignore that mostly.

Some MVP techniques use multiple presenters (such as
mentioned here
), in which case storing a collection of listeners (observers) would be necessary. I’d think it’s a good practice to not limit such needs if it’s not too much trouble.