• Adam (unregistered) in reply to Josh
    Josh:
    C-Derb:
    I think my favorite part is potentially splitting the "Summary" string 8 times when one time would have been sufficient:
    if (line.Split(':')[1] == "New Year's Day" || line.Split(':')[1] == "Good Friday" || line.Split(':')[1] == "Easter Monday" || line.Split(':')[1] == "Early May Bank Holiday" || line.Split(':')[1] == "Spring Bank Holiday" || line.Split(':')[1] == "Christmas Day" || line.Split(':')[1] == "Boxing Day" || line.Split(':')[1].StartsWith("Summer Bank Holiday"))

    Seems like you're splitting hairs on this one.

    I see what you did there

  • Other developer dude (unregistered) in reply to Developer Dude

    Are you my coworker?

  • S (unregistered) in reply to Gill Bates
    Gill Bates:
    Don't you guys have some sort of code coloring?

    Yes. The appropriate colors are black and blue, with red for more terminal cases...

  • Mathlete (unregistered) in reply to Redsplinter

    random.shuffle(list(list_)) then. The original point that sorted(list_, key=lambda z:random.random()) is awful still stands.

  • Cow Orker (unregistered) in reply to QJo

    [quote user="QJo"][quote user="TheCPUWizard"] It makes you want to chew your own leg off to get away.[/quote]

    Reminds me of something my dad used to say "If you break your leg don't come running to me!"

  • (cs) in reply to Walky_one
    Walky_one:
    ... these functions have got a nice XML-Doc description ...
    That would be the format you use to get VisualStudio's Intellisense to recognize and use your comments.
  • Old Student (unregistered) in reply to Redsplinter
    Redsplinter:
    Old Student:
    The code snippet cited is also not good Python practice. It makes the function more difficult for users to understand and is arguably less efficient than explicitly defining a function:
    def shuffled(list_):
        return sorted(list_, key=lambda z:random.random())
    
    (Also, the code violates the coding standards outlined in PEP 8, so it would likely be rejected if submitted as part of a standard module.)

    Of course, since we've already imported the random module, we probably ought to just replace this with calls to

    random.shuffle(list_)
    

    True and true - though I don't think anyone cares about PEP 8 around here since Python is usually just used for prototyping and glue. ... and

    random.shuffle(list_)
    shuffles in-place so it's not quite equivalent.

    Sure... so we can redefine our function as

    def shuffled(_list):
        temp = copy.deepcopy(_list)
        random.shuffle(temp)
        return temp
    

    but whether it's necessary to return a different list vs. shuffle in place is a question of the intended use of the function.

  • nmclean (unregistered)

    But please don't use copy.deepcopy. list(_list) or _list[:] is what you want there.

  • (cs)

    I know it's a bit late to comment, but hey, the implementation isn't that bad (provided there wasn't an obvious library function available which could already do the job).

    I dunno, maybe I was the source of a lot of WTF early on in my life as a coder for this, but I sometimes felt compelled to implement similar things myself, cause I didn't like "Magic" and wanted to understand how something was done. It wasn't a mistrust of libraries thing, but for a newbie, it sometimes feels good to have "done it yourself", even if it is something trivial.

    To those who said better supervision was needed for a junior. I agree, but sometimes senior management see a well run, efficient team with 2 or 3 senior devs and a large number of graduates, then start thinking "hey, these kids do most of the work, why do we need these overpaid seniors, it's all just computer shit anyway" then they retrench any technical staff paid over $150KPA and you've got no technical leadership left.

    If he were on my team, during the code review I'd have refactored the calling code to use the requisite library functions, explained why having more code to maintain is bad, then pointed the well-intentioned kid in the direction of the library source code (or ILSpy if you're on .NET), to satisfy his curiosity as to how the thing is implemented.

  • Gunslinger (unregistered) in reply to ShachMaT
    ShachMaT:
    Alargule:
    TheCPUWizard:
    What was happening during the daily standup/scrum?

    What is this daily standup you speak of?

    Tell me that you are not serious, or NOT a dev.

    Your Name:
    It's that daily "fifteen minute long meeting" that lasts from 8:30 to 10:00, where your pointy-haired manager asks for everybody's status and demands explanations of why everything is behind schedule.

    The idea that there's (1.5 * number_of_team_members) manhours consumed on status updates daily doesn't ever occur to them as one of the reasons.

    THAT.

    I work for a company that actually produces things to contract, on time and on budget. We don't have daily standup meetings. Coincidence?

  • admiralranga (unregistered) in reply to Balu

    and then curse your CS lecturer for not letting you use it :/

  • (cs)

    This developer was eventually promoted to Project Manager. This is the part that is missing in the story.

Leave a comment on “Some Useful Bits”

Log In or post as a guest

Replying to comment #:

« Return to Article