当前位置:网站首页>Reconstruction practice of complex C-end project of acquisition technology
Reconstruction practice of complex C-end project of acquisition technology
2022-06-22 12:57:00 【InfoQ】
1. background
1.1 restructure
- Project maintenance costs are high
- Affect project tuning , Such as performance optimization
- The code is ugly , When not elegant
- When the existing design and implementation are not conducive to expanding new functions
- Repetitive work , When existing code doesn't help you easily add new features
- repair bug when , Troubleshooting logic is difficult
- code review You can have someone review the code to see if it is readable , Comprehensibility
- Too much code is uncommented , Even I can't figure out the code logic quickly
1.2 How to reconstruct

- Think clearly ( The overall design , It doesn't have to be documented, but it needs to be clear ).
- Collaborative planning ( Cooperation within the development team and integration of the refactoring branch with other branches 、 Apply for external resources in advance, such as products 、 test 、 Operations etc. )、 The overall planning .
- Layer by layer and step by step , Grasp the big and let go of the small, from coarse to fine . Make good use of “The batch”.
- Do one thing at a time .
- Don't make wheels over and over again .
- When you find something difficult , Stop and think about the wrong method , What should it be . Keep monitoring and reviewing your way of thinking .
- Good internal and external communication , Especially when the project is not developed and maintained by only one person . Pay attention to communicating with interested parties in advance ( test 、 Operation and maintenance ) Good communication, ( programme 、 Main time nodes 、 Resources to be invested 、 Matters requiring their cooperation ).
2. Community C The refactoring practice of the end
2.1 Analysis of current situation
Technology stack :

Project side
- repo A:A1 + A1. + A2 + A2.
- repo B:B1 + B1. + B2 + B2.
- repo C:C1 + C1. + C2 + C2.
2.2 Refactoring plan
The overall idea of the front side :
- repo A Newer , It is the main warehouse of the community , Most of them C End page , As the target C Target repository for end code .
- repo B To repo A:repo B And The technology stack of the target warehouse is very close , involve 5 A page , Migrate through human flesh , Pay attention to the migration of dependencies during the process .
- repo C To repo A:repo C It is quite different from the target warehouse , And the language is heterogeneous , Upper frame 、 Component libraries are quite different , There are many pages involved .
- First, identify the valid pages , Put... On the offline page dead code Excluded from migration ; The details will be discussed later , Take out the front-end routing configuration in the warehouse to be migrated , Know the total range of pages , Check out Alibaba cloud sls Recent in the log PV( Two query methods for proofreading ), Exclude pages without traffic .
- Hierarchical reconstruction , In the early stage, we should focus on the big and let go of the small , The time-consuming, labor-intensive and problem prone framework syntax conversion (vue to react) It should be implemented by scripting , Realize the transformation of maintaining the overall structure and reference relationship in file level and various classes .
- The detail syntax is batched through a custom script ( such as vue In Chinese class Of key And string form value convert to react Medium className And variable form value).
- To ensure efficient self-test after migration, the corresponding *.vue File retention , Think of it as doc file , Delete after the entire migration , To improve the efficiency of migration and testing . Pay attention to transformation lint Rules ignore the detection of such files .
- In the process, the files are migrated together , Yes “ Namespace isolation ”, Pay attention to maintaining the relative relationship of the overall directory structure , Do overall migration , And do not pollute the existing documents in the target warehouse , Prevent files with the same name from being overwritten .
- Through the above three steps, each warehouse code is migrated to repo A after , Sync The latest updates in the three warehouses .repo C To repo A In the process of ( from V1 Cut out branches ),repo C The code is still being updated ,repo A Also need to repo C Medium V1.、V2、V2. Code in (repo B also ). Because the code is in different repositories , Manual consolidation is required .Tips: Can be in repo C Lieutenant general V1.、V2、V2. The multiple commits Synthesis of a commit, Summarize all change items to one place for batch update .
- repo A in SSR The scheme research and application are also in parallel . The newly migrated pages in the refactoring should be consistent with SSR Do integration .
2.3 Refactoring and integration practices
2.3.1 Warehouse B Page sorting and migration
2.3.2 Warehouse C Page sorting and migration
- Online traffic query , Exclude useless pages
- Routing statements in the three code repositories determine the total scope
- Determine the past based on Alibaba cloud logs 3 Months 、2 Months 、1 Months of PV, Will not PV Pages of are removed from the page pool to be migrated .
- Be careful 1: Alibaba cloud SLS Logs are based on reported data , Data may be lost in the reporting and statistics process , Therefore, two query entries are integrated to determine and troubleshoot .
- Be careful 2: For having 1-2 individual PV The page of , It may be caused by the research conducted in the early stage of the team's internal development , After confirming the visitor, discharge “ test ” produce PV The page of .
- Determine the final reconstruction scope (27 Filters 13 individual ). Will step 1 The total range obtained in step 2 No users in PV Page culling .
- Heterogeneous language transformation and processing
- Warehouse C in Vue2 Convert to warehouse A Medium react
- Tool conversion
- Script conversion
- transformation
- Project directory structure design and file mapping process
// step1: Keep the relativity of the overall directory structure unchanged
.
├── apis
│ ├── community.ts
│ ├── h5community
│ ├── ...
├── components
├── pages
│ ├── h5community
│ │ ├── App
│ │ ├── api
│ │ ├── asset
│ │ ├── components
│ │ ├── config
│ │ ├── filter
│ │ ├── live.js
│ │ ├── main.js
│ │ ├── mixins.js
│ │ ├── router
│ │ ├── style
│ │ ├── utils
│ │ └── views
│ ├── community
├── utils
└── ...
// step2: foo.vue The file to foo/ Catalog , The templates are mapped to jsx And less file
.
├── apis
│ ├── community.ts
│ ├── h5community
│ └── ...
├── components
│ ├── h5community
│ └── ...
├── config
│ ├── h5community.js
│ └── ...
├── pages
│ ├── community
│ └── h5community
│ ├── column // primary column.vue Convert to directory , Split into index.tsx And index.scss
│ │ ├── index.local_js // index.local_js Reserved as a comment , Reference for testing regression
│ │ ├── index.scss
│ │ └── index.tsx // The first line is automatically inserted into the pair index.scss References to
│ └── ...
└── utils
├── h5community
└── ...- Step by step conversion 1: File level
// The file before conversion is foo.vue
// After the transformation :
.
└── foo
├── index.jsx
├── index.local_js
└── index.scss
- Step by step conversion 2: Grammar level - html lang
// Before conversion foor.vue in
<template lang="pug">
article.modal-wrap(@touchmove.stop.prevent @click.stop='close')
section.modal
p.more More highlights , Just get something App
p.slogan Poisonous movement x Trend x Good thing
.enter-btn(@click.stop='enter') Enter the object App
aside.close(@click.stop='close')
</template>
// After the transformation foo/index.jsx in
<article class="modal-wrap" @touchmove.stop.prevent="@touchmove.stop.prevent" @click.stop="close">
<section class="modal">
<p class="more"> More highlights , Just get something App</p>
<p class="slogan"> Poisonous movement x Trend x Good thing </p>
<div class="enter-btn" @click.stop="enter"> Enter the object App</div>
<aside class="close" @click.stop="close"></aside>
</section>
</article>- Step by step conversion 3: Grammar level - className etc.
// foo.vue Writing method in documents
<div class="var1">demo1</div>
<div class="var1 var2">demo1</div>
// foo/index.jsx (react in ) Writing
import style from './index.scss'
import classNames from 'classnames'
...
<div className={style["var1"]}>demo1</div>
<div className={classNames(style["var1"], style["var2"])}>demo1</div>- Page by page debugging and proofreading
- Differences in warehouse technology selection
- umi Routing rules and customization
- Third party component library
- Such as Swiper、postcss-px-to-viewport etc. ,vue Edition and react There are some differences in the edition , Incomplete documentation , Embrace source code and community . among postcss-px-to-viewport Use different... In different warehouses viewportWidth Set up , In the conversion process, different path ranges are processed for different plug-in instances
- Basic skill : Sensitivity ( This has something to do with experience ). What is the library location ? How about maturity ? What should be supported and what should not be supported ? How would you design it if you designed it yourself ( Sometimes even if the documents are incomplete , You can push out a lot of content without looking at the source code )? Where to find solutions ? How to find ?
- transfer home Page configuration
- Zoom out in the process home Path range of the page , hide repo A Access path in , Only the path to be migrated , Improve search efficiency
- Migration process record ( Test data and path, etc , Facilitate cross testing and QA Return to )
- Coverage self test . Multiple business logic in one page , Sufficient self-test shall be carried out for each path in the future
- Design and change path of directory and file structure during migration ( important )
2.3.3 Integrate repo A、repo B、repo C Refactoring branch code
- repo B Pages in migrate to repo A in , If used chore-repoB Branch
- repo C Pages in migrate to repo A in , If used chore-repoC Branch
- take repo A master Branch and chore-repoB、chore-repoC Merge and resolve conflicts , The merged branch is recorded as chore-repoA-repoB-repoC, At this time, the branch has only V1 Code for , The iteration function of the current version of each warehouse and that of the previous version hotfix Has not been merged into this branch .
2.3.4 Integrate repo A、repo B、repo C Iterative branch code in
2.3.5 Integrate three warehouse business codes with SSR Code
3. External coordination of project promotion
3.3 Problems encountered
4. summary
Related links :
- https://pughtml.com/
边栏推荐
- 信创之下:国产数据库群星闪耀时
- Translate the tutorial Txt file
- 重磅直播|BizDevOps:数字化转型浪潮下的技术破局之路
- MySQL_ Create and manage tables
- 仿网易云音乐的滑动冲突处理效果
- SAP-ABAP-如何实时传输物料主数据,供应商主数据,工单,采购订单等信息给外部系统-隐式增强。
- Analysis of STM32 Hal serial port interrupt
- Final of the 13th Blue Bridge Cup embedded design and development project
- Tis tutorial 02 model
- 巨杉数据库荣获艾媒咨询2022年中国信创产业双项荣誉
猜你喜欢

SAP 系统取消用户设置ALV全局布局

Flutter - realize progressive card switching of Netease cloud music

SAP 客户端中文显示乱码问题

Flutter:剥离StatefulWidget——简化页面开发、跳转以及传值

Parallels Desktop 17.1.4pd virtual machine

Parallels Desktop 17.1.4pd虚拟机

Universaldependencies dependency label interpretation

SAP-MM-MIGO 311工厂内转移挑拨库存

Tis tutorial 01- installation

MySQL_数据处理之查询
随机推荐
[MySQL] the difference between where and having
XML file parsed by repo
SAP fi financial statement version setting
Translate the tutorial Txt file
Zcu102 PL end running water lamp
SAP-abap-OLE核心代码
修复flutter_webview_plugin在页面滑出时web图层残留的问题
Difference between function pointer and pointer function
[QT] QT get standard system path
第十一届 蓝桥杯 嵌入式设计与开发项目 决赛
Ffmpeg converts AMR format to MP3 format
请问Flink的动态表是这样创建吗?我用flink cdc 读mysql数据,写flink动态表,发
Flutter之CustomPaint 绘制贝塞尔曲线图表(三)
Parallels Desktop 17.1.4pd virtual machine
SAP 系统取消用户设置ALV全局布局
SAP-ABAP- 如何查找表,字段有哪些关联表
8 challenges of BSS application cloud native deployment
信创之下:国产数据库群星闪耀时
帝云CMS升级PHP8注意事项
In depth analysis of glide source code