[Architecture] Architecture Design of Android mobile app

Source: Internet
Author: User
Tags coding standards md5 encryption

[Architecture] Architecture Design of Android mobile app
Preface

Architecture, also known as software architecture, is an abstract description of the overall structure and components of the software, used to guide all aspects of the design of large-scale software systems.

Software Architecture Design goals:

1. reliability ). The reliability of the software architecture is a prerequisite for product design.
2. Security (Secure ). The security of software architecture is a condition for sustainable product development.
3. Scalable ). The software architecture must support scalability when different functional needs are met.
4. Customizable ). The same set of software can be adjusted based on different customer groups and changes in market demands.
5. Extensible ). When new technologies emerge, a software architecture should allow the import of new technologies to expand the functions and performance of existing systems.
6. Maintainable ). Maintenance of software systems includes two aspects: first, to eliminate existing errors, and second, to reflect new software requirements to existing systems. An easy-to-maintain system can effectively reduce the cost of technical support.

Architecture is the trend from project formation to a certain stage. Is an effective guarantee for the entire product. It is unreasonable for many project designers to emphasize the software architecture without considering the products, teams, and time periods, it is not conducive to the development of the entire product. Of course, a good project architect can clearly understand the different responsibilities of a project at different stages. To maximize the energy efficiency, make the most appropriate matching plan between the product cycle and the function module. This is what an architect must pursue.

The following is my personal experience on the architecture design of Android mobile projects. You are welcome to contact more friends. If you have any questions or are unreasonable, you can contact us at any time.

Start with project functions

Each project architect has different priorities when getting a new project. There are different considerations for the project planning style. When I start a project, I start with the function. First, understand the functional modules of the project, differentiate the classes of the main functional modules, and carefully divide different functional modules. This is my first step. Because only by having a certain grasp of the entire project can we have a faster understanding of the project, so that we can know how to reasonably arrange the project R & D, and better arrange the project progress process, and personnel scheduling.

After the functions are divided, the next step is the actual R & D Phase of the Project. This stage is the actual progress of the project. Reasonable scheduling is required to ensure project efficiency. For example, most of our projects involve network interaction, local functions, and basic data modules. These functions must be properly scheduled.

Before Project R & D, the following points are provided:
I. Unified coding standards among teams.
Ii. unified management of Requirement documents.
3. Collaborative development by multiple people and development by document (document-oriented ).

Projects are divided by functions and functions by modules. In the initial stage of the project, except for the product prototype which may be designed in advance, other project documents have not yet been developed. The product also has a definite function, but the detailed documents have not yet been developed, this is the initial stage of the project. You can start the basic development of the project even before some documents are created.

Function module

Network Module, database storage module, data encryption module, data cache module, data parser, and log information collection module. These are basic modules of the project. They can also be independent of functional modules and can be developed and tested in advance. It is easy to use directly later.

Mobile Security Mechanism

We all know that mobile security is an important part to be considered in the early stage of the project. Therefore, at the beginning of the project, data storage should be encrypted as necessary to encrypt the data transmitted over the network.
There are two types of mobile data encryption:
One is local data encryption, which only stores information stored on the local machine.
One is network transmission data encryption, which involves the network protocol and the encryption protocol between the server.

There are many local encryption methods:
1. MD5 encryption algorithm. MD5 is an irreversible algorithm that has no decryption algorithm (currently it is said that there are methods to crack it ).
Ii. DES encryption. Reversible.
3. RSA encryption. Reversible
For projects that do not require absolute security, the above three types of encryption are sufficient.

Network Data Encryption mainly involves two aspects:
1. Ensure that the API caller is an authorized App;
2. Ensure data transmission security.

Make sure that the API is an App authorized by the user and the signature method is used. Each mobile platform has different AppKey and AppSecret. When an API is called, AppKey is added to the Request Parameters. Then, AppSecret and other parameters are used to generate a signature string using a signature algorithm and transmit the data to the server. The server uses the same signature algorithm to generate the same signature based on the AppKey and AppSecret, which means the request is secure. You can use a set of signature algorithms (more secure) specified by yourself, or an externally published signature algorithm (used in the initial stage ). In addition, adding a timestamp to the parameter list can also prevent some replay attacks.
For data transmission security, you can use HTTPS. Because ssl security protocol is added to HTTPS. However, most android project development is not implemented. The ssl certificate is not checked for security.

API Protocol Standardization

For project development, the Protocol must be standardized and the interface protocol must be strictly enforced. Update the protocol document for each version for later users.
Currently, all protocols are transmitted in Json format. It should be noted that during the transmission of JSON data and object, serialization and deserialization may differ depending on the platform. For example, the JSON database converts data of the Date type to a String type during serialization. when the data is transmitted to the server, different results are often returned during server deserialization.

API Version Control

Generally, we solve the problem of interface update changes. We adopt that each API interface carries a Protocol version. If the protocol changes, the version number changes accordingly. When processing data requests, the Protocol version can be used to solve the compatibility problem.

Architectural hierarchy

The main purpose of architecture design is to reuse functions and code, reduce repeated development, facilitate function expansion, and reduce coupling between functions and code levels.
Currently, there are three mainstream mobile design frameworks: MVC, MVP, and MVVM.
Any framework design is based on the development requirements. Do not design for the purpose of design. Do not ask me which of the three designs is the most suitable for development? If you still ask, you can only say that you are not a mature product designer. The three frameworks have their own advantages and disadvantages. They should be selected in a more reasonable way at different stages and with different staffing. I used to participate in the development of a video project by a startup team. In the early stage, there were only two mobile developers who were busy with the project. The project owner will modify the requirements and talk about the project architecture on a daily basis. In the initial project, in the Product verification function phase, the most effective framework should be used in the fast iteration phase of the project, which is a reasonable choice. In addition, the development of the project must follow the establishment of the project functions, product stereotypes and requirements, and the stability and performance requirements of the project itself. To achieve perfect products in one step is not only difficult to achieve in design, but also hard to achieve in all products at present.

Any framework is on this layer-3 data model. View, Model, Controller/Presenter/ViewModel. Upper View: user action. The data result is displayed. Underlying Model: data processing and display data. The middle layer is the business logic layer.

Android project design focuses on the understanding of projects, the division of required functions, and the rational allocation of teams. Efficient Production and fast iteration are the survival of mobile projects.

Android Testing

Mobile development requires logical testing to ensure quality output. In the design of the project framework, the simple mvc mode is not conducive to interface testing if the view and model are mixed with the business logic. Therefore, in subsequent version iterations, You need to gradually use the mvp or mvvm framework design so that the view and model can be completely decoupled from the business logic.

Android Environment

Since Android provides more efficient and stable android studio, it is more convenient and convenient for developers. Package on the android gradle multi-platform. Proguard code optimization and obfuscation. As android studio becomes more and more powerful and more stable, it is believed that the development of android projects will become more and more so easy.

Summary at the end

A qualified mobile project architect must grow in constant project development. It not only understands the efficient and rapid deployment of projects, but also how to optimize the team reasonably to produce better products. Mobile products are quick-production products. How to make products suitable for team production is the learning path of mobile architects.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.