📣 独立日限时特惠: VIP通行证立减$68
查看: 2523| 回复: 1
跳转到指定楼层
上一主题 下一主题
收起左侧

[经验总结] Design Pattern 设计 - 请看应该选择那种模式

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
讨论如下设计题Task
  • Implement a type "Robot" with the following requirements
    • Robot must support pluggable chips that allow him to do different operations on numeric arrays
    • Only one chip can be plugged at a time and robot can't function without a chip
    • Chips can be swapped at runtime, since you have only one robot instance (robots are expensive)
  • Robot should have only two functions/methods
    • A function that executes current chip's logic and returns result, it should accept an array and return whatever current chip is returning
    • A function that installs a chip into a robot, it should accept a chip and should not return anything
  • Implement two chips
    • "Chip of Sorts" — sorts an array in the order and can have an option to specify ascending or descending type of sorting. (Sorting algorythm is not important, use standard one from any library you want.)
    • "Total Chip" — finds a total sum of all elements of an array
  • Add a property to your robot that represents total number of different chips installed through robot's lifetime. It should only count unique chips being installed.
  • Write one simple test function that tests logic from 4, you don't have to use any Unit Testing framework, just a simple function would be fine
  • It's up to you how do design your robot and types. Pay attention to make design simple and intuitive.
Bonus
There is no right or wrong solution as long as code works, but we give bonus points for a plain-text explanation on why particular design decisions were made and what are the tradeoffs. Put it right into the code in a form of a comment at the beginning of the main file.


上一篇:Bloomberg面试该准备系统设计还是OOD?
下一篇:Facebook news feed系统设计
🔗
14417335 2019-4-19 00:47:32 | 只看该作者
全局:
Robot
  execute chip logic
  install(chip)
  uniqueChipsUsed
Pluggable Chip Interface
  logic
SortChip
TotalChip
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表