- 浏览: 865424 次
- 性别:
- 来自: lanzhou
-
文章分类
最新评论
-
liu346435400:
楼主讲了实话啊,中国程序员的现状,也是只见中国程序员拼死拼活的 ...
中国的程序员为什么这么辛苦 -
qw8226718:
国内ASP.NET下功能比较完善,优化比较好的Spacebui ...
国内外开源sns源码大全 -
dotjar:
敢问兰州的大哥,Prism 现在在12.04LTS上可用么?我 ...
最佳 Ubuntu 下 WebQQ 聊天体验 -
coralsea:
兄弟,卫星通信不是这么简单的,单向接收卫星广播信号不需要太大的 ...
Google 上网 -
txin0814:
我成功安装chrome frame后 在IE地址栏前加上cf: ...
IE中使用Google Chrome Frame运行HTML 5
This is a letter that I would not show to a programmer in a real-life situation. I've often thought of bits of it at a time, and those bits come up in conversation occasionally, but not all at once.
This is based on an observation of the chat window in Skype 4.0.0.226.
Dear Programmer,
I discovered a bug today. I'll tell you how I found it. It's pretty easy to reproduce. There's this input field in our program. I didn't know what the intended limit was. It was documented somewhere, but that part of the spec got deleted when the CM system went down last week. I could have asked you, but you were downstairs getting another latte.
Plus, it's really quick and easy to find out empirically; quicker than looking it up, quicker than asking you, even if you were here. There's this tool called PerlClip that allows me to create strings that look like this
*3*5*7*9*12*15*18*21*24*27*30*33*36*39*42*45*48*51*54*57*60*...
As you'll notice, the string itself tells you about its own length. The number to the left of each asterisk tells you the offset position of that asterisk in the string. (You can use whatever character you like for a delimiter, including letters and numbers, so that you can test fields that filter unwanted characters.)
It takes a handful of keystrokes to generate a string of tremendous length, millions of characters. The tool automatically copies it to the Windows clipboard, whereupon you can paste it into an input field. Right away, you get to see the apparent limit of the field; find an asterisk, and you can figure out in a moment exactly how many characters it accepts. It makes it easy to produce all kinds of strings using Perl syntax, which saves you having to write a line of Perl script to do it and another few lines to get it into the clipboard. In fact, you can give PerlClip to a less-experienced tester that doesn't know Perl syntax at all (yet), show them a few examples and the online help, and they can get plenty of bang for the buck. They get to learn something about Perl, too. This little tool is like a keychain version of a Swiss Army knife for data generation. It's dead handy for analyzing input constraints. It allows you to create all kinds of cool patterns, or data that describes itself, and you can store the output wherever you can paste from the clipboard. Oh, and it's free.
You can get a copy of PerlCliphere, by the way. It was written byJames BachandDanny Faught. The idea started with a Perl one-liner by Danny, and they build on each other's ideas for it. I don't think it took them very long to write it. Once you've had the idea, it's a pretty trivial program to implement. But still, kind of a cool idea, don't you think?
So anyway, I created a string a million characters long, and I pasted it into the chat window input field. I saw that the input field apparently accepted 32768 characters before it truncated the rest of the input. So I guess your limit is 32768 characters.
Then I pressed "Send", and the text appeared in the output field. Well, not all of it. I saw the first 29996 characters, and then two periods, and then nothing else. The rest of the text had vanished.
That's weird. It doesn't seem like a big deal, does it? Yet there's this thing calledrepresentativeness bias. It's a critical thinking error, the phenomenon that causes us to believe that a big problem always looks big from every angle, and that an observation of a problem with little manifestations always has little consequences.
Our biases are influenced by our world views. For example, last week when that tester found that crash in that critical routine, everyone else panicked, but you realized that it was only a one-byte fix and we were back in business within a few minutes. It also goes the other way, though: something that looks trivial or harmless can have dire and shocking consequences, made all the more risky because of the trivial nature of the symptom. If we think symptoms and problems and fixes are all alike in terms of significance, when we see a trivialsymptom, no one bothers to investigate theproblem.It's only a little rounding error, and it only happens on one transaction in ten, and it only costs half a cent at most.When that rounding error is multiplied over hundreds of transactions a minute, tens of thousands an hour... well you get the point.
I'm well aware that, as a test, this is a toy. It's like a security check where you rattle the doorknob. It's like testing a car by kicking the tires. And the result that I'm seeing is like the doorknob falling off, or the door opening, or a tire suddenly hissing. For a tester, this is a mere bagatelle. It's atrivialtest. Yet when a trivial test reveals something that we can't explain immediately, it might be good idea to seek an explanation.
A few things occurred to me as possibilities.
For any one of the cases above, since it's so easy to test and check for these things, I would think that if you or anyone else knew about this problem, your sense of professionalism and craftsmanship would tell you to do some testing, write some checks, and fix it. After all, as Uncle Bob Martin said, you guys don't want us to findanybugs, right?
Any of the above explanations could be in play, many of them simultaneously. No matter what, though, all your unit tests could pass, and you'd never know about the problem until we took out all the mocks and hooked everything up in the real system. Or deployed into the field. (Actually, by now they're notunit tests; they're just unit checks, since it's a while since this part of the code was last looked at and we've been seeing green bars for the last few months.)
But it's not my place to say that. All that stuff is up to you. I don't tell you how to do your work; I tell you what I observe, in this case entirely from the outside. Plus it's only one test. I'll have to do a few more tests to find out if there's a more general problem. Maybe this is an aberration.
Now, I know you're fond of saying, "No user would ever do that." I think what you really mean is no userthat you've thought of, andthat you like, would do thaton purpose. But it might be a thought to consider users that you haven't thought of, however unlikely they and their task might be to you. It could be a good idea to think of users that neither one of us like, such as hackers or identity thieves. It could also be important to think of users that youdolike who would do thingsby accident. People make mistakes all the time. In fact, by accident, I pasted the text of this message into another program, just a second ago.
So far, I've only talked about the source of the problem and the trigger for it. I haven't talked much about possible consequences, or risks. Let's consider some of those.
NASA calls this last problem "the normalization of deviance". In fact, this tiny little inconsistency reminds me of the Challenger problem. Remember that? There were these O-rings that were supposed to keep two chambers of highly-pressurized gases separate from each other. It turns out that on seven of the shuttle flights that preceded the Challenger, these O-rings burned through a bit and some gases leaked (they called this "erosion" and "blow-by". Various managers managed to convince themselves that it wasn't a problem, because it only happened on about a third of the flights, and the rings, at most, only burned a third of the way through. Because these "little" problems didn't result in catastrophe the first seven times, NASA managers used this as evidence for safety. Every successful flight that had the problem was taken as reassurance that NASA could get away with it. In that sense, it was like Nassim Nicholas Taleb's turkey, who increases his belief in the benevolence of the farmer every day... until some time in the week before Thanksgiving.
Richard Feynman, in hisAppendix to the Rogers Commission Report on the Space Shuttle Challenger Accident, nailed the issue:
The phenomenon of accepting for flight, seals that had shown erosion and blow-by in previous flights, is very clear. The Challenger flight is an excellent example. There are several references to flights that had gone before. The acceptance and success of these flights is taken as evidence of safety. But erosion and blow-by are not what the design expected. They are warnings that something is wrong. The equipment is not operating as expected, and therefore there is a danger that it can operate with even wider deviations in this unexpected and not thoroughly understood way. The fact that this danger did not lead to a catastrophe before is no guarantee that it will not the next time, unless it is completely understood.When playing Russian roulette the fact that the first shot got off safely is little comfort for the next.
That's the problem with any evidence of any bug, at first observation; we only know about asymptom, not thecause, and not theconsequences. When the system is in an unpredicted state, it's in anunpredictablestate.
Software is wonderfully deterministic, in that it does exactly what we tell it to do. But, as you know, there's sometimes a big difference between what we tell it to do and what wemeantto tell it to do. When software does what we tell it to do instead of what we meant, we find ourselves off the map that we drew for ourselves. And once we're off the map, we don't know where we are.
According to Wikipedia,Feynman's investigations also revealed that there had been many serious doubts raised about the O-ring seals by engineers at Morton Thiokol, which made the solid fuel boosters, but communication failures had led to their concerns being ignored by NASA management. He found similar failures in procedure in many other areas at NASA, but singled out its software development for praise due to its rigorous and highly effective quality control procedures - then under threat from NASA management, which wished to reduce testing to save money given that the tests had always been passed.
At NASA, back then, the software people realized that just because their checks were passing, it didn't mean that they should relax their diligence. They realized that what really reduced risk on the project was appropriate testing, lots of tests, and paying attention to seemingly inconsequential failures.
I know we're not sending people to the moon here. Even though we don't know the consequences of this inconsistency, it's hard to conceive of anyone dying because of it. So let's make it clear: I'm not saying that the sky is falling, and I'm not making a value judgment as to whether we should fix it. That stuff is for you and the project managers to decide upon. It's simply my role to observe it and report it.
I think it might be important, though, for us to understandwhythe problem is there in the first place. That's because I don't know whether the problem that I'm seeing is a big deal. And the thing is, until you've looked at the code,neither do you.
As always, it's your call. And as usual, I'm happy to assist you in running whatever tests you'd like me to run on your behalf. I'll also poke around and see if I can find any other surprises.
Your friend,
The Tester
P.S. Ididrun a second test. This time, I used PerlClip to craft a string of 100000 instances of :). That pair of characters, in normal circumstances, results in a smiley-face emoticon. It seemed as though the input field accepted the characters literally, and then converted them to the graphical smiley face. It took a long, long time for the input field to render this. I thought that my chat window had crashed, but it hadn't. Eventually it finished processing, and displayed what it had parsed from this odd input. I didn't see 32768 smileys, nor 29996, nor 16384, nor 14998. I saw exactly two dots. Weird, huh?
Read more:http://www.developsense.com/2009/09/letter-to-programmer.html#ixzz0SXqgDOP3
发表评论
-
为什么中国出不了扎克伯格
2010-03-12 08:01 1144他们已基本失去成为互 ... -
不会编程的程序员
2010-03-06 12:39 950我想这让人难以置信, ... -
让代码更美:10大编程字体
2010-01-21 13:36 1756日复一日的编写代码, ... -
Everything you need to know about Android 2.0
2009-11-07 21:03 1110Android 2.0 (formerly codenamed ... -
Linux: still better for coding
2009-11-05 08:01 862Something like one year ago I s ... -
Top 10 Programming Fonts
2009-11-01 09:20 1616I’m a typeface geek, and when i ... -
Speed Up and Back Up Your Rooted Android Phone
2009-10-31 15:16 1113If you've rooted your Android p ... -
Five Favorite Web Applications of Designers
2009-10-18 08:36 957Webapps –compared to their des ... -
The Best Programming Language for a Lean Startup
2009-10-18 08:31 1224Think arguments between religio ... -
5 Excuses Bad Programmers Make
2009-10-16 16:51 732It’s a common problem, there’s ... -
How to Create a Twitter Feed on Your Web Site
2009-10-08 08:50 1037Twitter has quickly become one ... -
How NOT to test that mysqld is alive
2009-10-06 09:35 907I had a call from a new custo ... -
CodeThatDocumentsItselfSoWellItDoesNotNeedComments
2009-10-06 07:56 739“When I first met the lead de ... -
The Evolution of a Programmer
2009-10-06 07:54 727High School/Jr.High 10 PRI ... -
将Web入侵消灭在萌芽之中——预防SQL注入
2009-10-05 08:38 1077国家互联网应急中心CN-S ... -
阿里要走102年 阿里的工程师能走多远?
2009-10-04 08:46 701很高兴看到阿里云的 ... -
支持云应用程序服务的PHP API
2009-10-03 08:14 1044自称“PHP公司”的Zend Technologies发起 ... -
Java is dead, but you'll learn to love it
2009-10-02 08:32 1099A favorite hobby-hors ... -
程序员需要知道的97件事
2009-10-02 08:24 1462继架构师需要知道的97件事(参看InfoQ此前的报道)之后,该 ... -
Google Wave: There Will Be Backlash
2009-10-01 08:11 765Have you gotten your Google W ...
相关推荐
- **Objective:** Develop a simple number guessing game where the computer selects a random number and the user tries to guess it. - **Key Concepts:** - Random number generation using the `random` ...
The assignment is to write a parallel map-reduce program for the above task using either octo.py, or mincemeat.py, each of which is a lightweight map-reduce implementation written in Python. ...
浙江大学2025年DeepSeek的本地化部署与AI通识教育之未来57页.pdf
内容概要:本文探讨了基于主从博弈理论的社区综合能源系统分布式协同优化运行策略。随着能源市场的变化,传统的集中优化方法已无法满足多主体间的复杂交互需求。文中利用Matlab、YALMIP和CPLEX平台,构建了一主多从的分布式协同优化模型,其中综合能源销售商作为领导者,新能源冷热电联供运营商和负荷聚合商作为跟随者。通过遗传算法和二次规划相结合的方式解决了Stackelberg均衡的唯一性和求解问题,并通过多个算例验证了该策略的有效性。结果显示,该策略显著提高了供能侧的收益和用能侧的消费者剩余。 适合人群:对能源系统优化、博弈论及其应用感兴趣的科研人员和技术开发者。 使用场景及目标:适用于研究和实施社区综合能源系统的分布式协同优化,旨在提高能源系统的经济效益和社会效益。 其他说明:文中提供了详细的模型构建步骤、代码示例和实验结果,有助于理解和复现实验过程。此外,讨论了光伏渗透率对博弈策略的影响,强调了收敛条件设置的重要性,并分享了一些实用的技术技巧。
nexus-3.77版本,适用于windows环境下本地仓库环境搭建,支持jdk17以上,支持https访问配置
该MATLAB Simulink模型提供了与太阳能集成的储能系统(ESS)的综合仿真。该模型是为旨在探索、研究或原型可再生能源解决方案的用户设计的。它包括模拟太阳能发电、电池存储和并网或独立系统的能源管理的组件。太阳能电池板的输入电压可以根据用户而改变 特征 太阳能发电:模拟具有不同太阳辐照度的光伏(PV)系统。 两个储能系统的集成:引入两个动态储能系统来储存能量,它们是锂离子电池和超级电容电池。超级电容器电池被引入来处理由可再生能源引起的波动,锂离子电池被用于支持电网 电池储能:为锂离子电池和超级电容电池实施高效的充电和放电机制 能量管理系统(EMS):平衡光伏系统、电池和负载之间的能量流动。 负载动力学:支持可变负载条件,以测试系统的健壮性。 用户友好的设计:模块化和可定制的模型架构,易于适应。 应用程序 可再生能源的电网整合。 离网储能系统的开发。 理解ESS和太阳能概念的教育目的。 可再生能源技术的研究和开发。
内容概要:本文详细介绍了利用COMSOL Multiphysics和Avizo软件进行数字岩心建模和流固耦合模拟的方法和技术细节。首先阐述了数字岩心的概念及其重要性,接着讲解了如何在COMSOL中构建流固耦合模型,包括定义物理场、设置参数以及生成高质量网格。随后讨论了Avizo在处理CT扫描图像方面的优势,展示了如何通过Python脚本实现图像分割和三维模型生成,并将其与COMSOL结合用于更精准的物理场模拟。最后强调了这种联合仿真技术在地质工程和能源勘探中的广泛应用前景。 适合人群:从事材料科学研究、地质工程、石油天然气勘探等相关领域的研究人员和技术人员。 使用场景及目标:适用于需要深入了解岩石内部流体流动特性和传输性质的研究项目,旨在提升对复杂地质结构的认识并优化资源开采过程。 其他说明:文中提供了大量实用的技术细节和代码片段,帮助读者更好地理解和实施具体的仿真步骤。同时提醒了一些常见的陷阱和解决方案,有助于提高工作效率和准确性。
基于51单片机protues仿真的水泵效率温差法测量系统(仿真图、源代码、AD原理图) 水泵效率温差法测量系统 主要是用两个E型热电偶测量水泵进出口温差,温差传给单片机(有水泵效率的经验公式)用单片机程序算出效率并显示出来 主要硬件是两个E型热电偶,好像是分别接MAX31855芯片通信到AT89C52,然后通过单片机编程算出效率再显示效率 设置效率的范围 要是超出范围就报警 1、E型热电偶测量水泵进出口温差; 2、MAX31855芯片温度采集; 3、按键设置温度参数; 4、LCD液晶屏显示相关参数和信息; 5、计算显示效率;
内容概要:本文详细介绍了基于时间卷积神经网络(TCN)的多分类预测方法,旨在提高时间序列数据分类的准确性。首先简述了TCN的基本原理及其相对于传统循环神经网络(如LSTM、GRU)的独特优势,特别是在并行计算和长期依赖处理方面。接着,文章展示了从Excel中读取数据的具体步骤,并进行了必要的数据预处理,如特征缩放和标签编码。随后,构建了一个基于Keras框架的TCN模型,详细解释了每一层的作用以及参数设置的理由。为了确保模型的有效性和泛化能力,文中还讨论了数据集的划分方式、训练技巧(如滑窗划分)、模型评估指标(如混淆矩阵)以及最终的模型部署方法。此外,作者分享了一些实用的经验和技巧,如避免梯度爆炸的方法、调整学习率策略等。 适合人群:对时间序列数据分析感兴趣的初学者和有一定经验的数据科学家,尤其是希望深入了解TCN模型及其应用的人群。 使用场景及目标:本方案适用于各种涉及时间序列分类的任务,如金融市场趋势预测、工业设备故障检测等。目标是在保证高准确度的同时,提供灵活易用的实现方式,使用户能够快速上手并在自己的项目中应用。 其他说明:文中提供的代码片段可以直接运行或稍作修改后应用于不同的数据集。对于想要进一步优化模型性能的研究者来说,文中提到的一些高级技巧(如滑窗划分、自定义损失函数等)也非常有价值。
内容概要:本文介绍了一种针对ESP32设备的改进型OTA(Over-The-Air)固件升级方案。该方案不仅解决了官方OTA示例中存在的问题,如手动模式灵活性差、自动模式易变砖以及错误处理不足,还增加了自动回滚机制、Websocket传输协议、双模切换等功能。文中详细展示了如何通过SPIFFS存储固件MD5值进行校验,确保固件完整性;利用Websocket提高传输效率并实现断点续传;并通过NVS闪存保存启动计数,增强系统的容错能力。此外,作者分享了实际应用案例,如智能家居项目的批量升级和工业设备的稳定性测试。 适合人群:对ESP32有初步了解并希望深入研究OTA升级机制的开发者和技术爱好者。 使用场景及目标:适用于需要频繁更新固件的物联网设备,特别是那些部署于难以物理接触的位置或者对可靠性要求较高的场合。主要目标是提供一种更加稳定、高效的OTA升级方法,减少因升级失败而导致设备无法使用的风险。 其他说明:文中提供了完整的代码片段和配置指导,帮助读者快速理解和应用这一方案。同时强调了在不同网络环境下的适应性和鲁棒性,确保即使在网络不稳定的情况下也能顺利完成升级。
内容概要:本文详细探讨了光子晶体超表面中动量空间动态调节BICs(连续域中的束缚态)的技术和方法。首先介绍了动量空间和BICs的基础概念,解释了BICs作为一种特殊光学模式的独特性质。随后讨论了通过改变几何参数或引入外部激励来动态调节BICs的具体方法,并展示了如何利用COMSOL软件进行模拟。文中提供了具体的COMSOL建模步骤和脚本示例,包括几何模型的创建、材料属性的设置、物理场的选择以及参数化的扫描设置。此外,还分享了一些实际操作中的经验和技巧,如如何处理COMSOL的缓存问题、优化网格划分、监测Q值变化等。最后,强调了这种结合理论与模拟的研究方法在新型光学器件设计和光与物质相互作用新机制探索中的重要性和有效性。 适合人群:从事光子学、光学工程、物理学等相关领域的研究人员和技术人员,尤其是对光子晶体超表面和BICs感兴趣的学者。 使用场景及目标:适用于希望通过理论结合模拟深入理解光子晶体中超表面BICs特性的科研工作者。主要目标是掌握动量空间中动态调节BICs的方法,为设计高性能光学器件提供理论支持和技术手段。 其他说明:文章不仅提供了详细的理论推导和公式解析,还包括了大量的COMSOL建模实例和代码片段,便于读者动手实践。同时,文中提到了许多实际操作中的注意事项和经验教训,有助于提高模拟效率和准确性。
如何综合性测试一款电源芯片?ASP3605芯片测试报告
内容概要:本文介绍了SVM-Adaboost算法及其在MATLAB平台上的实现方法,重点探讨了该算法在多种故障识别场景中的应用。SVM-Adaboost结合了支持向量机的强大分类能力与Adaboost的迭代增强特性,适用于多分类问题。文中详细讲解了轴承故障识别、变压器油气故障识别、输电线路故障区域识别和绝缘子、配网故障识别的具体实现步骤,包括数据读取、预处理、模型训练、预测验证等环节。此外,还提供了具体的MATLAB代码示例,展示了如何通过调整样本权重、选择合适的核函数等方式优化模型性能。 适合人群:具有一定MATLAB编程基础和技术背景的研究人员、工程师,特别是从事机械故障诊断、电力系统维护等相关工作的专业人员。 使用场景及目标:①快速准确地识别机械设备如轴承、变压器等的故障类型;②提高电力系统输电线路故障区域的定位精度;③增强绝缘子、配网故障识别的准确性;④通过优化模型参数,提升故障识别的效率和可靠性。 其他说明:文章强调了SVM-Adaboost算法在处理小样本数据方面的优势,并指出了一些常见的注意事项,如样本类别均衡、核函数选择、Adaboost迭代次数等。同时,提供了实用的代码片段和技巧,帮助读者更好地理解和应用该算法。
内容概要:本文详细介绍了基于S7-200 Smart PLC的速度与频率同步控制程序,主要用于卷板材生产线和造纸设备。程序通过设置速度同步地址vw10作为基准,利用频率调整系数factor[i]实现1-15回路的频率同步。此外,还支持主从单机微调功能,确保各回路能够精确同步。文中提供了具体的代码示例,解释了如何通过简单逻辑实现多机同步,并强调了微调和异常检测的重要性。对于16-30回路,考虑到设备布局和负载差异,提出了相应的优化建议,如地址映射调整和滤波算法的应用。 适合人群:从事自动化控制系统开发的技术人员,尤其是熟悉PLC编程和变频器应用的专业人士。 使用场景及目标:①帮助技术人员理解和掌握S7-200 Smart PLC在卷板材生产线和造纸设备中的速度与频率同步控制方法;②提供实用的代码示例和技术细节,便于快速部署和调试;③提高生产线的稳定性和效率,降低故障发生率。 其他说明:本文不仅涵盖了基本的同步控制逻辑,还包括了许多实际应用中的经验和技巧,如微调处理、异常检测和滤波算法等,有助于解决实际工程中的常见问题。
windows系统 的右键菜单太丑有没有, 替换自定义的菜单要是应用不到全局,你就可以来看看, 还写了命令绑定, mvvm模式的.示例代码
学习
内容概要:本文介绍了基于梯度下降的改进自适应短时傅里叶变换(STFT)方法,并展示了其在Jupyter Notebook中的具体实现。传统的STFT由于固定窗口长度,在处理非平稳信号时存在局限性。改进的方法通过梯度下降策略自适应调整窗口参数,从而提高时频分辨率。文中详细解释了算法的工作原理,包括信号生成、窗函数设计、损失函数选择等方面,并给出了具体的Python代码示例。此外,文章还讨论了该方法在多个领域的广泛应用,如金融时间序列、地震信号、机械振动信号、声发射信号、电压电流信号、语音信号、声信号和生理信号等。 适合人群:从事信号处理、数据分析及相关领域研究的专业人士,尤其是对时频分析感兴趣的科研人员和技术开发者。 使用场景及目标:适用于需要处理非平稳信号的研究和应用场景,旨在提高信号处理的精度和效率。具体目标包括但不限于:改善金融市场的预测能力、提升地震监测系统的准确性、增强机械设备故障诊断的效果、优化语音识别和合成的质量等。 其他说明:该方法不仅限于特定类型的信号,而是可以通过调整参数灵活应用于不同的信号类型。文中提供的代码可以在Jupyter Notebook环境中直接运行,便于实验和验证。
蓝桥杯python资源。蓝桥杯python官方省赛模拟题源代码。
使用遗传算法的示例问题和解决方案 给定一个目标字符串,目标是从相同长度的随机字符串开始生成目标字符串。在下面的实施中,进行了以下类比 - 字符 A-Z、a-z、0-9 和其他特殊符号被视为基因 由这些字符生成的字符串被视为 chromosome/solution/Individual 适应度分数是特定索引处与目标字符串中的字符不同的字符数。因此,体能值较低的个体被赋予更多的优先权。 // Number of individuals in each generation