Don’t Nail Your Program into the Upright Position

Don’t Nail Your Program into the Upright Position

Verity Stob

i ONCE WROTE A SPOOF C++ qUiz, in which I satirically suggested the fol- lowing strategy for exception handling:

By dint of plentiful try…catch constructs throughout our codebase, we are sometimes able to prevent our applications from aborting. We think of the resul- tant state as “nailing the corpse in the upright position.”

Despite my levity, I was actually summarizing a lesson I received at the knee of Dame Bitter Experience herself.

It was a base application class in our own, homemade C++ library. It had suf- fered the pokings of many programmers’ fingers over the years: nobody’s hands were clean. It contained code to deal with all escaped exceptions from every- thing else. Taking our lead from Yossarian in Catch-22, we decided, or rather felt (decided implies more thought than went into the construction of this monster) that an instance of this class should live forever or die in the attempt.

To this end, we intertwined multiple exception handlers. We mixed in Windows’ structured exception handling with the native kind (remember __try…__except in C++? Me, neither). When things threw unexpectedly, we tried calling them again, pressing the parameters harder. Looking back, I like to think that when writing an inner try…catch handler within the catch clause of another, some sort of awareness crept over me that I might have accidentally taken a slip road from the motorway of good practice into the aromatic but insalubrious lane of lunacy. However, this is probably retrospective wisdom.

??56 97 Things Every Programmer Should Know

?

???????????????Needless to say, whenever something went wrong in applications based on this class, they vanished like Mafia victims at the dockside, leaving behind no useful trail of bubbles to indicate what the hell happened, notwithstanding the dump routines that were supposedly called to record the disaster. Eventually—a long eventually—we took stock of what we had done, and experienced shame. We replaced the whole mess with a minimal and robust reporting mechanism. But this was many crashes down the line.

I wouldn’t bother you with this—for surely nobody else could ever be as stupid as we were—but for an online argument I had recently with a bloke whose academic job title declared he should know better. We were discussing Java code in a remote transaction. If the code failed, he argued, it should catch and block the exception in situ. (“And then do what with it?” I asked. “Cook it for supper?”)

He quoted the UI designers’ rule: NEVER LET THE USER SEE AN EXCEP- TION REPORT, rather as though this settled the matter, what with it being in caps and everything. I wonder if he was responsible for the code in one of those blue-screened ATMs whose photos decorate the feebler blogs, and had been permanently traumatized.

Anyway, if you should meet him, nod and smile and take no notice, as you sidle toward the door.

时间: 2024-08-02 09:23:15

Don’t Nail Your Program into the Upright Position的相关文章

ARTS Week 12

Jan 13, 2020 ~ Jan 19, 2020 Algorithm Problem 112. Path Sum (路径总和) 题目链接 题目描述:给定一棵二叉树和一个值 sum ,检查二叉树是否存在根到叶子路径之和等与 sum 的路径,若存在,则返回 true,反之返回 false.例如,sum = 22,二叉树如下: 5 / 4 8 / / 11 13 4 / \ 7 2 1 返回结果 true,因为 5->4->11->2 思路为:树的遍历要使用递归,sum同时要保持更新,比

监控视频相关数据集

BOSS dataset Website: Datasets are available here. Dataset: The BOSS project aims at developing an innovative and bandwidth efficient communication system to transmit large data rate communications between public transport vehicles and the wayside. I

Find the Smallest K Elements in an Array

Given one point P0 on a 2-dimension space. There are n other points on the same space. Try to find K points which are most closed to P0. hint: Part of Quick Sort. Just sort the useful part of the array. 1 public class findKPoints { 2 class Point { 3

OpenGL核心技术之延迟着色法

笔者介绍:姜雪伟,IT公司技术合伙人,IT高级讲师,CSDN社区专家,特邀编辑,畅销书作者,国家专利发明人;已出版书籍:<手把手教你架构3D游戏引擎>电子工业出版社和<Unity3D实战核心技术详解>电子工业出版社等. CSDN视频网址:http://edu.csdn.net/lecturer/144 如果读者使用过Unity3D引擎,在相机的组件中有关于延迟着色的控制开关,读者自己可以尝试体验一下效果.我们现在一直使用的光照方式叫做正向渲染(Forward Rendering)或

POJ 3358- Period of an Infinite Binary Expansion(欧拉函数+欧拉定理)

Period of an Infinite Binary Expansion Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3358 Appoint description:  System Crawler  (2015-04-08) Description Let {x} = 0.a1a2a3... be the binary rep

WebGL之点上添加图片(using texture on point)

var VSHADER_SOURCE =[ "attribute vec4 a_Position;", "uniform mat4 u_ProjMatrix;", "uniform float u_PointSize;", "void main() {", " gl_PointSize = u_PointSize;", " gl_Position = u_ProjMatrix * a_Positi

《Deferred Shading》

原文地址:https://learnopengl-cn.github.io/05%20Advanced%20Lighting/08%20Deferred%20Shading/ 原文 Deferred Shading 作者 JoeyDeVries 翻译 Meow J 校对 KenLee 我们现在一直使用的光照方式叫做正向渲染(Forward Rendering)或者正向着色法(Forward Shading),它是我们渲染物体的一种非常直接的方式,在场景中我们根据所有光源照亮一个物体,之后再渲染下

WebGL之点精灵的旋转(Rotation Sprite)

var VSHADER_SOURCE =[ "attribute vec4 a_Position;", "uniform mat4 u_ProjMatrix;", "uniform float u_PointSize;", "void main() {", " gl_PointSize = u_PointSize;", " gl_Position = u_ProjMatrix * a_Positi

Important Programming Concepts (Even on Embedded Systems) Part V: State Machines

Earlier articles in this series: Part I: Idempotence Part II: Immutability Part III: Volatility Part IV: Singletons Oh, hell, this article just had to be about state machines, didn’t it? State machines! Those damned little circles and arrows and q’s.