A Function to Quit For was originally published on July 17, 2006


It's easy to understand how Mike Hartnagel got himself into the classic "should I quit after three days?" dilemma. Who would have guessed that a single bullet point on the job description -- "utilizing some Excel Interoperability" -- actually described the architecture of the system: a horrid amalgamation of Excel spreadsheets interacting with C# interacting with other spreadsheets. Who would have thought that all other bullet points -- from "multi-tiered architecture using remoting" to "automated/integrated build process" -- were actually features they'd like to have at some point in the distant future.

Who? A hardened cynic -- that's who. And that's exactly what Mike became after being handed his first programming assignment: create overloads for the following function so that developers don't need use zeros if they don't need all of the 600+ parameters ...

 

/* adds up all the column values for a specific row from an excel file.
 * 20050823 - BSR - v1.0 - Adds only columns a to z.
 * 20050909 - BSR - v2.0 - Added support for adding columns aa to zz.
 */
public long addUpAllExcelColumns(
  int a,  int b,  int c,  int d,  int e,  int f,  int g,  int h,  
  int i,  int j,  int k,  int l,  int m,  int n,  int o,  int p,  
  int q,  int r,  int s,  int t,  int u,  int v,  int w,  int x,  
  int y,  int z,
  
  int aa, int ab, int ac, int ad, int ae, int af, int ag, int ah, 
  int ai, int aj, int ak, int al, int am, int an, int ao, int ap, 
  int aq, int ar, int _as, int at, int au, int av, int aw, int ax, 
  int ay, int az,

  int ba, int bb, int bc, int bd, int be, int bf, int bg, int bh, 
  int bi, int bj, int bk, int bl, int bm, int bn, int bo, int bp,
  int bq, int br, int bs, int bt, int bu, int bv, int bw, int bx, 
  int by, int bz,
  
  int ca, int cb, int cc, int cd, int ce, int cf, int cg, int ch,
  int ci, int cj, int ck, int cl, int cm, int cn, int co, int cp,
  int cq, int cr, int cs, int ct, int cu, int cv, int cw, int cx,
  int cy, int cz,
  
  int da, int db, int dc, int dd, int de, int df, int dg, int dh,
  int di, int dj, int dk, int dl, int dm, int dn, int _do, int dp,
  int dq, int dr, int ds, int dt, int du, int dv, int dw, int dx,
  int dy, int dz,

  /* Snip 100 lines */
  
  int ya, int yb, int yc, int yd, int ye, int yf, int yg, int yh,
  int yi, int yj, int yk, int yl, int ym, int yn, int yo, int yp,
  int yq, int yr, int ys, int yt, int yu, int yv, int yw, int yx,
  int yy, int yz,

  int za, int zb, int zc, int zd, int ze, int zf, int zg, int zh,
  int zi, int zj, int zk, int zl, int zm, int zn, int zo, int zp,
  int zq, int zr, int zs, int zt, int zu, int zv, int zw, int zx,
  int zy, int zz)
{
    return 
      a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+
      aa+ab+ac+ad+ae+af+ag+ah+ai+aj+ak+al+am+an+ao+ap+aq+ar+_as+at+au+av+aw+ax+ay+az+
      ba+bb+bc+bd+be+bf+bg+bh+bi+bj+bk+bl+bm+bn+bo+bp+bq+br+bs+bt+bu+bv+bw+bx+by+bz+
      ca+cb+cc+cd+ce+cf+cg+ch+ci+cj+ck+cl+cm+cn+co+cp+cq+cr+cs+ct+cu+cv+cw+cx+cy+cz+
      da+db+dc+dd+de+df+dg+dh+di+dj+dk+dl+dm+dn+_do+dp+dq+dr+ds+dt+du+dv+dw+dx+dy+dz+
      /* Snip 20 lines */
      ya+yb+yc+yd+ye+yf+yg+yh+yi+yj+yk+yl+ym+yn+yo+yp+yq+yr+ys+yt+yu+yv+yw+yx+yy+yz+
      za+zb+zc+zd+ze+zf+zg+zh+zi+zj+zk+zl+zm+zn+zo+zp+zq+zr+zs+zt+zu+zv+zw+zx+zy+zz;
}
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!