当前位置:网站首页>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)

边栏推荐
- 12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche
- Arbitrum Interview | L2 Summer, what does the standout Arbitrum bring to developers?
- How to expose Prometheus metrics in go programs
- Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
- case语句的综合结果,你究竟会了吗?【Verilog高级教程】
- MySQL的安装教程(嗷嗷详细,包教包会~)
- 真正的CTO,是一个懂产品的技术人
- Set the browser scrollbar style
- 934. 最短的桥
- leetcode-128: longest continuous sequence
猜你喜欢

成为比开发硬气的测试人,我都经历了什么?

Interprocess communication study notes

STP选举(步骤+案列)详解

MySql installation and configuration super detailed tutorial and simple method of building database and table

JPEG Steganalysis of Digital Image Steganography

MySQL的存储过程

Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things

12 pictures take you to fully understand service current limit, circuit breaker, downgrade, and avalanche

静态路由+PAT+静态NAT(讲解+实验)

coldfusion8后台计划任务拿shell
随机推荐
Software testing basic interface testing - getting started with Jmeter, you should pay attention to these things
真正的CTO,是一个懂产品的技术人
Drools规则属性,高级语法
MySQL的安装教程(嗷嗷详细,包教包会~)
有没有可以做副业可以日入300元方法?
Unity界面总体介绍
如何在 go 程序中暴露 Prometheus 指标
coldfusion文件读取漏洞(CVE-2010-2861)
系统需求多变如何设计
multiplayer-hlap 包有问题,无法升级的解决方案
[Map and Set] LeetCode & Niu Ke exercise
《MySQL数据库进阶实战》读后感(SQL 小虚竹)
计算S=a+aa+…+aa…a
tkinter模块高级操作(二)—— 界面切换效果、立体阴影字效果及gif动图的实现
leetcode-399: division evaluation
coldfusion8后台计划任务拿shell
Can an inexperienced college graduate switch to software testing?my real case
MySql的初识感悟,以及sql语句中的DDL和DML和DQL的基本语法
验证 XML 文档
关于Redis相关内容的基础学习