微软 Microsoft 系统设计/面向对象真题:支持多种访问限制(Block + Log 可叠加)

11次阅读
没有评论

Modify your implementation to support different types of restrictions.
Possible restrictions are:

  1. BlockAccess: Block access to the resource.
  2. LogAccess: Do not block access, but log an alert that the user has accessed the resource. This alert is logged through a stubbed service call.
    These restrictions are not mutually exclusive. You may want to block access and log access for the same content tag.

这题考的是 可扩展的设计能力 :限制不应该只是“二选一”的枚举,而应支持 组合 / 叠加 (同一 tag 同时 Log + Block)。面试官重点看:抽象是否干净、将来加新 restriction 是否容易、以及“同时命中多条限制”时你的 执行顺序与行为定义 是否清晰(比如先记 log 再 block,或两者都做)。

正文完
 0