lots of boolean flag inputs to a class

I have a dialog that displays various things depending on state of the application, security for the current user etc. I am currently passing in several boolean flags and then enabling and/or hiding UI components depending on these flags.Eg: new MyDialog(showOptionsTable, allowFooInput, allowBarInput, isSuperUser) Initially this started out as a couple of flags and that was fine. But now with changing requirements, it has evolved into an input of five boolean flags. What is the best practices way of handling behavior like this? Is this something that I should subclass depending on how the dialog should look?

以上就是lots of boolean flag inputs to a class的详细内容,更多请关注web前端其它相关文章!

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

评论 抢沙发

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

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