Last updated
Last updated
There are a few recommended practices to improve the organization, maintenance, and performance, and consequently loading your application. Some of them are very basic, like creating a class apart to store the colors used in the application and other more complex as working with loading images that are pulled from an external bank. In this chapter we will learn about these recommendations.
You can download the , which contains all the recommendations below.
In the development of any application it is essential to have a design to prototype the user interfaces. It turns out that when the developer takes these prototypes and starts to develop, it often ends up adding these colors in the UI classes themselves, which makes it difficult to maintain this code.
Now let's say you have an update to your application and the background color of the APP has changed. If your project has 2 or 3 screens, is it relatively quick to change these colors but if it is a more robust design of 15 screens? The developer would have to quit by changing the background color 15 times.
Thinking about this, TotalCross recommends that you create a class named Colors and create constants for each color that you will need to use in the application, and preferably with suggestive names such as BACKGROUND. The name of the constants must always be in upper case. Here is the standard suggested by TotalCross, feel free to adapt to the needs of your project.
To facilitate code maintenance, it is also recommended that all images be instantiated in a separate class called Images and only be called in the interface classes.
Images class example:
Using Images.class:
As with colors and images, it happens when we are going to edit the fonts and here the problem is even worse, because we still have to stick to the size of fonts, colors and type.
So we advised that before the developer can already take with Design all these details to pass through a class with everything custom, as in the example below:
to apply this class:
to apply this class:
you will find free website recommendations for screen prototyping in the part of in the last topic of this chapter.
The names we attributed to the contenders were not by chance but rather due to the Color standard. You can generate each of these colors and better understand this pattern through . With this Material tool you select the primary and secondary color of your project and it already generates the application's color palette and font color.
We also provide the source code for you to download and adapt for the project. Just click .
Another way would be to create an enum to stylize and only apply where you need it. To learn how to do it this way just click .
The Material recommends a series of , so it is ideal to create a class within the useful package and assigning these patterns to the constants, as in the example below:
Screen prototyping tool - , , and ;
To better illustrate where each of them is used, you can download the ;
Screen templates in standard Material Design made with totalcross - ;
.