Best table / enum driven method calling system

Consider I'm interfacing with an external system that will send a message (DB table, message queue, web service) in some format. In the "message header" there is the "MessageType" that is a number from 1 to 20. The MessageType defines what to do with the rest of the message. There are things like new, modified, deleted, canceled... My first inclination was to setup an enumeration and define all the types. Then parse the number into an enum type. With it as an enum I would setup the typical switch case system and call a particular method for each of the message types. One big concern is maintenance. A switch / case system is bulky and teadious but, it's really simple. Various table / configuration systems can be difficult for someone else to grok and add new messages or tweak existing messages. For 12 or so MessageTypes the switch/case system seems quite reasonable. What would be a reasonable cut-off point to switch to a table driven system? What kinds of systems are considered best for handling these types of problems? I'm setting a tag for both C# and Java here because it's definitly a common problem. There are many other languages with the same issue.

以上就是Best table / enum driven method calling system的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准