Reprint an article of gang elder brother late at night, chat architecture design, have inspiration to oneself very much.
I have written articles about architecture design before, and recently I have been reading the technical column “Learn Architecture from Zero”. I have some thoughts to share with you. If you are asked this question in the interview, you can answer according to this idea.
Many readers are mobile developers, and most of the books and columns on the market are on the back end. Is architecture born for the back end? Not really, but it is true that the backend architecture is more complex than the client and the front end.
After my thinking, I try to abstract some features of mobile terminal architecture.
High concurrency, load balancing, and disaster recovery are some of the core points of the backend architecture design, but these points do not exist on the mobile side. The reason is that all requests are sent to the same back end, so there is a many-to-one relationship between the mobile side and the back end, so there is no high concurrency on the mobile side.
I. What does mobile Terminal architecture design do?
Generally speaking, it’s basically MVC, MVP, MVVM, and componentized things. These things are called architecture, but in essence, they are variants of modularity. This kind of thing mainly does business architecture, dividing a large business into many small businesses, and each small business is a module.
The other part of the architecture content is the technical architecture, generally layered, the bottom layer is the basic framework, including network, storage, log, image loading and other third-party libraries; The middle layer is the public business layer formed after the abstraction of the upper business, which can also be called the middle platform, which often contains account number, payment, customer service, map and other relatively independent business. At the top is the core business. In terms of variability, the basic framework changes the lowest, and the upper business changes the highest among the public business levels.
In summary: Mobile Architecture = Business Architecture (modular) + Technical architecture (layered)
Two, why do architecture design?
Many people (including me) only know to do architecture design, but do not know why to do it, if I have to say, you can probably be summarized as follows:
“To make the project look more technical,” “everyone else is doing the architecture, I have to do it,” “improve the performance and scalability of the program, and reduce subsequent maintenance costs.”
In fact, these goals are more abstract, difficult to measure, after the completion of the architecture design may not be able to achieve expectations.
Is popular, for example, the MVP, MVP is to reduce the coupling, the benefits of reducing the follow-up maintenance costs, but in fact, with the MVP, the extreme code, add a lot of classes, code readability is poor, a lot of new people learn difficult, lost in a pile of presenter, you think about it, really do this maintenance cost reduce?
Third, the goals of the architecture design
If I had to say it again, I think I’d change my mind.
In order to find architectural design goal, we are looking for sources of complexity of the current project, that is to say, to the current project which has the most pain is the most need to improve, for example, drops to travel like this APP, complexity from a large number of similar lines of business, and these lines of business is in a different team, the team cooperation problem is very urgent, So that’s what we’re going to build around. Another example is Travel APP Qunar, which has a particularly high requirement for dynamics. Therefore, React Native is widely used in Qunar.
In other words, the goal of architectural design is to address the pain points of the current project, and if the current project doesn’t have pain points, then don’t architecture at all.
Four, how to do the architecture design
Architecture should be designed for practical purposes. Don’t just try to build the best architecture in the world. That’s not always true. In summary, there are three basic principles of architecture design:
1, suitable for their current business is better than the world’s leading, do not always want to engage in the world’s leading architecture, such as a user number of 1 million system, just think about the standard micro channel architecture, that micro channel every day live hundreds of millions, suitable for micro channel architecture may not be suitable for their own.
2. Simple is better than complex just as with code, the simpler the code, the better. The same is true with architecture.
Scalability, of course, is something to consider, but people are not gods, and no matter how you try to predict future evolution, there is always a big chance that you will miscalculate. Therefore, the architectural design prioritizes the current problem, and as for the future problem, the architectural solution will be improved when the time comes.
Architecture design also takes into account the cost, you design a good architecture, but need to invest 20 people, and the project has to stop for 2 months to focus on architecture development, then the cost is too high, it is difficult to move forward. On the back end, for example, you design a great, efficient architecture, but you need 1000 servers, and then the company can’t afford that many servers, so it’s useless.
These three principles also have a priority, specifically: fit over advanced > evolution over one-step > simple over complex
Fit is to adapt to the current needs is the first, even the current needs can not be met and nothing else. The overall development of architecture should be constantly evolving. Under this major premise, we should pursue simplicity as far as possible. However, when it is complicated, it is necessary to be complex.