> For the complete documentation index, see [llms.txt](https://ondrej-kvasnovsky-2.gitbook.io/vaadin-on-grails-3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ondrej-kvasnovsky-2.gitbook.io/vaadin-on-grails-3/chapter1/best_practices.md).

# Best Practices

## Keep work with GORM in Services

Never work with GORM in Vaadin code, use services or any other layer, like DAO, to encapsulate work with database. It will keep your Vaadin and database code separated, which will make the application code more readable and maintainable.

## CompileStatic

Use `@CompileStatic` annotation everywhere you can. The exception not to use the annotation is dynamic code where you need to utilize dynamic features of Grails, for example, to access variables that are not visible during compilation.

## Types

Use `def` only when it is required, because it always good to know type of a variable. Together with `@CompileStatic` annotation, you will know about compilation errors during compilation, not during runtime.
