当前位置:网站首页>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)
边栏推荐
猜你喜欢
加密生活,Web3 项目合伙人的一天
成为比开发硬气的测试人,我都经历了什么?
After reading "MySQL Database Advanced Practice" (SQL Xiao Xuzhu)
pycharm重命名后无法运行(报错: can‘t open file......No such file or directory)
vlan间路由+静态路由+NAT(PAT+静态NAT)综合实验
coldfusion文件读取漏洞(CVE-2010-2861)
Nacos
Interprocess communication study notes
STP选举(步骤+案列)详解
934. The Shortest Bridge
随机推荐
coldfusion8后台计划任务拿shell
Software Testing Defect Reporting - Definition, Composition, Defect Lifecycle, Defect Tracking Post-Production Process, Defect Tracking Process, Purpose of Defect Tracking, Defect Management Tools
Drools Rule Properties, Advanced Syntax
[Map and Set] LeetCode & Niu Ke exercise
Introduction and use of Drools WorkBench
"Cloud native's master, master and vulgar skills" - 2022 National New College Entrance Examination Volume I Composition
Kyushu cloud as cloud computing standardization excellent member unit
【Map与Set】之LeetCode&牛客练习
Are you still working hard on the limit of MySQL paging?
软件测试缺陷报告---定义,组成,缺陷的生命周期,缺陷跟踪产后处理流程,缺陷跟踪处理流程,缺陷跟踪的目的,缺陷管理工具
程序员转正述职报告/总结
华为od 转骰子 js
ShardingJDBC基本介绍
cudaMemcpy study notes
进程间通信学习笔记
Drools WorkBench的简介与使用
Path and the largest
【AcWing 62nd Weekly Game】
Maximum monthly salary of 20K?The average salary is nearly 10,000... What is the experience of working in a Huawei subsidiary?
Unity界面总体介绍