Main storyline Detailed description of the mobile development process Big Tech Component-based development
Plugin development
Detailed carving
Preface Your possible gains:
text My understanding of technical developers is that in addition to their passion for business and technology, they also need to have the ability to think independently. In this fast-changing era of two-dimensional mobile development, many products and companies are racing against time to catch up with the rapid changes, and the accompanying mobile research and development is also progressing with the "beating of gongs and drums to create the world". Therefore, it is necessary for us to analyze and think about the current mobile development cycle. In my personal understanding, the mobile development life cycle is divided into four major cycles. These four cycles accompany the entire process of company development simultaneously. The four life cycles are named:
The unification and differentiation period occurs after the third year of the company; the unification and differentiation period may be repeated multiple times. The so-called growth stage is the legendary barbaric development. At this time, the company's leading direction is to quickly iterate and follow the market. The R&D mileage and the number of personnel are all processes from scratch. Its purpose is to develop catch-up products and achieve rapid online launch. At this time, the selection of development technology is based on personal factors. Therefore, the early project selection and architecture are dominated by personal technology preferences. The technologies and frameworks that you are familiar with are the fastest and most effective, and can quickly catch up with the online progress. For example, if you like rxjava and the MVP model, you will soon take the lead in the solution and technical architecture of this project. Some development colleagues even start directly from the so-called ready-made projects with good architecture on the Internet. During this period, the company's only goal was to be the first to market and produce products. Rapid iteration occupied the minds of every developer, and all details could be ignored. What's the point of having a bicycle? Next, as the company's performance started to improve and financing was secured, it began to recruit new people and work hard. As the staff came up, confusion and adjustment began to appear. The new staff felt that the old code was a bunch of shit, and they despised and were unhappy with it. Old employees think that new employees are unruly, ignorant and like to show off. However, the company's purpose of recruiting new employees is to iterate projects more quickly, and the company often uses some kind of agile development model to iterate a version in 1 to 2 weeks (they just like to stir up trouble). The code needs to be iterated as the demand continues to develop, and the new and old developers write the code by copying the old ones. Slowly (it can be N), slowly after a while, it is found that the code is full of various couplings, non-standard codes, chaotic file packages, and various business interspersed. In a word, it was a mess, and various online bugs popped up one after another. When the online bugs were counted, the fuck index exceeded 5-10%. The whole team began to reflect quietly and came up with a unified idea of version reconstruction and iteration. Unified slogans such as project reconstruction and function improvement emerged. At this time, there are generally two groups of people, one group continues to iterate business while the other group reconstructs the project; the core of this matter is to reduce the magnitude of online bugs. The company's requirement that online bugs should not exceed 3% was met. At this time, the focus of the reconstruction was on dimensional analysis based on online bugs, and the problems were divided by number. The problems at this time were as follows:
Regarding the online bug indicators designated by the company, whether they are completed or not also requires multiple versions to be iterated and run on the live network before statistics can be counted; since there are different levels of severity in the live network bugs, if there are major bugs, new versions will be released immediately for updates, and minor bugs will be fixed in the next version iteration. Is there a hot fix solution for the live network bugs? Of course there is, and mature ones include third-party libraries such as tinker; Although the above problems have been solved after working overtime, with the development of the company's business and the strong promotion of the market, multiple business lines have sprung up and started to work. Looking at the current project architecture model (as shown in Figure 1) With a long sigh, the great hidden danger and anxiety buried in my heart slowly emerged. The project is still full of code coupling and confusion, and the theorem of "chaotic code plus new code is still chaotic code" has been pressing on my head. This project framework will definitely not be able to keep up with the development and planning of the company's new business line; pressure brings motivation. After careful consideration, the layered and modular architecture slowly emerged unconsciously. Each business line is a module module. Next, each business line will copy and paste a copy of this module and then start the business. Generally, this situation needs to continue until there are three business lines. Basically, there will be chaotic calls between modules, various resource files are repeated and codes are flying everywhere. In addition, the permission control is not available, so everyone has the permission to write the basic library, so that the public code of each business is sunk to the basic library, resulting in huge and bloated, and the speed of multi-module mixed compilation is extremely slow. A lot of bad problems have emerged. Looking back at the current status of the project, I'm here again, and there is no end to the work. Look at Figure 2. If you think of yourself as a Virgo, you will definitely go crazy, either fire your boss or calm down and think and analyze. After analysis, the following problems were found to be urgently needed to be solved:
Thinking about question 1, since decoupling is achieved and hot-plug solution is implemented at the same time, to put it simply, when the current module switch is turned off, other referenced modules cannot perceive that this module is turned off, that is, the code referenced by other modules must not hard-code the methods and reference classes of this module, etc. The solution is component routing, and the caller queries the module's services and functions through the string path. Thinking about question 2, code permission management is generally implemented through git or svn. Thinking about question 3, you can use gradle script to package the modules and upload them to the private server. Thinking about question 4, the problem of gradle itself and the large number of modules lead to slow compilation speed. According to the independence of business lines, we can implement the App mode for this module when writing the business module to reduce other unnecessary code compilation and running. The implementation plan is as follows: In the module gradle compilation script, an identifier is used to distinguish whether it is a module or an independently run App.
In this way, we need to run this module separately, set FINANCE_IS_APPLICATION to true in gradle.properies and then compile to implement business code writing and running. Someone asked, if I need to implement a new business in the main App, then you can close other irrelevant modules to achieve fast compilation and improve development efficiency. Thinking about question 5: As the project grows and is packaged through multiple channels, it is necessary to consider the business services surrounding the project, such as packaged testing provided to testers, official version releases, and other automated output issues. Generally, the automation service can be realized by building a Jenkins service or using a Python script to realize the automatic packaging function. The functionality of the scripts varies from company to company. Therefore, at this time, we urgently need a comrade who is familiar with gradle, python and other scripts (gradle itself is a Grovvy language). It takes at least half a year to reconstruct and improve the entire process while ensuring the development of new business (except for large companies). I gradually discovered that component-based architecture emerged silently. Isn’t it magical? Looking back, I found that a small part of the componentized architecture has been carried out. I am full of confidence and continue to work. At this time, I must take out Chairman Mao’s red notebook and read it out loud. I love programming and my skin is great!! We found that we have done business modular code separation, inter-module routing communication, and gradle component scripts; Your growth is based on the growth of the company. As the company's business grows, branches will emerge for various reasons. Some sub-business lines will need to have independent apps to provide professional services and experiences. They need to sow seeds and bear fruit. The original sub-modules may become independent apps. So, you find that the current architecture cannot be realized. Yes, come here and think under the Bodhi tree. The fundamental reason is the incomplete componentization. The biggest problem is that the main project module involves a lot of the earliest business codes and functions. The most urgent problem now is the need to separate the main project's business into a business sub-module plus a pure project skeleton. The project skeleton must be upgraded to a new main project module, which contains the public business of the project. To put it bluntly, putting the project skeleton on other sub-modules means that an independent app can run. For comparison, Figure 4 is the original architecture diagram, and Figure 5 is the architecture diagram of the main project module, which is one level higher than the project skeleton. The main project skeleton must include the following functions:
At this point, the componentization has been basically completed. The only thing to do now is to use the gradle script to make a glue. The script cooperates with Jenkins to dynamically realize the combination of modules and the main project skeleton. The componentization mentioned above means that the main framework is complete, but it needs to be further decoupled and separated according to the company's business, generally as follows:
This process should have achieved various decoupling and separation of project modules and codes, which looks very refreshing and clean. Unconsciously, I started singing again: I love programming, and my skin is great!! Suddenly one day you hear someone talking about plug-in, and you smile secretly in your heart, because our project has already realized hot-swappable plug-in; After discussing, I found out that it is not the plug-in you think. What they mean by plug-in is to store the business module dynamically on the Internet and load it in when needed. Wow, it turns out there are two types of plug-ins: static plug-ins and dynamic plug-ins. Unconsciously, we have realized the static plug-in function. This is what we mean by a steady stream of water. Oh, it should be a natural outcome. The prerequisite for dynamic plug-in is that the project must have a complete componentization before the dynamic plug-in function can be realized. At present, each submodule can be packaged into AAR, JAR, and APK independently; the next step is to add a dynamic plug-in function to the main project skeleton; perfect There are many mature solutions for dynamic plug-in in the market now, because this is not like the componentization process, which is actually closely related to the business and project, and needs to be processed and implemented according to its own business and existing business framework; The dynamic plug-in implementation mechanism has nothing to do with the business system and its own architecture, and you can boldly introduce mature third-party plug-ins; for example, the dynamic plug-in of Meituan and Alibaba. In fact, looking back on the whole process, I found that these are all done step by step, and it is impossible to achieve everything in one step. This is life; Some people ask if we can sit back and relax from now on. Haha, too x too native. These are just the first few steps in a long journey. We need to further refine the details and technology. The improvement of surrounding services and the implementation of security and other supporting facilities are all waiting for you to achieve. The road ahead is long and boundless. . . Here are a few details on the carving:
Eventually you will find that many functions can be implemented with half the effort only after you have completed componentization or plug-inization, thus minimizing the distribution of centralized optimization changes and greatly reducing the risk of changes and bugs. The above process is actually a process of long-term separation and long-term combination. When the project is pushed to the extreme and still cannot cope with the huge user base and business group, please switch to pig farming... Plug-in routing implementation, see the source code for details, please click star if you like it: https://github.com/wenzhonghu/MyRouter |
>>: iOS 12.1.2 shows 4G but can't connect to the Internet? Here is a temporary solution
The beginning of autumn passed quickly, and it is...
Why do rockets need to be transported by ship? Wh...
Liuzhou learned about the types of WeChat applet ...
[[166005]] SDWebImage is currently the most popul...
When doing private domain business, how to acquir...
Oil is the "black blood" that keeps mod...
On January 30, according to the latest data from ...
How much does it cost to use China Mobile's 1...
In the hot summer, if you try to cool down after ...
Copywriting is an important part of brand promoti...
Many products are in the early stages of promotio...
As the autumn rains come, the weather gets colder...
Every industry takes two things into consideratio...
2014 was a very busy year for the gaming industry...
At present, the photography industry has develope...