đ¨đźâđťBest Practices For Android Development
In todayâs mobile world, the use of android software devices has become quite common. This has become very important in developing android softwares in the best way. Letâs take a look at what should be considered when developing this software.
Just writing the code is not enough, writing it effectively is the real challenge.
- Attention to Code Quality
If we think that coding is an art, when a person starts coding correctly, the flavor begins to increase in the flavor he gets. Moreover, how creatively you code shows how good a developer you are. Your code quality is always important. Since writing long code is never a wise step, it not only increases the chances of more errors, it also wastes a lot of time and creates a lot of complexity. To give your code the best view, you can first review an expertâs code, analyze their approach, and try to change that.
- Use Design Pattern
Design patterns provide reusable solutions to problems that commonly occur in a given context in software design. In addition to being a possible solution to a problem, it aids communication between developers as it becomes easier to work in teams when you are familiar with the agreed upon patterns. Today we have many architectures such as MVC, MVP, MVVM, MVI, Clean Architecture. When choosing among these, you should choose the architecture that is suitable for your project, not the popular architecture. So if any of these architectures meet your project requirements and you follow standard coding guidelines and keep your code clean, no architecture is bad.
- The Subject of User Experience is Quite Important
A userâs interaction with your application is very important. I think we can all agree that there has been an increase in demand for better experiences on mobile devices lately. Letâs take a look at some points that you should pay attention to improve the experience of our applications:
- Excellent UI&UX Design: The user-friendliness and experience of an app starts with a good UI&UX design. It is very important to develop an application that complies with the principles of Google material design.
- Handling Configuration Changes: Configuration changes seem like a pain to most Android developers. When you rotate your device and the screen changes orientation, Android usually destroys your appâs existing activities and fragments and recreates them. This is done so that the application can reload the resources according to the new configuration and itâs basically like starting over. Mishandling this scenario is an example of bad user experience and can cause you to lose many users. With the viewModel, which is a part of the architectural components released by Google in 2017, you can ensure that your application does not lose data on direction changes. The ViewModel is designed to intentionally store and manage user interface-related data throughout its lifecycle. With it, your data can recover from configuration changes.
- Be Agile
Agile project development methodology offers several key advantages over other traditional approaches when it comes to mobile app development. It facilitates alignment between development and client teams and enables an ongoing and productive partnership between all stakeholders. The Agile model provides full transparency into the development process for customers and gives development teams flexibility to incorporate customer feedback into the application development process. This ensures that the project stays aligned with the clientâs vision and changes can be made easily throughout the process to maintain that alignment. Dividing a project into smaller modules or sprints allows multiple teams to be deployed to speed up the development process, as well as allowing you to launch an MVP faster and gather quick feedback from real users to help make decisions in subsequent iterations.
- Some points should be considered when using the resource structure
- Use Styles: Almost every project needs to use styles correctly. Having a common style for most text content in the application will facilitate widespread use.
<style name="ContentText">
<item name="android:textSize">@dimen/font_normal</item>
<item name="android:textColor">@color/basic_black</item>
</style>
For TextViews:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/price"
style="@style/ContentText"
/>
You donât need to have a single style.xml file, you can split it into other files like âstyle.xmlâ, âstyles_home.xmlâ, âstyles_item_details.xmlâ, âstyles_formsâ.
- You Can Name Colors Correctly: Naming the colors in the colors.xml file appropriately will make it easier to change or rearrange the colors, and will also make it easier to understand how many different colors are used. It is important to reduce the variety of colors normally used for an aesthetic user interface.
Donât:
<resources>
<color name="button_foreground">#FFFFFF</color>
<color name="button_background">#2A91BD</color>
</resources>
Do:
<resources>
<!-- grayscale -->
<color name="white">#FFFFFF</color>
<!-- basic colors -->
<color name="blue">#2A91BD</color>
</resources>
In addition, further distinctions can be made between basic colors and the use of styles, if necessary, by defining an additional color resource file that references the color palette.
- Use Dimens: You can avoid duplication by making some definitions for margin, paddings, spacing and font size for similar purposes as with colors. Dimens will give you a consistent look and feel while making your job easier.
<resources>
<!-- font sizes -->
<dimen name="font_larger">22sp</dimen>
<dimen name="font_large">18sp</dimen>
<dimen name="font_normal">15sp</dimen>
<dimen name="font_small">12sp</dimen>
<!-- typical spacing between two views -->
<dimen name="spacing_huge">40dp</dimen>
<dimen name="spacing_large">24dp</dimen>
<dimen name="spacing_normal">14dp</dimen>
<dimen name="spacing_small">10dp</dimen>
<dimen name="spacing_tiny">4dp</dimen>
<!-- typical sizes of views -->
<dimen name="button_height_tall">60dp</dimen>
<dimen name="button_height_normal">40dp</dimen>
<dimen name="button_height_short">32dp</dimen>
</resources>
-Instead of creating your own HTTP client, OkHttp Library can be used
There are several proven solutions that you should use instead of implementing your own client for making requests to servers. For efficient HTTP requests I recommend basing your stack on OkHttp and using Retrofit to provide a secure layer. If you choose Retrofit, I can recommend using the Picasso library for loading and caching images. Because Retrofit, Picasso, and OkHttp were created by the same company, they complement each other nicely, and compatibility issues are rare. Loading and caching images are available in the Glide library as another option for their animated GIFs, circular images.
-Projects should not be left vulnerable in terms of security
It doesnât matter what kind of application the developer intends to make, but security should definitely not be given priority and neglected by the developer. Your apps will have tons of data and sensitive information about your company as well as the users in your app. Depending on the application you are developing, the payment information may have important information such as home address, phone number and many more provided by the user. If your application is not secure, users will hesitate to inform you. If security is breached, it can damage your brand so much that it can be difficult to recover. Therefore, it is necessary to take precautions to protect sensitive information and use other tactics such as encryption (Two-Factor Authentication 2FA).
- The Project Should Be Checked With Appropriate Tests
- A/B Testing: Updates to improve security, introduce new features, or expand functionality are part of the lifecycle of every mobile app development process. But itâs never a good idea to overwhelm users with major app changes. For example, itâs always better to release major UI changes to a larger audience only after A/B testing with a smaller representative audience.
Progressive Release is part of the agile methodology as it removes the risks of the release process. Prioritizes results over deliverables to ensure the entire team understands the high-level business goal underlying each release. It allows development teams to release specific functions to specific user segments and at specific times, thus accelerating time to market without increasing risk.