当前位置:网站首页>How to design the changing system requirements
How to design the changing system requirements
2022-07-31 01:51:00 【xushiyu1996818】
Note: This article refers to "Online Interviewer""Online Interviewer" system requirements change, how do you design it?
I now have a system that takes different actions based on the input parameters of the request.However, this different action is likely to have changes in demand. How would you design this system?
Practical example: There are now multiple third-party channels, and the system requires order attribution for each channel.However, the logic of attribution is likely to change, and the logic of attribution of different channels is not the same. At this time, the logic in the system is relatively complex.
If you could optimize, how would you design?
In the final analysis, the processing logic is relatively complicated, and there are too many if else judgments
Although new requirements come, they can be solved by adding if else
But what you want is a more scalable and maintainable system
Want me to come up with a solution to solve similar problems
Before this, most of the Internet searches on how to solve if else are said to be strategy mode
But I don't feel the same way about the example I gave. Many times I just finished reading it
Actually, in the project, there are still quite a lot of strategy patterns, which may have been used accidentally (after all, interface-oriented programming)
And in my opinion, the strategy pattern is not the key to solving if else
The approach in my project is: Chain of Responsibility Pattern
Extract each process into a Process (which can be understood as a module or node), and then the request will be stuffed into the Context
For example, if a project has been maintained before, it is similar to different channels and different logics
Our approach here is to extract relevant logic into the Process and assign different chains of responsibility to different channels
For example, the chain of responsibility of channel A is: WhiteListProcess->DataAssembleProcess->ChannelAProcess->SendProcess
The chain of responsibility of channel B is: WhiteListProcess->DataAssembleProcess->ChannelBProcess->SendProcess
On the basis of the chain of responsibility, "scripts" can be embedded in the code
For example, on SendProcess, there is a built-in script for sending messages (the script can select different operators to send messages).With the "script", changes to the logic can take effect without restarting.
Some people call this set of things a "rule engine".For example, the well-known implementation framework "Drools" in the rule engine can do similar things
Write easy-to-change logic on "scripts" (at least we believe that scripts are separated from the real logic of our application)
(The script here refers to the ruleset, it can be the dsl of Drools, it can be Groovy, it can be aviator, etc.)
At my previous company, Groovy scripts were used.The general implementation logic is: there is a special background to manage the script, and then the script is written to the "distributed configuration center" (refreshed in real time), and the client monitors whether the script stored in the "distributed configuration center" has changed.
If there are changes, recompile and load the script through the Groovy class loader, and finally put it into the Spring container for external use
The system I am currently in charge of is this way to deal with the business of changing and frequently changing requirements (chain of responsibility + rule engine)
As far as I know, our game business has done more things in the "chain of responsibility"
The "chain of responsibility" is no longer written in the code, but sinks to the platform to do "service orchestration", that is, the programmer goes to the "service orchestration background" to configure the information (configure each node of the responsibility chain)
A client using "Service Orchestration" in the business system can execute the code according to the process of "Service Orchestration" as long as the ID of "Service Orchestration" is passed in when requesting.
The advantage of this is that the business chain is configured in the background, and there is no need to maintain the chain in the system business, and the flexibility is higher (the written responsibility chain nodes can be combined at will)
边栏推荐
- Jiuzhou Cloud was selected into the "Trusted Cloud's Latest Evaluation System and the List of Enterprises Passing the Evaluation in 2022"
- uniapp uses 3rd party fonts
- 力扣每日一题-第46天-704. 二分查找
- 一个无经验的大学毕业生,可以转行做软件测试吗?我的真实案例
- 手把手教你配置Jenkins自动化邮件通知
- 加密生活,Web3 项目合伙人的一天
- Path and the largest
- What have I experienced to become a tester who is harder than development?
- 基于FPGA的售货机
- Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
猜你喜欢
tkinter模块高级操作(二)—— 界面切换效果、立体阴影字效果及gif动图的实现
加密生活,Web3 项目合伙人的一天
Chi-square distribution of digital image steganography
力扣刷题之有效的正方形(每日一题7/29)
MySQL的存储过程
MySQL installation tutorial (detailed, package teaching package~)
ShardingJDBC usage summary
Path and the largest
最高月薪20K?平均薪资近万...在华为子公司工作是什么体验?
934. The Shortest Bridge
随机推荐
【微信小程序】一文带你了解数据绑定、事件绑定以及事件传参、数据同步
打印任务排序 js od华为
Shell 脚本循环遍历日志文件中的值进行求和并计算平均值,最大值和最小值
12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
C语言小程序 -- 常见经典练习题
Chi-square distribution of digital image steganography
cudaMemcpy学习笔记
【AcWing 62nd Weekly Game】
leetcode-952:按公因数计算最大组件大小
Unity界面总体介绍
leetcode-399: division evaluation
Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
Force buckled brush the stairs (7/30)
验证 XML 文档
软件测试基础接口测试-入门Jmeter,你要注意这些事
MySQL的安装教程(嗷嗷详细,包教包会~)
[WeChat applet] This article takes you to understand data binding, event binding, event parameter transfer, and data synchronization
【Map与Set】之LeetCode&牛客练习
Can an inexperienced college graduate switch to software testing?my real case
成为比开发硬气的测试人,我都经历了什么?