In the past two years, I have carried out the new reconstruction and revision of the mall system from the beginning of my entry. I have experienced the closed-end overtime work for more than half a year. The reconstruction of the new mall is followed by the business improvement and expansion of the new mall. Having witnessed the efforts of the development team along the way, the Android team is also moving forward with its own ideas.
preface
In terms of the development direction of the company, from the previous single WANbiao mall App, extended to the service class of Wanbiao Master App, information class of wanbiao world App and other projects are still incubating, so THAT I realized that wanbiao Mall App as the main flow entrance, in the future to a certain extent, will gather wanbiao master, wanbiao world into the main project. So componentization must be the right evolution direction. After the gradle project was upgraded to 3.x, the new dependency isolation feature helped me push the componentization further. In addition, I have to make fun of my experience in updating gradle3.x of the project. Although the gradle3.x upgrade was full of pit, it took me more than 4 months to upgrade it from 2.3.3 to 3.1.4. On the one hand, the project had heavy requirements and tasks, and each upgrade was carried out between the new development task after the package was issued. Gradle3.0.x, gradle3.1.4, gradle3.1.4, gradle3.1.4, gradle3.1.4, gradle3.1.4, etc. When the successful upgrade to solve the problem, found himself several times to give up the answer to the problem, the original has been lying in the corner, love yourself.
Componentization advantage
In the present environment, the advantages of componentization believe that we are familiar with.
- High cohesion, low coupling, clean code boundaries, each component can be split out to run independently
- In a functional set, each component is responsible for the work of its own component, which is not affected by other components and does not affect other components’ functions
- Improve development efficiency, each component can be debugged separately to ensure code quality
- Reduce repetitive wheel building and maintenance work
- Speed up compilation and, ideally, the App project is just an empty shell for loading components
Competing goods contrast
For a mall project, we often conduct research on competing products. Let’s take a look at the home page project structure of competing products.
After all, this is just the package structure of the home page, so we can’t speculate, but we can still see a lot of things.
The status quo
In the past, the code style liked to encapsulate a tool class library, and put the non-business code in a separate library for management and maintenance. Our company also has a toolkit library for internal maintenance, but this way is no longer suitable for continuously expanding business lines and creating the company’s ecosystem, as mentioned above. Our service App and information App are not suitable for the tool class Library encapsulated by mall App. Therefore, componentization can help us refine business Module and tool Library continuously, so as to achieve our purpose of reuse.
In addition, many projects are popular MVP mode, our company is the same. MVPS are packaged in different directions to a certain extent. Let’s take a look at an example.
We can see that the old WAY of writing MVP is to put all the activity. class in the same package. This way of writing is because the idea is changed from MVC to MVP. We have more or less done this before. We will use functional modules as granularity to separate each module, which is what we call modularization. Now our company’s project is completely developed in accordance with modularization, and each functional module is very clear, but the disadvantage is that the amount of code will be large.
Some students may have a vague understanding of componentization and modularization. It’s easier to tell the difference when we think about it metaphorically. Componentization they are independent of each other, each component can be separately extracted to run, and modularization is built according to the function module, there are certain relations and connections between modularization. For example, the home page module and the article module have the function of video playback, then the video playback will appear to coupling, at this time the componentization is very easy to deal with, we will separate the video playback into a component, so that the home page module and the article module to call the same video playback component. So componentization is less granular than modularization.
Componentization scheme
GitHub is now popular with open source routing libraries from various companies, and they basically use componentized solutions
This is one of the more general modular way, of course, different factory with modification process, according to own actual situation, but the basic same, multifarious, we discuss the most is a different business components of routing communication protocol encapsulation, we will refine business component split one by one, can’t be the last is directly dependent on each other to use lead to all sorts of chaos and coupling, What we need now is routing, which helps us manage the orderly communication between business components, with the same focus on event distribution and dynamic interception.
In reference to the previous competitive products, combined with the organizational structure of the company, analyze and customize the App of their own mall. My first phase of componentization work direction is the combination of functional modularization and business componentization. This is because our project is always follows the modular, the function of the finishing is better, my side not to take apart each business componentization, also is not used now popular routing communication way, because if I will project into fully modular, of excessive packaging, lead to cost of development not harmonious, but currently our primary processing problem, the problem is that the business component reuse of Therefore, to avoid duplication of wheels in our other two apps, we first separated the consulting component, payment component, positioning component, network request component and push component, and optimized and packaged the picture loading library, general tool library, Banner tool library, Umong third-party library, picture selection library, JSBridge library and other non-business basic libraries.
conclusion
The componentization push, from the simple separation of code, helped us better comb through the old code and tidy up the wiki in time. To enjoy the process – oriented, object – oriented, interface – oriented, aspect – oriented programming fun.
Looking forward to
In the end, the mall is componentized architecture evolution, is just the beginning, just like to say, there will be more than a day App will integrate, my personal recommendation is to load the corresponding business by means of plug-in modules, in the dynamic framework where the official launch by Android App Bundles is more suitable for the development of the future. In addition, in the future, the big front end will be fully involved in the daily development of the mall, and the architecture will continue to be adjusted. The above is my simple summary and some attempts to modularization, the deficiencies also hope that we exchange correction.
References:
- Cang Wang’s Android Componentized Architecture
- Speak Open Source fluently