youngy
youngy

Reputation: 15

Vaadin7 architecture

We are currently planing our project and decided to use Vaadin. Right now we are a bit stuck figuring out how we could organize our code quite well without spending to much time. It seems MVP is a good practice for vaadin, but we are all new to the framework and it seems that quite a few people are really struggling with it. During our research we noticed that there are only very abstract tutorials and outdated frameworks. In the vaadin book also a layered architecture is recommended which we wanted to use. Our application isn't too complex (comparable to a usual businessbackend). Is there maybe an elegant and simple solution to decouple the view,while also using the Designer? We are also planning to use Spring Security and UI. Thanks in advance

Upvotes: 1

Views: 113

Answers (1)

Alex Roig
Alex Roig

Reputation: 1574

In my latest project I'm using Spring alongside with Vaadin and, although lots of boilerplate is added, your classes will be smaller, better organised, with single responsibility. In my case, I follow the architecture below:

  • Layout: class that contains the UI elements and it's design/layout.

  • Controller: handles all the events and user actions that a layout has. A controller only responsible of a single layout.

  • View: View class is the main "controller" for a specific URI fragment. If it gets too complex or with subviews, a controller class is created and injected.

  • Service: contains the business logic of the data. While the "Controller" handles the user interaction, the service is responsible of the business logic and data.

  • Repository: SpringData JPA repositories. Implement the CRUD operation and custom queries.

  • Model: Database entities.

Extra packages:

  • Event: I recommend using EventBus alongside the application.

  • Helpers: For that stuff that you don't know where it really fits in.

  • Configuration: Configuration and properties fetched from application.properties (if using SpringBoot).

Using this pattern you'll avoid ending up with spaghetti code and mixing up responsibilities on the same class. Regarding the Vaadin Designer, with this pattern it's completely independent as your layout can either be pure java or the pseudo-html.

Upvotes: 1

Related Questions