摘 要
随着 Android 客户端 App 的飞速发展,简单的 MVC 分层架构早已不符合当 下开发的需求,现在的 App 具有开发上线周期短,需求变化多,功能体量多跨度大, 更新周期短,适配机型多,合作开发人员多等特点。
那么,对于现在体积庞大的 App,本文设计了一个立体的架构。本架构的设计 从横向,纵向和延伸性上考虑。纵向主要分解流程;横向主要分解业务,和开发期间 的功能复用;延伸性上本架构充分考虑了架构的升级和发展潜力,降低架构演进成本。
纵向上,本架构实现了合理分层。每个组件进行分层例如 MVP ; App 整体被分 为驱动层,lib 层,架构层,App 层,保证了底层架构对于上层 App 的控制力。
横向上,本架构采用组件化和模块化设计。组件化将每个部分进行细粒化的分离, 对每个具体业务进行切割隔离,并且实现组件之间的树形依赖管理,使底层组件可以 最高效的被上层业务组件复用;赋予组件生命周期管理,并且组件层级之间使用 DI 进行依赖拼装。在业务量大的情况下,组件提供了模块化进一步切割业务及功能,辅 以页面路由器进行模块间跳转,对于大型 App 来说,组件化使各个团队在开发期间 的隔离分工;App 落地运行期间子模块按需加载,即功能组件的懒加载,为用户节 省资源;除此之外利于动态增加功能模块。
延伸性上,本架构将架构的底层设计高度抽象化,严格遵循面向接口,保证了架 构的演进升级。对于上层 App,现在 App 对于更新的需求日益增长,架构集成了增 量更新组件,Bugfix 上,架构也集成了动态热补丁。
同时本架构也经过了实际开发案例的检验,最后给出了已经上线的实际开发案例 检验了本架构优越性。
关键词:Android;架构设计;App 开发;组件化;模块化;分层;MVP.
Abstract
With the development of the application of the android client,the mvc witch a simple layered architecture can not meet the current complex needs.Nowadays, app has many traits such as short circle of the development,frequent change of requirements,complex in function,frequently updated, many types of adaptation and multi person cooperation.
So, for the now bulky App, this article designed a three-dimensional architecture. The design of this architecture is considered in terms of landscape, longitudinal and extensibility. The main decomposition process; the main decomposition of the main business, and the development of the functional reuse; extension of the framework of the architecture to take full account of the upgrade and development potential, reduce the evolution of the cost of architecture.
For vertical, the architecture to achieve a reasonable layer. Each component is layered, such as MVP; App overall is divided into the driver layer, lib layer, architecture layer, App layer, to ensure that the underlying architecture for the upper App control.
For horizontal, the architecture uses modular and modular design. The component separates each part by fine-grained separation, isolates each specific business, and implements tree-dependent management between components so that the underlying components can be most efficiently reused by the upper business components; Cycle management, and the use of DI between the component level to rely on the assembly. In the case of large traffic, the components provide a modular further cutting business and functions, supplemented by page routers to jump between modules, for large App, the components of the various teams during the development of the division of labor; During the sub-module on-demand loading, that is, lazy loading of functional components for users to save resources; in addition to the dynamic function of the module.
For extensibility, the architecture of the architecture of the underlying design highly abstract, strictly follow the interface-oriented, to ensure the evolution of the architecture upgrade. For the upper App, App is now growing demand for updates, the architecture integrates incremental update components, Bugfix, the structure also integrates dynamic hot patch.
At the same time the structure has also been the actual development of the case test.