"I'm a senior developer in a department developing, among other things, an Adobe Flex web GUI for the configuration of our products," writes Lucy. "Having worked on systems in the past which could require production fixes at 2:00 AM if something went wrong, I am a true believer in robust software (which allows you to sleep through the night). Fortunately, my current employment doesn't require that lovely on-call dedication, but it does leave me as the odd man out when trying to argue designing and implementing robust code versus time-to-ship with my team mates and manager."
Lucy continues, "I was recently addressing a reported bug when I discovered some code that finally made me realize why my methodology for robust error-handling was not important. One of my fellow developers had found a much quicker and easier method of error-handling: the shenanigans handler. What better way to describe this methodology than a quick code snippet."
override protected function commitChange():void { super.commitChange(); if ( this._dataChanged && this._data ) { if ( this._data.type ) { switch ( this._data.accountType) { case "private": this.username = this._data.username; this.password = this._data.password; this.account = AccountType.private; break; case "shared": this.username = this._data.username; this.password = this._data.password; this.account = AccountType.shared; break; default: //shenanigans break; } } else { //shenanigans } } else { //shenanigans } }
Lucy adds, "The elegance is astounding. All possible error conditions are handled with the simple //shenanigans statement. I only wish such methods had been available to me much sooner. I have not yet discovered how this error handler actually works since to my simple mind, it appears to only be a comment, but hopefully, one day I will gain that understanding... or find another job."