Code through the looking glassI'm the God of all OOP
We typically don't look too deeply into the overall design on a candidate's code. Most coding tasks just aren't big enough to warrant it.
When we do, it is typically because the candidate has done something… peculiar. For example, we have had a candidate that send a submission with no less than 17 classes to manager reading a CSV file and populating a dictionary. At some point we knew that this candidate wasn't going to move forward, but it became a challenge, to try to outline how the data actually traveled through that particular maze. But as much as we love Mr. Goldberg, I'm afraid that dear Rubbie isn't going to be remembered for much longer.
Here is how this candidate code started:
static void Main(string[] args) { //Call for parsing method HelperClass cr = new HelperClass(); cr.CsvParser(); cr.ToArray(); cr.Sort(); cr.UnifyIdLists(); //ask the user to enter input string input = cr.InputReader();
I actually started explaining the issues in this code, but I run out of… pretty much everything.
I have a challenge for you, can you think of a single OOP principle that isn't being broken here?
For… fun, I guess, you can also look at the following code, which come just after the one above:
Start: //check input type switch (cr.InputTester(input)) { case 0: //valid email structure, but the input is not found in the file List<int> emails = new List<int>(); emails = cr.EmailSearcher(input); if (emails.Count == 0) { Console.WriteLine("The input you have entered has not been found in the file. \nPlease try again."); input = cr.InputReader(); goto Start; }
I guess someone heard that loops are a performance bottleneck in most applications and decided to do away with them.
More posts in "Code through the looking glass" series:
- (18 Mar 2016) And a linear search to rule them
- (17 Mar 2016) Sorting large data sets
- (16 Mar 2016) I'm the God of all OOP
- (15 Mar 2016) All you need is a dictionary (and O(N) )
- (14 Mar 2016) Finding today's log file
Comments
:-)
According to B. Stroustrup - if you are using SWITCH it is probably not OOP.
What happens to: List<int> emails = new List<int>();
After the goto statement? Is it a compiler warning or memory leak or OK? https://msdn.microsoft.com/en-us/library/13940fs2.aspx https://download.microsoft.com/download/0/B/D/0BDA894F-2CCD-4C2C-B5A7-4EB1171962E5/CSharp%20Language%20Specification.docx
p. 251: A label can be referenced from goto statements (§The goto statement) within the scope of the label. This means that goto statements can transfer control within blocks and out of blocks, but never into blocks.
It seems to be OK to use goto to leave a block. Normally you might use GOTO to go down to done: in the bottom and exit several blocks.
I'm all for learning from bad coding examples, but have you ever thought to yourself that some of your applicants are actually readers of your blog? I mean, think about how they may feel when they open their RSS feed one day, see a post called "Im the God Of All OOP" and see the code they sent to you. That would probably make them feel like crap. If this blog post actually had a propose, I'd think "well, this post is actually trying to convey a point so it might be worth it", but I really see no point to this other than shaming the person who wrote bad code and probably has one or two things to learn.
Yuval, It is hard to shame someone if I'm not mentioning a name or any identifying information. The person in question got a detailed explanation on their code, including pointers on where they need to improve.
Let me correct myself, I didn't mean "shaming" in it's public "look at person x.y.z how awful their code is". I'm just thinking of a person which values your blog posts and finds himself looking at his code and feeling bad for himself. Don't know, It may only be me but I think this can really make a person feel bad about himself.
Yuval,
Knowledge of your faults is the first step to fixing them. Acknowledging them as faults is the second. But being motivated to fix them is the critical third step. Why are you saying that someone who produces bad code should feel good about his work?
Hi Ayende, did you send this blog post to the person who attempted to work for you before publishing? I'm asking because the Yuval's remark seems to me valuable. If someone would write a blog post like this with an offensive title like "I'm the God of all OPP" even without mentioning one's name, but still about a particular person, that wouldn't help at all in improving. That could rather discourage one from showing his/her work anywhere.
Scooletz, The post isn't actually about the candidate, it is about the code
@StephanWard It's definitely not what I'm saying. You should definitely acknowledge your weaknesses and learn from your mistakes, as I hope the person who wrote this code understood after Oren sent him a descriptive replay about his work. On the other hand, seeing your bad code posted in a blog which has a large reader base can be embarrassing. I'm not saying the guy should feel proud of what he did, I'm simply saying it can hurt them.
I have to agree. Finding out I've seriously misjudged my position and receiving constructive feedback would be a learning experience, in fact receiving the level of feedback mentioned in these posts is laudable as we all know how much time hiring can take up with simple yes/no responses alone.
Then taking my code and putting it on a blog post tagged "humor"? Where the point seems nothing more than so other developers will have a chuckle at my expense? Hiding the name doesn't stop it stinging the developer who tried, while we all continue to post how awful it is we keep seeing devs who just cut and paste StackOverflow.
Previous posts of this ilk have had a point. A warning of "okay, the code isn't great, but here's the bit others might trip on or also misunderstand. Sure it's funny when it's not you, but here's the lesson". I didnt feel comfortable with the way they were presented, but I understood. This one just left a bad taste.
We can argue all day about the definition of "shaming" or the semantic details of whether this post is "about the candidate" or "about the code". Let's not bandy words: this is the third consecutive blog post in as many days that is encouraging readers to laugh at a piece of code that submitted to you as part of a job application. We get it: candidates sometimes submit bad solutions and it can be amusing. I chuckle to myself when I see someone making mistakes that I myself used to make -- but I keep that thought to myself.
Here's the thing: negative reinforcement is not as effective as positive reinforcement. This is a well researched and documented idea. I'm not suggesting that we need to treat people like delicate butterflies and make sure that everyone gets a 1st place trophy, but I do think that making people feel crappy will tend to demotivate them rather than motivate them. If I were currently seeking a job I'd be turned off from applying here because there appears to be a culture of code shaming.
Here's a suggestion for the blog: rather than highlighting the bad submissions, how about highlighting the good ones? How about pointing out the clever ideas that, even if they aren't what you're looking for, were creative and unique and interesting? I'd rather read about surprising successes than about mundane mistakes.
While I have been happily entertained with these posts, the sentiments of most of the comments above have been going through my head as well. Fyi.
I've had to work hard to be a more sensitive people person "It's not about the candidate, it's about the code" is exactly the sort of thinking that makes perfect sense to me but is actually a danger sign if I catch myself thinking it. In any community, it will be about people whether you intended it that way or not. And to be fair to most people, "I'm the God" is actually more about the candidate than anything. If I picture myself as the candidate as I read, as many readers of your blog will automatically do, it is very off-putting.
Not trying to tell you what to do. I enjoy each of your posts immensely! At least I have fair warning before applying. ;-)
Oren I know these people have gone thru a interview of some sort before the coding assignment. Seeing some of the coding assignment I am bit surprised with the results. Makes me wonder about my company and who we are hiring. That being said do you wonder if publishing posts like this may result in less people applying to work at your company? I am not sure I would apply (no worries US bound) although I think would be amazing to work with someone like you. This is not attempt at changing the way you do things seems to work for your company. Just more of a thought.
I don't see anything wrong with these posts. The code that has been pointed out on this blog from interviewees is literally thedailywtf worthy. As long as Ayende was constructive (in person) to the individual in person by pointing out what is wrong with their samples, what's the harm? Is thedailywtf doing any damage?
These people are interviewing for a company that has very high standards, led by someone who is notorious for being straightforward and zero-bullshit. I highly doubt Ayende would have any problem calling people out on their code if they were to work for him; so if they get discouraged by it happening anyway (while being anonymized) then they might not be the best candidate for that position.
I also find these posts very insightful. Specifically, I feel it makes a statement about how people can move forward in the industry (even get passed the first stage of the interview process!) while writing code like this. It kinda makes me hopeful, in that while the market is getting more and more saturated by the day, there will still be room left for people who take code seriously.
On the other hand, as a person without a degree or other credentials besides experience, it makes me worried that my resume could get passed up by candidates who produce this sort of code.
Paul, I'm fine with only people confident in their skills and having their code shown coming to work for us.
"Oren's blog reader" and "producer of the above code" is definitely an oxymoron.
Out of interest, how are these people being recruited, recruitment agent or direct (via online application)?
SRP
Ollie, This particular candidate reached us through a recruitment agency that we get a lot of our people from. We hired two candidates from this agency in this round
Hi Oren,
I understand you are critiquing the OOPness of the code submitted by the candidte...but you don't mention if it worked. Did the code submission work?
Steve, Take a look at the rest of this series. It didn't
Comment preview