foreach
Wyatt via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 16 11:37:56 PDT 2014
On Monday, 16 June 2014 at 17:52:29 UTC, H. S. Teoh via
Digitalmars-d wrote:
>
> I have seen 600+-line (and bigger) functions in "enterprise"
> production code. I don't recall seeing using goto's in such
> functions for flow control (other than error handling), but I
> may have missed them. :-P
Legacy maintenance here. Here's a common pattern in a similar
asinine monstrosity under my care:
if( (rc = allocate_struct_gymnast(CONSTANT1, CONSTANT2,
ptr_type, (gymnast *) flying_ptr) ) != 0 )
FAIL_AND_RETURN_MACRO(rc);
if(rc == 0 && stupid_comparison_1 == SOME_CONSTANT)
function_thematically_related(SOME_CONSTANT,
struct_gymnast->trapeze);
if(rc == 0 && stupid_comparison_2 == OTHER_CONSTANT)
function_thematically_related(OTHER_CONSTANT,
struct_gymnast->parallel_bar[0]);
...and so it goes. The best thing I can say about it is it
usually works, but reading it is annoyingly noisy.
> I've also seen functions called do_everything() and doit(),
> where parameters are passed via global variables (instead of,
> y'know, language built-in function parameters).
I've got this (yes, with K&R-style arguments):
static int formatit(ac,callback_scheduled)
If memory serves, this comes up in a non-recursive stack nineteen
frames deep.
> Or, on the flip
> side, functions with 10-15 parameters, each of which influences
> which subset of the others actually have any effect.
>
Tame. Gaze upon true horror:
#2 0x0809082c in stnz_sutrs (rec=0x461d550,
app_context_arg=0x461dfd0, attribute_set=0x0, answer_complete=1,
present_type=2, cgm=0, graphics=0, highlight_option=1,
records_requested=1, current_field=76, num_fields=88,
field=0x462a160, ans=0x0, database=0x45e0628 "REGISTRY",
esn_list=0x461dd98, issue_break=0x461d754, callback=0x806f82d
<display_next_answer>, callback_arg=0x461d668,
field_callback=0x8087bff <field_formatter>,
field_callback_arg=0x462adb8, callback_scheduled=0xfef92ac0, dg=0,
dp=5, line_length=100) at stnz_sutrs.c:399
Of course, most of those are passed directly from the parent frame
with no changes at all. :V
Enterprise code is probably worse than you think it is by nearly
every metric you can think of.
orz
-Wyatt
More information about the Digitalmars-d
mailing list