This topic has been archived. It cannot be replied.
-
工作学习 / 事业工作 / 最近面试,让现场写一个小project,就是出一个场景,然后让你用代码实现,没有标准答案,就看你各个对象之间的设计是否合理,代码设计是否简洁明了;一般1小时之内完成
考题一:有一台冰箱,内有一部发动机,负责制冷,冰箱外面有一个界面,人可以通过界面设置冰箱内部温度;如果冰箱门开了10分钟就要报警;冰箱的发动机,界面都是可以更换的,比如以后有新款界面拿来把旧的拆下来安装上新的就好;
写一个project,实现这个冰箱所描述的这些基本功能;
各位大牛小牛要跳槽刷题的,闲得无聊可以做做
-binghongcha76(一只大猫);
2021-8-31
{324}
(#13953214@0)
-
简单! 花100快请个写手。如果他们肯付你200块,你就有100块的利润。每天请1个专家赚800块,10个8000块,依次类推
-4_fun(寻开心: 誓别三推);
2021-8-31
(#13953480@0)
-
同情一下码工们.....什么编程语言?
-fxid(闲聊灌水);
2021-8-31
(#13953497@0)
-
BASIC
-manniangpai(慢两拍);
2021-8-31
(#13954198@0)
-
.net c#,这有啥同情的,写这玩意和喝凉水一样
-binghongcha76(一只大猫);
2021-8-31
(#13954260@0)
-
这种小玩意儿都写不出来就别吃这碗饭。估计不希望滥竽充数的人进来
-once01(一切都还没结束);
2021-8-31
(#13954384@0)
-
小玩意?注意细节:界面可以随时换。出题的人猜测应是C++出身。cpp 不难,别的语言还真不简单易弄
-zbeifly(苇子坑);
2021-8-31
(#13954416@0)
-
记得二十年前还用c++编程的时候也是这么面试......
-fxid(闲聊灌水);
2021-8-31
(#13954812@0)
-
其它都好说 换新冰箱的代码不知道咋写
-facenorthface(小北);
2021-8-31
(#13953603@0)
-
不错啊,看看OO design的理解程度
-keysi(K.S);
2021-8-31
(#13953611@0)
-
如果冰箱门开了10分钟就要报警 - 这个功能不好写
-ff2021(ff2021);
2021-8-31
(#13954188@0)
-
考的是设计模式
-new_house123(new_house123);
2021-8-31
(#13954457@0)
+2
-
嗯,也可以这么说,但是写project的时候根本没考虑什么模式;面试结束对方问我知不知道用了多少种设计模式?我说不知道,就是感觉舒服了,爽了,就知道大概设计合理了
-binghongcha76(一只大猫);
2021-9-1
(#13956190@0)
-
就考2个模式, factory pattern 还有 adaptor pattern。
-boolean(扎根儿农村);
2021-9-8
(#13968178@0)
-
IEngine 有 IsRunning {get;} / Start() / Stop(); IDoor 有 Opened / Closed event;IController 有 TemperatureSetting。IEngine/IDoor DI 进 Controller。
Controller 有个 10 分钟 timer,door Opened event 发生时启动,door Closed event 发生时停止。如果 10 分钟到,开始 beep。
Controller 有另一个轮询 timer,每隔 n 秒比较 _currentTemperature 和 TemperatureSetting,启动 / 停止 engine...
UI 通过 IController.TemperatureSetting {get; set;} 显示 / 更改 TemperatureSetting
-xmlhttprequest(build5381);
2021-8-31
{337}
(#13954733@0)
-
Controller判断温度还要加一个tolerance。或者不采用轮询,而是由温度传感器发event
-exception(违例);
2021-9-1
(#13955274@0)
-
一般来说温度传感器是比较 dumb 的。但真的 controller 多半应该使用 PID 控制算法来根据温差决定输出。不过这就不是这个 code 要演示的了...
-xmlhttprequest(build5381);
2021-9-1
(#13955592@0)
-
cool, 不过我提交的project没有IDoor这个概念, door 和 冰箱是一体的,冰箱接口IRefContainer 有一个void OpenDoor(),void CloseDoor(), 触发警报的event Action<string> OnDoorOpenOverTimeAlert; 代码提交后能保证基本运行,面试官会围绕我的设计问各种奇葩问题
-binghongcha76(一只大猫);
2021-9-1
(#13955420@0)
-
lol 其实不需要 IDoor --- 一般来说门开关是个开/关 sensor,所以完全可以抽象成 IController 的一个 bool property IsDoorOpen {get; set;} 其实都无所谓啦,只要能显示你会根据需求做抽象设计就可以了
不过较真说一下,Controller.IsDoorOpen 比 Controller.OpenDoor() / CloseDoor() 要更 make sense 一些...
-xmlhttprequest(build5381);
2021-9-1
{102}
(#13955610@0)
+1
-
门跟Contorller 没有关系啊, 有关系的是冰箱。Contorller 应该叫Panel, DI进冰箱, 随时可以换。
-sxffff(lookingforjob);
2021-9-1
(#13956148@0)
-
基于业务需求的抽象不需拘泥于具体物件 -- 在这个例子里,门的唯一作用就是一个开/关的 switch,所以可以(简化)抽象成 Controller 的一个 state --- 你想象一下有两根线连进 Controller (或者如你所叫 Panel) set on/off。
象我一开始把 Door 分离也可以,更 fancy 些,但最终其实只是提供一个 on / off...
有时候没有绝对对错,只是看容不容易扩展,更改,和理解...
-xmlhttprequest(build5381);
2021-9-1
{146}
(#13956221@0)
-
这个state是门的state, 也可以是冰箱的state, 但不是Panel的state, 如果换Panel,跟门是没有关系的,如果在panel里面,换Panel后, 你怎么知道门是开还是关呢? 当然你可以从旧的copy过去,但一般不这么做。
-sxffff(lookingforjob);
2021-9-1
(#13956254@0)
-
这个真的不一定重要。比如冰箱门开了,里面灯就亮了,其实你可以直接按那个小switch控制灯亮灭,不需要门。同理,*在这个use case里*,你*可以*跳过门(实物),直接抽象成 Panel switch1 (door) (没准儿还有s2, s3..) 新的panel装上了,s1/s2/s3是on还是off都会被设置的
要想 fancy 当然完全可以有 Door,然后让 Door 的开关状态和 Panel switch1 动态绑定(更像通用型可更换面板了吧)blah blah blah 但面试时候我一般见好就收 lol...
-xmlhttprequest(build5381);
2021-9-1
{155}
(#13956458@0)
-
你自定义requirement了吧?Panel只是控制温度的,没说有控制门的灯啊?这Panel连Engine也控制了?
-sxffff(lookingforjob);
2021-9-1
(#13956507@0)
-
那个灯只是举个例子,如何跳过表象(门)看本质(switch) ---- 没有说楼主有这个需求。现在的冰箱好像界面/控制面板就是一回事儿了吧 --- 修冰箱时,控制单元坏了换了整个面版 --- 所以控制面板是要启停 engine 啊 --- 这个需求理解错了吗?
-xmlhttprequest(build5381);
2021-9-1
(#13956541@0)
-
这个是通过断电来实现的吧?一般来说,Engine不是控制面版的一部分,而是冰箱的一部分,所以控制面板要控制Engine,要先拿到冰箱的reference, 再access Engine
-sxffff(lookingforjob);
2021-9-1
(#13956804@0)
-
想知道楼主拿下了没有?感觉这一通下来除了Door没有必要,其他都没有问题,写代码不光得自己爽,最好让大家一起爽。
-ff2021(ff2021);
2021-9-12
(#13976056@0)
-
当然拿到了,不过进了公司实际干的活和面试的这些完全没啥关系;大公司面试都是这样,这些技能你不能没有,但实际工作的时候完全用不到
-binghongcha76(一只大猫);
2021-9-13
(#13977975@0)
-
这个题目主要考的是你对adaptor的模式的理解,外加一些基本的coding skills....
-boolean(扎根儿农村);
2021-9-8
(#13968147@0)