After mastering UI mockups for the future Backendless application and designed data schema for all application's data entities a developer gets very close to the coding part. This topic covers the issue of generating a code, but beforehand it is important to describe a core principle of the client-server integration with Backendless.
Every table in a Backendless backend represents an entity. For example of Restaurant-to-Go App, if it is a Restaurant table, it represents and contains Restaurant objects. The same is true for relations. For example, there is a one-to-many relation between the Menu and MenuItem tables. That relation represents the composition pattern in the object-oriented view of the world. Indeed a Menu object may contain one or more MenuItem objects.
The Backendless API uses that concept to the fullest - any time a developer needs to save an object in a table, he/she creates a class instance which corresponds to the table and save it using the API.
It is possible to find out a precise example in the topic that describes how to save objects in Backendless. What this means is the starting point for the coding task is creating the code for the core entities in the application. Some client-side environments call them DTOs (data transfer objects) or VOs (Value Objects).
Whatever the term one would like to use, these are objects which will travel back and forth between the client application and the Backendless servers. These objects will be stored in the Backendless data tables. A property in such an object correlates to a column in a table. This is very important to understand for successful mastering the feature.
To see the Backendless code generation in action, make sure to import the table schema so anr app has all the tables for the Restaurant to-go app.
Once it is done, follow the instructions below:
- Login to Backendless console, select your app and click the Code Generation icon.
- In the menu of code generation options select the __XXX___ classes for defined data tables checkbox, where __XXX__ references the language of your choice, for example "Java classes for defined tables".
- Click the Download Project button.
Backendless will generate the project files and the source code and package it in a ZIP file. Expand the zip file and open the generated project an IDE of your choice (Eclipse, IDEA, XCode). Make sure to inspect the contents of the project, you will see the classes for all the tables from your backend. The generated code contains 100% of the functionality to perform all the major data-related operations (full CRUD - Create, Retrieve, Update and Delete).
Review related topics: