This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术 / 今儿浏览公司代码,无意中发现这段code,大惊失色,马上预警通知公司内部一个号称工作10年的.net大牛,没想到大牛和俺电话上来回争论半个小时说这段代码没有问题;最后俺说算求了,爱咋咋地,老子出去赏枫去;这就是加拿大排名前几位公司出品的软件质量public virtual TypeA NextName { get { return GetNextName(); } set { NextName = value; } }
-binghongcha76(一只大猫);
2021-10-15
{89}
(#14044564@0)
-
大猫也是用dinosaur语言编程的😂握手🤝是东欧来的一代移民写的代码吧,熟悉的味道
-benii(惊坐起);
2021-10-15
{40}
(#14044586@0)
+2
-
惭愧,还真不知道啥是dinosaur,这段代码已经在系统内好几年了,已经没法考证是谁写的了;没有暴雷是因为暂时没有代码访问那个setter
-binghongcha76(一只大猫);
2021-10-15
(#14044602@0)
-
2001年的时间我们公司一个罗马尼亚人看了Andrei Alexandrescu还是谁的书,然后学了几招花的,你那个set function非常像当初那个人练的反向函数赋值。他只是漏了点东西
-benii(惊坐起);
2021-10-15
(#14044619@0)
-
也爆不了啥雷,不就是throw一个StackOverflowException 嘛……
-guestagain(guest again);
2021-10-15
(#14044695@0)
-
你讨论之前或之后为什么不写一个unit test,既然已经争论了半小时,把结果一放,还要讨论吗?
-sxffff(lookingforjob);
2021-10-16
(#14045075@0)
+2
-
正解!
-piglet(小猪);
2021-10-16
(#14045241@0)
-
越看这代码越像是从JAVA转过去的,然后JAVA的code里面没有setter,某位老兄就自己加了个啥东东,其实这可能就应该是个readonly的property。
-guestagain(guest again);
2021-10-16
(#14045163@0)
-
大牛怎么说的?
-xmlhttprequest(build5381);
2021-10-15
(#14044612@0)
-
大牛很搞笑,反驳我说系统内还有很多类似的setter,还给我找出来看,这里,那里,你看都没事吧?大惊小怪,运行的好好的;我看完没说啥,默默的结束了通话,祝好运,又不是我家公司。。
-binghongcha76(一只大猫);
2021-10-15
(#14044632@0)
+1
-
可能正好所有的 derived class 都 override 了,或者正好没人调过 --- 随便写个 unit tests 就可以证明是个雷。
-xmlhttprequest(build5381);
2021-10-16
(#14045283@0)
+1
-
厉害,这是最直接的原因,所有有问题的property全都被child class override了,所以才会没有问题;这些问题代码全部在最root的class里
-binghongcha76(一只大猫);
2021-10-16
(#14045326@0)
-
如果那样,其实很容易 fix --- 直接把这行删掉换成 throw exception 就完了 (用 abstract 可能更正经儿些,但看你的 code,大牛 f-up 的地方可能还有很多不太容易一下清干净)。
-xmlhttprequest(build5381);
2021-10-16
(#14045334@0)
-
是,如果是force child class强制override,应该用abstract
-binghongcha76(一只大猫);
2021-10-16
(#14045362@0)
-
理论上所有的child class必须is-A parent class,但实际中各种人写的child class都是100% is-Not-A parent class. 在container这种必须是is-A morphism的,各种软件屎bug就出来了。
-zhengy4(_);
2021-10-17
(#14049162@0)
+1
-
也许正是因为有问题又不肯改,所以才会被child class override呢。
-guestagain(guest again);
2021-10-16
(#14045371@0)
+1
-
我记得如果用ReSharper的话,这种写法是会报警的
-binghongcha76(一只大猫);
2021-10-16
(#14045456@0)
-
这种历史遗留问题,没人愿意碰,都怕以后麻烦找上门……
-guestagain(guest again);
2021-10-16
(#14045551@0)
+1
-
warning, who cares?
-sxffff(lookingforjob);
2021-10-16
(#14045586@0)
+1
-
recursion, 啥大牛
-keysi(K.S);
2021-10-15
(#14044779@0)
+1
-
不会。内层的是default,和外层的不同。
-less_is_more(二手黑客);
2021-10-15
(#14044789@0)
+1
-
setter是recursion for sure, 不信你干点儿事儿看看, 马上stack overflow
-keysi(K.S);
2021-10-15
(#14044794@0)
+1
-
编译器很聪明的,不会发生这种情况,内层用的是built in简单数据类型赋值,外层才定义为函数。
-less_is_more(二手黑客);
2021-10-16
(#14044796@0)
+1
-
NextName = value, NextName只有同名的properties, 100% recursion,不信的话,你可以在setter里加一句打印语句
-keysi(K.S);
2021-10-16
(#14044805@0)
+2
-
编译器解释器的基本原理就是只有递归的运行没有递归的定义,所以set里的等号不是set。如果因此产生bug说明是编译器问题,如果该语言认为是bug不应该编译通过
-less_is_more(二手黑客);
2021-10-16
(#14045373@0)
+1
-
这就是胡扯了……
-guestagain(guest again);
2021-10-16
(#14045097@0)
-
你们没有一个记录跟踪bug的系统么 你就记录上去 事后被怎么处理随他 日后出了问题还能查到你曾经爆过 被捂住了
-facenorthface(小北);
2021-10-16
(#14045027@0)
+5
-
这个是正解。👍
-newrover(漫游);
2021-10-17
(#14047696@0)
-
程序没有暴,那就不是bug。估计你们测试也就瞎测一下,没有code coverage要求的
-gta_palace(呄 - 每天乃古);
2021-10-16
(#14045050@0)
-
大拿们,能先解释一下这一行莫名其妙的字母加数字怎么就让你们大惊失色了?
-cicy(HuntforFreedom);
2021-10-16
(#14045100@0)
-
自己去运行一下就知道了
-guestagain(guest again);
2021-10-16
(#14045117@0)
-
请问你这个又是什么意思啊?在哪里能运行?要用卡车运吗?我们木有卡车呀😂
-cicy(HuntforFreedom);
2021-10-16
(#14045121@0)
-
哦,看不明白就那就不要问技术细节了,就看热闹就好……
-guestagain(guest again);
2021-10-16
(#14045139@0)
-
好学呀,急死我了……马上找小匹学电脑去了
-cicy(HuntforFreedom);
2021-10-16
(#14045141@0)
+2
-
请问你自己运行过吗?楼主这两行码也不是贴上去就能运行的,太麻烦,俺就看热闹了。我好多年没写过码了,但是据记忆这是.net正确的简写。
-piglet(小猪);
2021-10-16
(#14045226@0)
-
啥?当然不是直接就可以,我只是给个地方…… 您的记忆是错的……
-guestagain(guest again);
2021-10-16
(#14045251@0)
-
你就不可能看错了?码工讲究的证据证据证据
-piglet(小猪);
2021-10-16
(#14045257@0)
-
哎,我的意思是,连怎么运行都不知道就别凑热闹了…… 算了算了,这样可以了吧?
-guestagain(guest again);
2021-10-16
(#14045267@0)
-
你这个是故意implement了一个会出错的条件,不是楼主原码出错,是你的class implementation的问题, 不是caller的事儿,当然这种implementation很少见,告诉Microsoft吧
-piglet(小猪);
2021-10-16
(#14045284@0)
+1
-
哈?我故意?您真的是写过代码的人?
-guestagain(guest again);
2021-10-16
(#14045288@0)
-
不好意思,俺曾是.net大牛,后来不写了
-piglet(小猪);
2021-10-16
(#14045308@0)
-
哦,大牛你好,大牛再见……
-guestagain(guest again);
2021-10-16
(#14045312@0)
+1
-
谢谢, 不用跟学生级别的准外行矫情课堂练习级别的东西了😂
-piglet(小猪);
2021-10-16
(#14045329@0)
+1
-
嗯,好,小的退散了……
-guestagain(guest again);
2021-10-16
(#14045333@0)
-
大猫啊,哪里小了?😂
-piglet(小猪);
2021-10-16
(#14045410@0)
-
我刚注意到,你和楼主就是照抄别人的黑客寻衅微软结果,拿来给正经公司的英语程序员看,一群马甲挖坑的?
-piglet(小猪);
2021-10-16
(#14045344@0)
+1
-
?这是啥神展开?
-guestagain(guest again);
2021-10-16
(#14045349@0)
-
这个不需要运行,只要概念清楚一看就知道了,因此楼主提到的大牛至少不会是C#的
-keysi(K.S);
2021-10-16
(#14045254@0)
+2
-
又一个纸上谈兵不懂装懂的,你会.net吗? 这个概念是对的,.net法定的简写格式。其它细节我是没看到,除了楼主的反应。
-piglet(小猪);
2021-10-16
(#14045263@0)
-
扯吧……
-guestagain(guest again);
2021-10-16
(#14045268@0)
-
程序员要都是你这个态度就完了,NextName是class的property name,相当于this.NextName =value,recursion这该明白了哈,这个其实都不需要懂c#, 学编程的都应该知道,属于基本概念
-keysi(K.S);
2021-10-16
(#14045286@0)
+2
-
哪个程序员或测试员敢用明摆这个词就该fire了。 基本概念以微软文档为准,不以小匹的眼光为准
-piglet(小猪);
2021-10-16
(#14045296@0)
-
楼主最后的态度是正确的,大牛是不对的,大牛应该让楼主把所有的相关代码都检查一边并把单元测试都写好,然后对楼主进行口头表扬!
-ff2021(ff2021);
2021-10-16
(#14045184@0)
-
悄悄删了才是正解
-firetrain(火车头);
2021-10-16
(#14045191@0)
-
如果不是自己负责的部分,要慎重,自己职责边界内的自己决定,边界外的可以小心地提供建议,谨言慎行。
-ff2021(ff2021);
2021-10-16
(#14045261@0)
-
画地为牢是不对的。真正的高手是容不下一点多余的。
-firetrain(火车头);
2021-10-18
(#14049240@0)
-
请问你有没有运行,验证会出错? 有的话把结果拷屏扔给同事,cc头儿, 大功一件。没有的话就自己憋着吧,可能是你自己短路。我好多年没写过码了,但是据记忆这是.net正确的简写,当然码不能目测,没有运行验证的任何码都可能有问题。
-piglet(小猪);
2021-10-16
(#14045239@0)
+2
-
这个不需要验证,就是看一眼的问题,吃这碗饭的,这是基本功;我本来是抱着发现地雷邀功请赏的心态去和大牛报告的,结果练了半小时英语,好啊油
-binghongcha76(一只大猫);
2021-10-16
(#14045306@0)
+1
-
算了,随你吧,忠言一句,自己写的码万不可偷懒不运行,读别人的码不理解的话要么深究要么跳过。
-piglet(小猪);
2021-10-16
(#14045316@0)
+1
-
只要是合格的程序员,这东东看一眼就够了…… 今天真是开了眼界……
-guestagain(guest again);
2021-10-16
(#14045317@0)
+1
-
俺也开了眼,一个单位有几个无事生非不懂装懂的人,大家谁也干不好活儿😂
-piglet(小猪);
2021-10-16
(#14045323@0)
+2
-
“不懂装懂"这词用的真好……
-guestagain(guest again);
2021-10-16
(#14045328@0)
+1
-
looooooooooool 看楼上讨论,“大牛” 是客观存在。
-xmlhttprequest(build5381);
2021-10-16
(#14045290@0)
-
哈哈
-guestagain(guest again);
2021-10-16
(#14045294@0)
-
确实,common practice, 码不会100%没bug, 边界条件总有的,关键是合理可行
-piglet(小猪);
2021-10-16
(#14045318@0)
+1
-
一群马甲挖的坑, 照抄黑客码连class name都不改,不信请老大验证IP😂 binghongcha76, guestagain, keysi...
-piglet(小猪);
2021-10-16
(#14045348@0)
+1
-
大哥,这东东还要黑客?您真是程序员?这黑客已经饿死了吧……
-guestagain(guest again);
2021-10-16
(#14045358@0)
+1
-
你贴的那个外国话的网址,难不成楼主也碰巧看到了.😂
-piglet(小猪);
2021-10-16
(#14045378@0)
+1
-
天…… 算了算了,没义务教你怎么用dotnetfiddle.net,这算不算你就是那个黑客的证据?
-guestagain(guest again);
2021-10-16
(#14045384@0)
-
那人家嚼过的东西,给自家同事看,略微该一下很难么?
-piglet(小猪);
2021-10-16
(#14045396@0)
+1
-
行了,大牛乖,该睡午觉了……
-guestagain(guest again);
2021-10-16
(#14045398@0)
+1
-
小外行继续放狗搜,进国家队有望😂
-piglet(小猪);
2021-10-16
(#14045402@0)
+1
-
哥,我和前两位网友经常吵,你不能因为这次没吵,就给归成马甲哈
-keysi(K.S);
2021-10-16
(#14045360@0)
+1