preface

We covered the industry’s best architecture practices and the CloudDisk team’s layered architecture designed for business situations.

In this article, we will present a condensed version of the example in which we designed some of the common abnormal dependencies, and we will use this example to demonstrate the operation in subsequent refactorings. To simplify the code and understanding the business context, some of the implementations in the example are empty implementations, focusing on the coupling dependencies of exceptions.

Warehouse address: CloudDisk

CloudDisk sample

Description of project

CloudDisk is a cloud storage application similar to Google Drive. The application has three core business modules.

  1. File module: Manages user cloud file systems. Users can upload, download and browse files.
  2. Dynamic module: similar to wechat circle of friends, used to share information and documents on the dynamic
  3. Personal Center module: Manages users’ personal information

Problem specification

The project has been maintained for more than 10 years and currently has more than 100 useful developers. The code is in a large monomer module, about 30W lines, and takes more than 5 minutes to compile. The team currently faces several major problems.

  1. The development efficiency is low, the compilation time is long, often appears the code merge conflict
  2. Code quality is poor and new problems are constantly being fixed
  3. Slow market response and need to align each module for full package release

The code analysis

The code is in a Module and managed in a Git repository. The “MVC” structure is adopted to divide the Package according to its functions.

Package structure is as follows:

Main package description:

The package name Functional specifications
adapter ViewPager RecycleView and other adapter classes
callback The callback interface
controller The main business logic
model The data model
ui Activity, Fragment related interface
util Utility class

Description of main categories:

The name of the class Functional specifications
MainActivity The main interface is used to load and display fragments of each module
CallBack Network interface operation callback
DynamicController The dynamic module is the main business logic, including publish and get lists
FileController The file module provides service logic, including uploading, downloading, and obtaining the file list
UserController The user module provides business logic, including logging in and obtaining user information
HttpUtils Network request, used to send GET and POST requests
LogUtils It is mainly used for logging

For details, see CloudDisk

To simplify business context understanding, the code is an empty implementation, showing only the abnormal dependencies of the module, and subsequent MV* refactoring sections will continue to supplement the common bad-taste sample code.

conclusion

When CloudDisk initially developed its business, it adopted a single Module and a simple “MVC” architecture to support the development of the business. However, with the evolution of the business and the expansion of staff, such a model has been difficult to efficiently support the development of the business and the team.

Now that we’ve shared the “ideal” (future architecture design) and the “reality” (current code status), as we begin to refactor, we need to know how many problems there are in the evolution to the ideal design architecture. On the one hand, as input to start refactoring, on the other hand, we have data metrics that can also assess effort and measure progress.

Next, we will share with you the refactoring of mobile Application Legacy (4) – Analysis. Introduces common analysis tools and frameworks, and analyzes the CloudDisk team’s current code.

Series of links

Refactoring legacy Systems for mobile Applications (1) – Start

Refactoring legacy systems for mobile applications (2) – Architecture

The outline

about

Welcome to the CAC Agile Coach public account. Wechat search: CAC Agile Coach.

  • Author: Huang Junbin
  • Blog: junbin. Tech
  • GitHub: junbin1011
  • Zhihu: @ JunBin