Slice concepts - 4.4

Separation of concerns

The framework is based on the presentation model pattern which means that your views (JSP files) determine which presentation model to use (Java classes) to return underlying data (a Java class with repository data). Thanks to this you don't have to write business logic of your components in JSPs any more.

In Slice, your JSP files are strictly the presentation layer. Data to be displayed are defined in a corresponding Java class - the only thing a JSP file needs to do is to output the data. No business logic in JSP.

Business logic is contained in a Java model. The Java class can fetch data from repository, manipulate them - do the business logic - and prepare to be displayed by a JSP script.

Data coming from repository can be automatically mapped to Java objects using built-in object-resource mapper (ORM)

Modularity and dependency injection (DI)

Slice is strongly based on the dependency injection and Guice. Thanks to this you can let Guice to provide you some objects which are required by your class, instead of creating them and passed "manually". Read more about Guice and DI here.

Slice is a framework designed having modularity in mind. We divided it into a number of modules, and you can add yours too. Modularity of the framework is achieved using Guice. You might be a little bit surprised that OSGi is not the key point of modularization. It was chosen because we'd like to have the ability to inject any object, not only OSGi components/services.

However, you will still use OSGi bundles but inside your application bundles there will be Guice dependency injection framework.

Guice

If you haven't used Guice before, we strongly advise you to read at least these couple of pages from Guice documentation:

AEM components with Slice

Slice organizes the development of AEM components as it introduces common patterns to development and makes common operations (like reading data from repository) much easier. See the diagram below which depicts a basic differences between components written with and without Slice.