• (cs)

    junior devs arent qualified to frist.

  • Walky_one (unregistered)

    Cannot be bad code. As we learned the day before yesterday, Some comments is better than no comments. And these functions have got a nice XML-Doc description...

  • Pista (unregistered)
    In a related note, the developer responsible for maintaining the applications he wrote has since handed in his notice.

    Ouch! This hurts!

  • (cs)

    that holiday code doesn't discriminate between summaries; if the date is in the file and some summary comes after it (not necessarily on the next line) then it is a holiday

  • (cs)

    My question is why was a "Junior Developer" not being monitored closely????

    What was happening during the daily standup/scrum?

    What was happening during the review/retrospective?

    To me that is TRWTF.

    ps: Since these were in a ".txt" file, rather than in Source Control, were they ever used in production code?

  • moz (unregistered) in reply to ratchet freak
    ratchet freak:
    that holiday code doesn't discriminate between summaries; if the date is in the file and some summary comes after it (not necessarily on the next line) then it is a holiday
    This does at least avoid the false negative problem which might have occurred when UK32Holidays.ics contains a holiday which isn't on the list.
  • (cs)
    TheCPUWizard:
    What was happening during the daily standup/scrum?

    What is this daily standup you speak of?

  • QJo (unregistered) in reply to TheCPUWizard
    TheCPUWizard:
    My question is why was a "Junior Developer" not being monitored closely????

    What was happening during the daily standup/scrum?

    What was happening during the review/retrospective?

    To me that is TRWTF.

    ps: Since these were in a ".txt" file, rather than in Source Control, were they ever used in production code?

    One presumes that they are held locally to this junior dev's machine, and when he wants to use such functionality, he just cut-and-pastes it into whatever class he needs it.

    I've seen such practices used all over the place. It makes you want to chew your own leg off to get away. The arguments in favour of this egregious style are: "These are quick and simple and it's quicker to do this than to go hunting around for the class where they live -- and besides, I thought you said last week that globals are bad." And: "In case we find we want to do something slightly different in the location where I [strikeout]bodged[/strikeout] pasted it in, ..." etc.

    The points about peer review and standup/scrum are still completely valid, and are probably indeed the real WTF.

  • faoileag (unregistered) in reply to Pista
    Pista:
    In a related note, the developer responsible for maintaining the applications he wrote has since handed in his notice.
    Ouch! This hurts!
    Well, maintaining software written by somebody else is par for the job - lucky are the ones who can start from scratch in a new position.

    However, if said software is a pita to maintain yet management does not recognize that and sets impossible-to-keep deadlines, looking for new employment is completely acceptable (more so if the developer inheriting the software is on a "performance related pay" scheme and suffers financially for missed deadlines).

    But what if the blame game is not possible? I once worked at a place where someone in department "A" was tasked with developing a module for department "B" (my department). When he delivered what he called an "example of how you can use the library" that example was so bad, I flat-out refused to accept the "example" (and thus the responsibility for failing to make it work) and told him "You developed it. You make it work". Shortly after, the developer from department "A" handed in his notice.

    And I definitely couldn't blame him.

  • faoileag (unregistered)
    the junior developer wrote:
    int day = Convert.ToInt32(str[6].ToString() + str[7].ToString());
    Must be a very junior developer indeed when he has not heard of the Substring(start, length) method of String.
  • Balu (unregistered) in reply to faoileag
    faoileag:
    the junior developer wrote:
    int day = Convert.ToInt32(str[6].ToString() + str[7].ToString());
    Must be a very junior developer indeed when he has not heard of the Substring(start, length) method of String.

    Must be a very, very junior developer when he has not heard of DateTime.ParseExact(...)...

    I read this is a book once: If you find a task hard to implement, spend 5 minutes to look at the framework documentation very closely.

  • faoileag (unregistered) in reply to Balu
    Balu:
    faoileag:
    the junior developer wrote:
    int day = Convert.ToInt32(str[6].ToString() + str[7].ToString());
    Must be a very junior developer indeed when he has not heard of the Substring(start, length) method of String.
    Must be a very, very junior developer when he has not heard of DateTime.ParseExact(...)...
    I didn't know that one as well - but then it's been some six years since I last coded in C#.
    Balu:
    If you find a task hard to implement, spend 5 minutes to look at the framework documentation very closely.
    Ok, a quick 10-seconds glance at the documentation of String was definitely not enough, since ParseExact had escaped my eye...
  • faoileag (unregistered) in reply to faoileag
    faoileag:
    Ok, a quick 10-seconds glance at the documentation of String was definitely not enough, since ParseExact had escaped my eye...
    Yes, I know. If I had been logged in I could now edit my post. As I am not I can't.
  • (cs) in reply to TheCPUWizard
    TheCPUWizard:
    My question is why was a "Junior Developer" not being monitored closely????

    What was happening during the daily standup/scrum?

    What was happening during the review/retrospective?

    To me that is TRWTF.

    ps: Since these were in a ".txt" file, rather than in Source Control, were they ever used in production code?

    I'd say that your assumption that everyone has daily standups and/or SCRUM is AmWTF(*). But you're right, someone should keep more of an eye on junior devs.

    (*) A minor WTF, duh, also known as WTF in A minor.

  • ANON (unregistered)

    At least I learned to know a new language feature of C#: extension methods.

  • Gill Bates (unregistered)

    Don't you guys have some sort of code coloring? This looks like something an intern would PM and ask "what's wrong here" repeatedly afterwards. Captcha: dolor, which appropriately means pain.

  • EvilSnack (unregistered)

    Another exhibit for the Museum of Re-Invented Wheels.

    Also known as, "A typical company's code base."

  • ZoomST (unregistered) in reply to faoileag
    faoileag:
    the junior developer wrote:
    int day = Convert.ToInt32(str[6].ToString() + str[7].ToString());
    Must be a very junior developer indeed when he has not heard of the Substring(start, length) method of String.
    Sadly, that is a subsequent effect of the "code stash": 1) (very junior) developer implements this crap and test it in a couple of situations. 2) developer keeps pasting his "trusted" code everywhere. If it gets corrected in some project, it's not corrected in the code stash. 3) (less junior) developer builds more and more confidence on his code stash, even if he learned better ways to do it. Keeping in mind "It works and is easy to add" is essential for this way of thinking. 4) Crap multiplies (in most of the cases) at an alarming rate. 6) ??? 7) Profit! At all times) Pain coming from hell for the rest of the sufferers: developers, code maintenance engineers,...
  • lol (unregistered)
    when it was pointed out that you could do it in one line by overloading ToString()

    erm... a single line to overload ToString()... but then you'd have to copy the code from his function into your overloaded method to format it as he wanted, so really... its not 1 line of code at all.

    And he could have added his own method as an extension method to string class anyway, which might have been better - especially if someone else had already overloaded ToString for other purposes.

    I think the WTF today is the article itself, not the WTF.

  • (cs)

    Yaaay, free code ... I am adding this to my Project_Utils.vb :-)

  • Mathman (unregistered)
    Math.Round((Convert.ToDecimal(dec) - Convert.ToDecimal(Convert.ToDecimal(dec) / Convert.ToDecimal(1.2))), 2);

    A particularly complicated way of dividing by 6.

  • Dunx (unregistered)

    GetVat() is a gem too, with its hard-coded magic number for the VAT rate, because the VAT rate never changes and does not vary at all between countries.

  • The Fury (unregistered) in reply to Dunx
    Dunx:
    GetVat() is a gem too, with its hard-coded magic number for the VAT rate, because the VAT rate never changes and does not vary at all between countries.

    Or different goods. Not to mention that WTF is this doing as an extension method?

    You would need at least the following :)

    IVatCalculator VatCalculator IVatCalculatorFactory VatCalculatorFactory MultinationalVatCalculator ....

  • QJo (unregistered)

    Just found this unholy pile of manure in a core app of ours:

    import java.io.*;
    import java.util.*;
    
    public class TextAreaManipluation
    {
    
    
     public static int textAreaCount(String args) 
    {
    	try
    	{	
    	String[] argsList = args.split("\n");
    	int len=argsList.length;	
    	return(len);	
    	}
    	catch(Exception e)
    	{
    	return(0);
    	}
    }
    public static String textAreaDatatoApp(String args, String ctr) 
    {
    	try
    	{
    	int i=Integer.parseInt(ctr);
       String[] argsList = args.split("\n");
       String strget=argsList[i-1];
    	    if(strget!=null)
    	    			return(strget);	    	
    	    else
    	 		return("");	 
    	}
    	catch(Exception e)
    	{
    		return("");
    	}
    }
    
    public static String textAreaDataFromApp(String args) 
    {
    	try
    {
    if((args!=null) || !args.equals(""))
    {
    String finalStr=args.replaceAll("~","\n");	
    return(finalStr);
    }
    else
    {
    return("");	
    }	
    }
    catch(Exception e)
    {
    	return("");
    }
    }
    

    Indentation is as I found it.

  • Bill Coleman (unregistered) in reply to Walky_one

    Yes, I noticed that as well. the XML doc is completely empty.... That's a red flag if I ever saw one.

  • Your Name (unregistered)

    Any code in your codebase in a file named "Utils" or something similar is inevitably full of this sort of helpful code.

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

    What is this daily standup you speak of?

    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.

  • Paul Neumann (unregistered)
    if (!str.StartsWith("-"))
        {
          str = "£" + str;
        }
        else
        {
          str = str.Insert(1, "£");
        }
    If both legs of a conditional are operative, then there is no need to negate the condition.
  • Paul Neumann (unregistered) in reply to Balu
    Balu:
    faoileag:
    the junior developer wrote:
    int day = Convert.ToInt32(str[6].ToString() + str[7].ToString());
    Must be a very junior developer indeed when he has not heard of the Substring(start, length) method of String.

    Must be a very, very junior developer when he has not heard of DateTime.ParseExact(...)...

    I read this is a book once: If you find a task hard to implement, spend 5 minutes to look at the framework documentation very closely.

    I heard it differently: If it isn't done in 5 minutes, you're doing it wrong. Approach the problem differently, slice the task differently, and find a library option which solves the other half.

  • Blah (unregistered)

    So, who wants to takes bets after reading those methods that the junior dev wasn't a bad/inexperienced programmer so much as he was sadist? I just hope Graham's coworker will choose not to carry on this painful legacy.

  • C-Derb (unregistered)

    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"))

  • Lily (unregistered) in reply to Your Name

    and the hours wasted surfing the net and fucking around

  • Redsplinter (unregistered) in reply to Your Name
    Your Name:
    Any code in your codebase in a file named "Utils" or something similar is inevitably full of this sort of helpful code.
    Not necessarily, but definitely exceedingly likely.

    Found in util_init_.py:

    shuffled = lambda list_:sorted(list_, key=lambda z:random.random())
    random_hex_string = lambda len_:''.join(random.choice(string.hexdigits) for i in range(len_)).upper()

    ^^ Useful and good abstractions.

    On the other hand... found in macros.py:

    def exec_(*args, **kwargs):
    	return exec(" ".join(args))

    ^^ I happen to know there's a justification for that thanks to the input interface, and that it never comes near a user, but still....

    C-Derb:
    I think my favorite part is potentially splitting the "Summary" string 8 times when one time would have been sufficient...
    Yeah that was a bit painful to see. Cycles ain't free, dammit.
  • (cs)

    What I can't believe is that Alex wasted all these beauties on only one article. He could have milked this submission for a week!

  • Josh (unregistered) in reply to C-Derb
    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.

  • (cs)

    Something to add, which has been proven time and time again here:

    Dates and time are difficult. Look for library routines to do at least SOME of the work. You won't be sorry.

  • (cs) in reply to Paul Neumann
    Paul Neumann:
    if (!str.StartsWith("-"))
        {
          str = "£" + str;
        }
        else
        {
          str = str.Insert(1, "£");
        }
    If both legs of a conditional are operative, then there is no need to negate the condition.

    I don't deny that you are not wrong about that.

  • (cs) in reply to C-Derb
    C-Derb:
    I think my favorite part is potentially splitting the "Summary" string 8 times when one time would have been sufficient:
    This is already explained by QJo:
    QJo:
    One presumes that they are held locally to this junior dev's machine, and when he wants to use such functionality, he just cut-and-pastes it into whatever class he needs it.
    It's called copy&paste-programming and is the only form of code-reuse that has been successful in the industry!
  • Developer Dude (unregistered)

    No imagine working on an app where the lead developer writes code like this, and where that lead has been working on that app from inception, for over ten years.

    Welcome to my world. sigh

  • (cs) in reply to moz
    moz:
    ratchet freak:
    that holiday code doesn't discriminate between summaries; if the date is in the file and some summary comes after it (not necessarily on the next line) then it is a holiday
    This does at least avoid the false negative problem which might have occurred when UK32Holidays.ics contains a holiday which isn't on the list.
    So you're left with the false negative problem that causes *all* days to be not bank holidays. You know, when the admins move the .ics file to a different location, and the function silently decides that nothing is a bank holiday...
  • (cs) in reply to Developer Dude
    Developer Dude:
    No imagine working on an app where the *lead* developer writes code like this, and where that lead has been working on that app from inception, for over ten years.

    Welcome to my world. sigh

    Remember to put the GAU-8 in your back pocket before going to work...

  • anonymous (unregistered) in reply to Developer Dude
    Developer Dude:
    No imagine working on an app where the *lead* developer writes code like this, and where that lead has been working on that app from inception, for over ten years.

    Welcome to my world. sigh

    Are you looking at me from across our cubes? Sounds so much like my project... except that the lead is expelled, and we've been rewriting the crap for over three years.

    Most code is up from "smelliest shit you can imagine" (most like thoday's post and some worse) to "smells quite weird". After that we can rewrite again and try to get to "I quite like the smell of it, don't you?", except that we never will... either because we won't be satisfied with it, or because I'll move to greener pastures and forget this shit.

  • (cs) in reply to Alargule
    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.

  • Jeremy (unregistered)

    I will never ever ever understand why do many programmers think they have to do so many things themselves. Why in the world do people think "converting from one date format to another", or "formatting 3223 as $3,223" is some super custom problem that needs their solving?

    DO THE MATH. Almost every time something is along the lines of "this must be really common, I can't believe it isn't easier then this 50 line function" it probably is.

  • Matthew (unregistered) in reply to Redsplinter
    Redsplinter:
    shuffled = lambda list_:sorted(list_, key=lambda z:random.random())
    That's actually not a good way to shuffle a list. At best it's inefficient, and at worst it's very non-random and breaks some sorting algorithms. Use Fisher-Yates instead.
  • Jeremy (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.

    At my old job we had a project that was "way behind", and by "project" I mean "what the people in charge wanted it to be that day" and by "behind" I mean "past an overly optimistic date chosen by someone who knew nothing about nothing."

    Anyway, we needed to get it back on track, so a daily 1 hour meeting was schedule for the first thing in the morning. When that, somehow, failed to get things back on track, a daily 1 hour meeting at the end of the day was scheduled.

    Of course nothing changed between us leaving that meeting and arriving for the next morning's meeting, so every morning meeting was a rehash of the previous days ending meeting.

    Somehow having a whole team spending at least 2 hours of their days in meetings about how to get the back on track, at least 1/2 of which were a spectacular waste of time, even by these-types-of-meetings standards, also failed to get it back on track.

    The solution they came up with was to throw the main developer on the project under the bus and ask for more time to retool...which is why that's where I "used to" work.

  • Old Student (unregistered) in reply to Matthew

    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_)
    
  • Redsplinter (unregistered) in reply to Old Student
    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.

  • Anomaly (unregistered)

    Its entirely possible they are told not to use the built in libraries. That used to be a huge problem for the Java libraries...

  • jlmt (unregistered)

    I tried ConvertToMoney, and it didn't work.

    I am disappoint.

Leave a comment on “Some Useful Bits”

Log In or post as a guest

Replying to comment #429168:

« Return to Article