Recent Representative Line

A single line of code from a large application that somehow manages to provide an almost endless insight into the pain that its maintainers face each day.

Dec 2011

JavaScript JSON Parsing

by in Representative Line on

No data interchange format is perfect. ASN.1 (Abstract Syntax Notation One) is probably the closest (it's by far the most flexible and comprehensive), but since no one's really heard of it, it may as well be Esperanto. Although XML has become the de-facto standard, JSON (JavaScript Object Notation) has been gaining favor – especially for simple operations on the web.

For example, a JSON response to an authorization check might look something like this.


Uppity

by in Representative Line on

"The project was done in C and it was clear the original contractor had no comprehension of function parameters," Aargle Zymurgy writes, "Imagine a source file with 20 functions in it, all modestly complex (between 10 and 40 lines) that only differed from each other by which global variable they operated on. Now repeat for dozens of other modules."

"But this was just the start of the global madness. For the user interface, various notions of up, down left and right were needed. In fact, those ideas were needed in dozens of contexts throughout the program. But what to do? You just have to innovate, of course! Thus the code had the following global variables."