foreach

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 15 17:38:53 PDT 2014


On Sun, Jun 15, 2014 at 03:05:37AM -0400, Nick Sabalausky via Digitalmars-d wrote:
[...]
> True story: I once had to put up with a production codebase (the
> company's *flagship* product) that wasn't asm (it was VB6) and yet was
> filled with garbage like this:
> 
> if ...cond... then
>    ...statements...
>    goto somelabel
> end
> ...statements...
> somelabel:
> 
> Got posted on thedailywtf for that one.

I see code like that *all the time*. It's about the only sane way you
can write error-handling code in C:

	int func(some_type some_arg)
	{
		do_some_work();
		if (some_cond) {
			log_error();
			goto CLEANUP;
		}
		do_some_more_work();
		if (some_other_cond) {
			log_error();
			do_something_else();
			goto CLEANUP;
		}
		...
		return 0; /* success */
	CLEANUP:
		do_cleanup();
		return -1; /* failure */
	}


Also, just because something is a production codebase or flagship
product, says *nothing* about the quality of code it has. IME, most
"enterprise" code is really nasty, it only survives because it's
important enough that it got more attention from the devs so the most
obvious problems have been patched up. And nobody dares rewrite it
because customers have come to rely on its quirks (aka long-standing
bugs). But it's generally a nasty piece of work riddled with ugly hacks
and fragile bits that will come crashing down the moment you prod it a
little too hard.


T

-- 
Skill without imagination is craftsmanship and gives us many useful objects such as wickerwork picnic baskets.  Imagination without skill gives us modern art. -- Tom Stoppard


More information about the Digitalmars-d mailing list