• Josh (unregistered)

    Looks like source code for the original zune...

  • Jimmy (unregistered)

    I absolutely love the "dayinmonth_function" definition. Find the day of the year, keep subtracting the length of the months from it, until the number is <= 31..

    There are times when

    return ((struct_tm *)localtime(time(NULL)))->mday;

    just doesn't cover all your needs.

  • Jimmy (unregistered) in reply to AshG
    AshG:
    Using macros to implement functions is wtf.

    Macros are fast! Mostly because everything written in a preprocessor macro is translated into inline code. How you use them is of course up for debate.

    It may just be years of experience, but stuffing recurring, trivial, space consuming, hard to read code like :

    increment value x by y unless z is defined, in which case you set x to CONSTANT_K - j

    which turns out like

      if(z)
        x = CONSTANT_K - j;
      else
        x+=y;
    

    That's easy to read, but if it occurs 50 times in your code, i'd rather see this:

    #define NEXTVAL(x,y,j,z) ( z ? CONSTANT_K - j : x + y)
    .
    .
    .
    x = NEXTVAL(x,y,j,z);
    
  • Moderately Impressed Systems Engineer (unregistered) in reply to Herby
    Herby:
    If you really want the definitive response to the "is 2000 a leap year" question, you ought to quote the original Latin that was in the Pope's decree. It actually mentions the year "MM" by name (as being a leap year).

    The year 2000 was specifically identified as a Leap Year by Pope Gregory XIII in his Papal Bull of February 24, 1582, Inter Gravissimas:

    quote:

    1. Deinde, ne in posterum a XII kalendas aprilis aequinoctium recedat, statuimus bissextum quarto quoque anno (uti mos est) continuari debere, praeterquam in centesimis annis; qui, quamvis bissextiles antea semper fuerint, qualem etiam esse volumus annum MDC, post eum tamen qui deinceps consequentur centesimi non omnes bissextiles sint, sed in quadringentis quibusque annis primi quique tres centesimi sine bissexto transigantur, quartus vero quisque centesimus bissextilis sit, ita ut annus MDCC, MDCCC, MDCCCC bissextiles non sint. Anno vero MM, more consueto dies bissextus intercaletur, februario dies XXIX continente, idemque ordo intermittendi intercalandique bissextum diem in quadringentis quibusque annis perpetuo conservetur.

    unquote:

    This may be the clearest requirement specification I've ever seen from a customer, even if it was written 450 years ago in a dead language. I am impressed and a bit envious. (Also, disappointed that we in the development community can still screw up the implementation.)

    CAPTCHA: "mara". Which is either Hebrew for "bitter" (the life of a requirements analyst), a Scandinavian folkloric wraith which causes nightmares (like most customers), or a large mammal related to a guinea pig (which is how our developers feel).

  • jmucchiello (unregistered) in reply to snoofle
    snoofle:
    *musical interlude* Does anybody really know what time it is?
    Ah, yes, the "I'm a complete a--hole" song. Some asks me what time is it and what do I do? I get philosophical about it. Does anybody really know what time it is? WTF. Either tell me the time or tell me you don't know but don't ask me something totally unrelated.
  • The Solution is Obvious (unregistered)

    Actually it's quite easy to fix; the solution's even in the damn code; just pass in Feblength which should be determined by something like

    IF (Year mod 4) = 0 Then //I'm substituting mod for whatever your desired modulus or "remainder" operator is. {FEBLENGTH = 29} Else {FEBLENGTH = 28}

    Or did the original programmer miss that in highschool?

    Now that said I'm sure there's a less messy way to implement that but, um, yeah.

    Also; please don't shoot me; I've been doing IT work for the last 3 years instead of programming like I was taught in college.

  • Hoodaticus (unregistered) in reply to The Solution is Obvious
    The Solution is Obvious:
    Actually it's quite easy to fix; the solution's even in the damn code; just pass in Feblength which should be determined by something like

    IF (Year mod 4) = 0 Then //I'm substituting mod for whatever your desired modulus or "remainder" operator is. {FEBLENGTH = 29} Else {FEBLENGTH = 28}

    Or did the original programmer miss that in highschool?

    Now that said I'm sure there's a less messy way to implement that but, um, yeah.

    Also; please don't shoot me; I've been doing IT work for the last 3 years instead of programming like I was taught in college.

    I won't shoot if you promise not to ever implement any version of that algorithim, because the leap rule is much more arcane than that. It's on a 4, 100, and 400 year cycle.

    bLeap = Not (iYear Mod 400) Or ((iYear Mod 100) And Not (iYear Mod 4))

  • toweri (unregistered) in reply to Jimmy
    Jimmy:
    It may just be years of experience, but stuffing recurring, trivial, space consuming, hard to read code like :
    increment value x by y unless z is defined, in which case you set x to CONSTANT_K - j
    which turns out like
      if(z)
        x = CONSTANT_K - j;
      else
        x+=y;
    

    That's easy to read, but if it occurs 50 times in your code, i'd rather see this:

    #define NEXTVAL(x,y,j,z) ( z ? CONSTANT_K - j : x + y)
    .
    .
    .
    x = NEXTVAL(x,y,j,z);
    

    ...and then the next guy taking over your code for some reason needs to call x = NEXTVAL(x, y, j+1, z); and will get a nice lesson in using a debugger. Unless he's been burned by this before and before using a macro checks that all parameters are really protected as they should be.

  • epso (unregistered) in reply to Man of Steel
    Man of Steel:
    Bobble:
    Protip: You don't have to wait until a Feb 29th to fix this bug.
    Managertip: The return on investment of fixing the bug now is zero. So, yes, you do have to wait. Hey, with any luck we'll be bankrupt before then and collecting our fat bailout bonuses.
    Lawyertip: Ban the use of program for timeframes spanning Feb 29th in EULA to avoid fixing costs altogether.
  • Theep Dinker (unregistered) in reply to Mr B

    T

    Mr B:
    And hopefully, by the time the next February 29 rolls around, someone else will be there to fix it.

    Yes, yet again, complain about something, do NOTHING about it, and leave it to someone else. Which is exactly why code like this exists.

    Which is exactly why a site such as this exists :)

  • enpien (unregistered)

    cialis cause hiccups buy generic cialis

  • enpien (unregistered)
    Comment held for moderation.
  • enpien (unregistered)

    cialis poveikis cialis professional cheap

  • enpien (unregistered)
    Comment held for moderation.
  • enpiFah (unregistered)
    Comment held for moderation.
  • enpiFah (unregistered)
    Comment held for moderation.
  • enpien (unregistered)
    Comment held for moderation.

Leave a comment on “A Waste of Time”

Log In or post as a guest

Replying to comment #:

« Return to Article