惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Troy Hunt's Blog
Google DeepMind News
Google DeepMind News
G
Google Developers Blog
F
Full Disclosure
N
Netflix TechBlog - Medium
C
Check Point Blog
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
M
MIT News - Artificial intelligence
H
Help Net Security
F
Fortinet All Blogs
P
Proofpoint News Feed
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Vercel News
Vercel News
A
About on SuperTechFans
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
B
Blog RSS Feed
S
Securelist
Y
Y Combinator Blog
C
Cybersecurity and Infrastructure Security Agency CISA
D
DataBreaches.Net
B
Blog
The Hacker News
The Hacker News
Security Latest
Security Latest
P
Privacy & Cybersecurity Law Blog
Scott Helme
Scott Helme
D
Darknet – Hacking Tools, Hacker News & Cyber Security
V
Vulnerabilities – Threatpost
Martin Fowler
Martin Fowler
人人都是产品经理
人人都是产品经理
Forbes - Security
Forbes - Security
T
The Exploit Database - CXSecurity.com
Latest news
Latest news
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
AWS News Blog
AWS News Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
C
Cisco Blogs

博客园 - luckygxf

javascript构造方法 数据库连接池初始连接 分布式系统CAP理论(一) 数据库连接太多排查(一) 审批流程-节点自动审批通过 防表单重复提交 深分页问题 devops 对象存储迁移-组件上线 工作效率提升 新需求开发-重构老的逻辑 js析构赋值 框架的好处和不足 React框架Hello world 数据库表设计在哪个接口 需求实现-ddd四层架构实现 前端代码(一) 高内聚,低耦合 对象存储改造 mermaid初体验 业务逻辑优化-解决提示词问题打分不准 idea 插件envfile初体验 防盗链-防盗用链接 springboot项目启动小技巧 github托管网站 AI MCP开发 AI中 MCP 作用 mapconstruct 初体验 架构积累-解耦与防腐 表创建索引的重要性 drawio初体验 六边形架构 架构积累-依赖注入和SOLID原则 工作总结-定时任务 工作总结-知识通关需求上线 工作总结-演练场景映射方案 工作总结-MVP 工作总结-需要学习的方向 工作总结-接口优化 python asyncio demo 工作总结-sse接口心跳 工作总结-问题筛选方案 工作总结-工具分享 工作总结-提示词优化 工作总结-工作优先级 工作总结-灰度发布
重构注意事项(一)
luckygxf · 2026-04-16 · via 博客园 - luckygxf

加入了AI对练项目,看到其中有一些重复代码,想抽取出来,做成工具方法。看到有一些硬编码,想要抽取成变量或者枚举值。看到一些字典,想定义类,好维护一些。重构是可以的,不过要注意问题。

1. 最好不要修改原来的代码,不知道历史背景,可能会修改出问题。原来的代码没有问题,就先不优化。

  我把一个userinfo对象,从字典,定义成了一个类。把原来的使用的地方都改了,有个地方改错了,导致线上出了问题。一个中心的投顾,不能看到分行客户经理的记录了。

2. 建议新增方法、类、接口,比如方法v2等,新需求使用新的方法、类、接口。不要修改原来的地方

  抽象了一个方法,生成http默认头部,有application-type、cookie字段。通过浏览器访问的请求,都有cookie,通过定时任务访问的接口都没有cookie。导致后面序列化请求的时候报错。cookie为空,序列化报错。

  新需求使用新方法也会报错,不过影响面会更小,不会影响原来的功能,修改引入。

3. mvp原则,小步重构,生效后再逐步迭代。不要一下重构太多内容,这样风险很大,很容易修改出问题,测试不容易完全覆盖。在HW公司应该就是修改引入了