Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
NovemberMike
Dec 28, 2008

Fal-Cone posted:

Just graduated two months ago in May with a B.S. in CS (No previous internships/research experience. A handful of small projects, and a 2.98 GPA), but after two months of hobbling around and applying to a handful of places, the only position I managed to snag was as a "Software Intern" at a large telecom company at $15/hr working 35/40h a week on a 6-month contract doing test automation and stuff.

Everyone else that graduated with me is either making double my expected annual income, or is still bopping around doing summer stuff. It's day five for me, here, and I'm not really digging this huge cubicle farm and the whole "worth-half-as-much-as-my-classmates thing" :ashobon:

What's the best plan in terms of trying to get a position as an actual software engineer job out there? Could I try to put the fact that I'm currently in an internship on my resume and hope it scores me some points? Or stick it out for a couple quarters or the whole six months? I mean, i'm in the SF Bay Area, it shouldn't be that difficult, right?

Just keep putting in applications and maybe try to put some work examples up. I was in the same position and it took me about 5 months but I got a 70k/yr job.

Adbot
ADBOT LOVES YOU

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

how!! posted:

That code took me three days to create. It represents exactly how I write code for production. Everything I write for my personal projects and for stuff at work, I strive for it to look like that. I never ever ever ever check in code that looks like tef's code. For that reason, I always feel like it's unfair when I'm given a programming challenge where I'm forced to turn in code that I'm not able to polish up the way I like. For the same reason, I hate it when my co-workers check in code thats not polished up either. Reddit did it right because they let me take as much time as I wanted. I feel proud of the code I wrote and feel confident in emailing it to them. Do you think I'm a terrible programmer because it took me three days to write that? I guess I could have gotten it done in one hour, but it would have been awful code and I would have been ashamed of myself for sending them a solution that was not as good as I am capable of creating.
so basically you spent an hour solving the problem and then 23 hours making future maintenance less time consuming

in this context that may be the right thing to do, but only because they don't actually know how long you spent on it so it doesn't automatically reveal that you are terrible at time management

how!! posted:

By the way, does anyone have a job where they're tasked with solving problems with only one hour to do it in? Since I started programming about 5 years ago, I've never had such a short amount of time to get something done. Most deadlines I deal with are on the scale of days, not minutes. Does it make me a bad programmer if I get anxious when told I need to write something complex and I only have an extremely short amount of time to complete it?
have you ever worked anywhere other than a large and inefficient non-software company?

how!!
Nov 19, 2011

by angerbot

Haywood Japwnme posted:

He didn't say your code was garbage or that he didn't care about the code he writes. You are completely ignoring everyone's advice and probably aren't going to get a job at a company like Facebook if you keep up that attitude. In the workforce, you're expected to work quickly. Don't get mad at people for telling you how the real world is. You need to turn your ego down a bit and listen to to the people trying to help you get a job.

That or apply to grad school.

So you're saying speed is all that matters? The advice is that I should not care about code being readable and elegant? A good programmer fixes everything in the quickest manner possible? If a problem can be fixed in 5 minutes, then spending 6 minutes is wasting time? I don't know, in my experience that line of thinking leads to really really complex code that becomes really unmaintainable really quickly. Its what I call "crap piled on top of crap, piled on top of crap, piled on top of crap"

elegant code == fun to work with (because you can easily run the code in your head)
complex code == not fun to work on (because you have no idea what the gently caress is going on)

not fun work == programmers procrastinate, get frustrated and make excuses for not getting the work done

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
Most of the time when you need code fast it doesn't have to be maintainable. When the production environment shits the bed and you're losing millions of dollars per hour, management probably wants you to tape it back together now and design a proper solution later.

And 5 minutes vs 6 minutes isn't the issue here, you were talking about writing an hour-long problem in a week. Have you ever done programming contests? Try something like USACO to learn to code on a timer and not care very much about code quality.

qntm
Jun 17, 2009
You should all just write perfectly polished code in 1 hour like me :smug:

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

How!!, I'm not sure what you want from us.

You asked whether it was unfair to ask for the GoL problem to be done in an hour, we all agreed that it was fair and doable within the time limit, and now you've spent the last page doing mental contortions to convince yourself that you're a special snowflake to whom reality doesn't apply. I think you'll find when you get out into the real world that, like it or not, having enough time to write code "the right way" is a pipe dream and never happens.

For better or worse, being a good developer isn't about writing the best of all possible code given unbounded time, but writing code that's good enough under (hopefully not unrealistic) deadlines.

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
That kind of makes me wonder, all the courses that aren't deep theory keep drilling into us that there are always constraints, there are always tradeoffs, and you can never ever have your one perfect data structure or algorithm in the real world. Not one of your classes taught you to make decisions about tradeoffs?

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

how!! posted:

So you're saying speed is all that matters? The advice is that I should not care about code being readable and elegant? A good programmer fixes everything in the quickest manner possible? If a problem can be fixed in 5 minutes, then spending 6 minutes is wasting time?

Way to take things out of context again, I didn't say anything about limiting your time or that "speed is all that matters." The point here is that you just have to learn how to write code faster and be more efficient with your time.

how!! posted:

I don't know, in my experience that line of thinking leads to really really complex code that becomes really unmaintainable really quickly. Its what I call "crap piled on top of crap, piled on top of crap, piled on top of crap"

And please enlighten us with all of this experience that you keep heralding over the thread. The experience that trumps every other poster's in this thread.

how!! posted:

not fun work == programmers procrastinate, get frustrated and make excuses for not getting the work done

I hope you realize how ironic this statement is. I bet you don't like working in teams too!

tk
Dec 10, 2003

Nap Ghost

how!! posted:

So you're saying speed is all that matters? The advice is that I should not care about code being readable and elegant? A good programmer fixes everything in the quickest manner possible? If a problem can be fixed in 5 minutes, then spending 6 minutes is wasting time? I don't know, in my experience that line of thinking leads to really really complex code that becomes really unmaintainable really quickly. Its what I call "crap piled on top of crap, piled on top of crap, piled on top of crap"

elegant code == fun to work with (because you can easily run the code in your head)
complex code == not fun to work on (because you have no idea what the gently caress is going on)

not fun work == programmers procrastinate, get frustrated and make excuses for not getting the work done

There's often a solution that's somewhere between directly hex editing an existing binary and what you seem to feel is necessary.

Ensign Expendable
Nov 11, 2008

Lager beer is proof that god loves us
Pillbug
Sometimes life forces you to hex edit a binary or rewrite existing functionality. I once had to compress 4 month of someone else's work into a day and a half. Sometimes you need to code fast. Sometimes you need to code well. If you do both, you can sure as hell earn more than $15 per hour.

Also, I don't know what kind of projects you've worked on where programmers give up if they're faced with hard code. I can almost guarantee you that someday in your career you will be faced with lovely undocumented, uncommented, legacy code. Knowing how to understand hard code is essential.

shrughes
Oct 11, 2008

(call/cc call/cc)

Haywood Japwnme posted:

And please enlighten us with all of this experience that you keep heralding over the thread. The experience that trumps every other poster's in this thread.

I can answer that:

how!! posted:

So far in my tech career, I've worked for 3 different companies. At each company, a pattern always emerges:

1. The company gets started
2. A bunch of inexperienced developers start writing code with little idea
3. I get hired
4. I see the code base and see incomprehensible crap that is not tested, not documented, not logical in any way, etc.
5. I make the suggestion right off the bat that it would be better, faster and more fun to just throw everything away and start again fresh.
6. Company boss / lead developer gets extremely angry and offended and tells my I'm the craziest person alive for suggesting such a thing.
7. I get frustrated and disappointed and eventually lose interest in the job until I get fired, or I find another job.

From the Complete code rewrites / refactoring in the real world thread.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
Since it seems to be job interview and internship hour, I'll go ahead and mention that I got an internship recently in an agile shop where almost all the tests consist of directions for manual testing in Excel spreadsheets, plus maybe ~100 automated tests written in Javascript for a poorly-supported automated testing tool that likes to stop working on two of the three machines it's been setup on, with apparently nobody knowing why and just suggesting that I remote into a VM on which it actually works. Oh, and the scripted tests are months out of date. The last time they were updated was sometime in February, I think, and the last time they were run none of them passed. :toot:

My job is to figure out which test scripts can still be used, then start making new automated tests to replace the manual ones.

They seem to follow an actual agile process (scrum) rather than waterfall where the requirements change every day. I'm kind of excited. I'm kind of nervous, but at $10/hr I'm guessing that I'm super cheap compared to actual developers, as one of my friends who graduated a year ago got hired for >$60k/yr. So they're probably not expecting me to be a genius here.

I need to be a genius anyway, though, because I want to be working at Google/MS/Facebook/etc. this time next year.

how!!
Nov 19, 2011

by angerbot

Dijkstracula posted:

How!!, I'm not sure what you want from us.

You asked whether it was unfair to ask for the GoL problem to be done in an hour, we all agreed that it was fair and doable within the time limit, and now you've spent the last page doing mental contortions to convince yourself that you're a special snowflake to whom reality doesn't apply. I think you'll find when you get out into the real world that, like it or not, having enough time to write code "the right way" is a pipe dream and never happens.
I disagree. In the refactoring thread I posted a while ago, someone posted a quote that went a little like "There are two ways to write code, one way is so that there are no obvious bugs, the other way is that there are obviously no bugs. The first is very easy, the second is very hard". My problem (and I completely admit that this is a problem that pretty much ensures that I will never write code professionally again), is that I am completely incapable of writing code the first way. tef's code has 'no obvious bugs'. The code I was trying to write was going to have obviously no bugs. A lot of the code in my github has obviously no bugs, and that code I'm proud of and will send to employers when they ask for a code sample. That kind code is very possible to write, and very fun to write, but also takes much more time.

When I wrote the reddit code, the process went a little like this:

1. Read problem
2. Spent few minutes writing code in my head and trying to figure out how I would attack the problem, no real solution comes to me, so I forget the problem and start thinking about other stuff
4. Left for the grocery store.
5. While I was standing in line to checkout, I began thinking about the problem and decided the best way would be to have some kind of bogosort method where it randomly matchs up users, and then there be some kind of process that goes through the result to verify that most of the match requirements are satisfied.
6. On my walk home after thinking about it some more, I realize that the bogosort method might take too long to execute if there are a lot of users, but it probably still might work. so its worth a shot if it turns out to be easy.
7. After I get home I start writing some code implementing the bogosort matching method.
8. After an hour or so I realize this bogosort method is not going to cut it
9. Stopped programming, and went and did something else, maybe i'll get back to this problem, maybe I'll just forget the whole thing.
10. The next day I was thinking about the problem again and came up with the idea of arranging the users into circles.
11. Realized I'm going to have to write TubeSort (an algorithm for sorting a set of objects with no duplicates next to each other), which I had written before at one of my previous jobs (which I dont have acces to the code anymore). I didn't really want to write it again, because I remember the first time being kind of tedious.
12. I made this stack overflow question: http://stackoverflow.com/questions/11040368/re-arrange-items-into-an-array-with-no-similar-items-next-to-each-other thinking maybe I can use something in the python standard lib instead of writing it all from scratch.
13. Some time later I resign to the fact that I'm going to have no choice but to write TubeSort so I began writing it. At least now it'll be in my github so I dont ever have to write it again.
14. By the end of the second day, I finish tubesort with some unit tests and I'm confident that it works right
15. While I'm laying in bed I'm thinking about all the corner cases and how I'm going to deal with them. I make the decision that my circles idea is going to be flexible enough to handle the corner cases, and that I might as well give it another shot.
16. I wake up the next morning and start writing the program with the circle idea and TubeSort. (throwing out all the code I had written for the bogosort method)
17. By noon of the third day I was done and it appeared all the corner cases were dealt with.
18. I write the cover letter, explaining my approach, and the few corner cases I never got to (and why I didn't get to them), and all the other crap you normally put in cover letters. This part actually took another day or so because I hate writing cover letters.

All in all it took three days, but not solid three days. I was doing other things during that time. The problem is, this is how I solve all coding problems. This is the pace at which I work. I can't go any faster, and I really cant go any slower either. I do ship code though. I've shipped lots and lots of code actually (its all in my github).

When I got the facebook problem, I know how I work, and I immediately knew that one hour is not going to be enough time to go through all the steps listed above. If they had said "you have 5 days to complete this", I would have kept the problem in the back of my head, and eventually realized that its simple, and sometime during the fourth day, I would have came up with something like what tef wrote.

edit: I admit I have the biggest ego in the world, which is why I make posts like this, hoping someday someone will say whatever they need to say to me that will convince me to not be so egotistical.

how!! fucked around with this message at 01:04 on Jul 10, 2012

pigdog
Apr 23, 2004

by Smythe

tef posted:

:toot:

Python code:
import sys
import collections, itertools

lines = sys.stdin.readlines()
num = int(lines.pop(0))

for b in range(num):
    size, n= (int(x) for x in lines.pop(0).strip().split())
    old_b, new_b = [], []
    for _ in range(size):
        line = lines.pop(0).strip()
        old_b.append(line)
        new_b.append(list(line))
    for _ in range(n):
        for r in range(1, size-1):
            for c in range(1,size-1):
                grid = "".join(g[c-1:c+2] for g in old_b[r-1:r+2])
                counter = collections.Counter(grid)
                new_b[r][c]='b' if counter['b'] > counter['w'] else 'w'
        old_b = ["".join(row) for row in new_b]
    print "Board (%d)\n%s"%(b+1, "\n".join("".join(r) for r in new_b))
this is probably wrong :3:

edit; if I had the entire hour I might do something like this for fun

Python code:
import sys, collections, itertools
lines = sys.stdin.readlines()
for n in range(int(lines.pop(0)):
    s, i = (int(x) for x in lines.pop(0).strip().split())
    b = [lines.pop(0).strip() for _ in range(s)]
    for _ in range(i):
        b = [[('b' if sum("w b".find(x)-1 for x in itertools.chain.from_iterable(\
        g[c-1:c+2] for g in b[r-1:r+2]))>0 else 'w') if 0<r<s-1 and 0<c<s-1\
        else b[r][c] for c in range(s)] for r in range(s)]
    print "Board (%d)\n%s"%(n+1, "\n".join("".join(r) for r in b))

I'm not a Python programmer, which may or may not be a factor, but with that in mind, a solution such as this doesn't give a good impression on your skills at all.

It looks like you're still stuck in the hacker mindset where you strive for your code to look terse, "cool" and written by a smart person who knows all the tricks of the language to make something shorter. And also takes a smart person to understand and appreciate it.

Paraphrasing Martin Fowler from a book that's nearly 10 years old by now, "you do not write the program for the computer, but also for the next developer who gets to read it (who may be you in a couple of years)". It's good if code is short and to the point, but the goal of having short code is clarity. Code which is written by smarty people, for smarty people, takes a lot of "CPU time" in the head to read and understand, and in projects that are 100 or 10,000 times bigger than this interview question, and instead of being a delightful brain tease it that becomes a serious pain in the rear end and something that will slow everything down.

Professionally written code is easy to read. Even if you were to keep the algorithm the same, there's literally no reason not to use more descriptive variable names and a couple of functions to break the functionality apart into logical, easily digestible chunks. It takes little time, and whoever has to work with the code later will thank you.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Well, looks like you have it all figured out then good luck with the Facebook interview!

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

Y'know, if I thought like you I never would have built anything. I'm not a very good programmer, self taught and all, but I have something and it does work with enough tests to prove it, but not the whole way around cause I'm one person.

Start timeboxing your jobs and get comfortable with it, otherwise the real world either won't bother with you or it'll force you into a time schedule you won't be able to comfortably deal with.

Put a time constraint on yourself, commit to sticking to it, and that should be all the impetus you need to stick through tedious problems, persist or adapt hard problems, and just keep the code moving.

I say this more from the perspective of my work in non programming fields, but it applies to anything. If you are not willing to set a time limit to your goals, you'll find the not done pile getting bigger and bigger everyday.

Scaevolus
Apr 16, 2007

Here's a really excellent talk that discusses how years of your life is a valid and important optimization parameter. It has a lot of pragmatic wisdom that comes from actually completing projects.

http://the-witness.net/news/2011/06/how-to-program-independent-games/

(Slides 21, 26, and 30 are particularly interesting)

shrughes
Oct 11, 2008

(call/cc call/cc)

pigdog posted:

I'm not a Python programmer, which may or may not be a factor, but with that in mind, a solution such as this doesn't give a good impression on your skills at all.

It looks like you're still stuck in the hacker mindset where you strive for your code to look terse, "cool" and written by a smart person who knows all the tricks of the language to make something shorter. And also takes a smart person to understand and appreciate it.

I am a Python programmer, I guess, and that code's perfectly fine. Exceptionally readable, actually.

Edit: The first version, of course. The second version is only mildly silly.

baquerd
Jul 2, 2007

by FactsAreUseless
I made this all for you how!!, I'm curious about your thoughts on the code.
http://ideone.com/j8TH4

Hacked together as all hell in a half hour.

Paolomania
Apr 26, 2006

Haywood Japwnme posted:

That or apply to grad school.

Whoa now, there is nothing more seat-of-the-pants than what a grad student hacks up. It is just enough to get numbers for a paper with the added confidence that no reviewer will ever bother to look at the code.

how!!
Nov 19, 2011

by angerbot

baquerd posted:

I made this all for you how!!, I'm curious about your thoughts on the code.
http://ideone.com/j8TH4

Hacked together as all hell in a half hour.

that code looks like it was hacked together as all hell in a half hour

I don't know java, so it's hard for me to really understand whats going on, but theres a lot of nested ifs and stuff like this:
code:
internationals.get(countries[0]).remove(0);
internationals.get(countries[0]).remove(1);
combined with very little documentation and no tests makes me think there could be bugs, but idk.

The way I measure 'goodness' of code is by the amount of time it would take to fix a bug if one were to emerge. Even my code could have a bug in it, but it would be faster to find in my code than yours. I'm biased though.

edit: your code doesn't strike me as terrible, but it doesn't strike me as awesome either. It just looks like code.
edit2: your code is almost half the lines as mine. That may be because mine has a bunch more documentation, but it could also be a sign that yours doesnt cover a corner case that mine does. tests would help determine this.

how!! fucked around with this message at 03:55 on Jul 10, 2012

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
Just thinking about it real quick, it seems like making a one-hour program and having someone else spend eight hours extending it later seems like a better idea than spending eight hours on it so that someone else will only have to spend two hours extending it later. I think it's even worse if that second person thinks like you and also spends eight hours on it so that a third programmer will only have to spend a couple hours when he or she gets to work on it, unless he or she also decides to spend much more time on it so the next person in line will spend less time, unless...

I'm just not convinced you're doing better in the long run.

how!!
Nov 19, 2011

by angerbot

Safe and Secure! posted:

Just thinking about it real quick, it seems like making a one-hour program and having someone else spend eight hours extending it later seems like a better idea than spending eight hours on it so that someone else will only have to spend two hours extending it later.

You don't spend the extra time just to make it more extendable. You do it to make the code more understandable. Understandable code is not only more easily extendable, it is also more easily fixable and more easily changeable. Code is always broken and code is always in need of changing/improving.

Also, the act of refactoring code and making it more understandable will reveal bugs that you wouldn't have noticed.It also gives you ideas for features that would be easy to implement with the elegant code, which would have not been possible with the crappy code. For instance, my code makes it known when a domestic user gets matched up with someone from another country, or when an international user gets matched up with someone from the same country. That part of the program wasn't in the requirements, but it was trivial to implement so I went ahead and implemented it (mainly for my own testing purposes, if the boss wanted me to remove that code, I would). I don't know if baquerd's code can do that, but I imagine he would have to spend at least another half hour adding in that functionality if he was told to.

quote:

I think it's even worse if that second person thinks like you and also spends eight hours on it so that a third programmer will only have to spend a couple hours when he or she gets to work on it, unless he or she also decides to spend much more time on it so the next person in line will spend less time, unless...
If the next person spends 8 hours changing the code, then that means they are completely changing the way the code behaves. If that were the case, then so be it, theres no way around it.

Cicero
Dec 17, 2003

Jumpjet, melta, jumpjet. Repeat for ten minutes or until victory is assured.

shrughes posted:

I am a Python programmer, I guess, and that code's perfectly fine. Exceptionally readable, actually.

Edit: The first version, of course. The second version is only mildly silly.
It's fine for readability because it's a math problem. If the variables were representing more concrete things, then naming them like "old_b" would be a terrible idea. I think that may be where some people are confused.

Wulfeh
Dec 1, 2005

The mmo worth playing: DAoC

Fal-Cone posted:

Just graduated two months ago in May with a B.S. in CS (No previous internships/research experience. A handful of small projects, and a 2.98 GPA), but after two months of hobbling around and applying to a handful of places, the only position I managed to snag was as a "Software Intern" at a large telecom company at $15/hr working 35/40h a week on a 6-month contract doing test automation and stuff.

Everyone else that graduated with me is either making double my expected annual income, or is still bopping around doing summer stuff. It's day five for me, here, and I'm not really digging this huge cubicle farm and the whole "worth-half-as-much-as-my-classmates thing" :ashobon:

What's the best plan in terms of trying to get a position as an actual software engineer job out there? Could I try to put the fact that I'm currently in an internship on my resume and hope it scores me some points? Or stick it out for a couple quarters or the whole six months? I mean, i'm in the SF Bay Area, it shouldn't be that difficult, right?

If you are in the bay area have you tried going to any meetups and networking a little bit? You could try this something like this: http://www.meetup.com/San-Francisco-Twisted-Python-Meetup/events/71296232/

Tres Burritos
Sep 3, 2009

I'll hopefully graduate sometime this year and I keep tabs on this thread quite a bit. That being said, I'm almost positive that how!! is a troll. I hope.

Promethium
Dec 31, 2009
Dinosaur Gum

Cicero posted:

It's fine for readability because it's a math problem. If the variables were representing more concrete things, then naming them like "old_b" would be a terrible idea. I think that may be where some people are confused.

I don't normally read Python but I thought tef's first solution was very easy to read since it did exactly what I expected out of a brute force solution.

In a quick coding / problem solving interview, I feel the goal is to impress your interviewer, not write something particularly well documented or easy to maintain. Your interviewer is the audience, not hypothetical devs looking at your code without knowing anything in advance, and the interviewer has seen many people write the same algorithm already so they know what to expect. Well-documented code has a lot of benefits but doing it in a short interview doesn't impress most programmers, especially when the documentation is about boilerplate parts of the code; what they appreciate is an elegant algorithm. I remember reading a discussion where people were debating an interview question with various approaches, tradeoffs of code complexity vs. run speed, when Peter Norvig replied with a few lines of uncommented Python. No one proposed anything after that.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.

how!! posted:

If the next person spends 8 hours changing the code, then that means they are completely changing the way the code behaves. If that were the case, then so be it, theres no way around it.

But how do you know your requirements in the future? Extensible code that is intended to be reused for current requirements is one thing, but creating extensible code for the 'possibility' of reuse, without knowing what that reuse could be, seems like throwing time away that you'll never get back. It COULD be really useful, or it could be dead weight.

There's nothing wrong with writing a piece of code that definitively does the thing it's intended to, designed for the requirements you know you have. You can write tests for requirements you know you have, which means you know if you are meeting them or not with your code.

Also, written and running code, regardless of quality, gives you feedback about what does and doesn't work. Unwritten code remains a concept in your head and nothing more, untested by the compiler / interpreter.

Cicero
Dec 17, 2003

Jumpjet, melta, jumpjet. Repeat for ten minutes or until victory is assured.

Promethium posted:

I don't normally read Python but I thought tef's first solution was very easy to read since it did exactly what I expected out of a brute force solution.

In a quick coding / problem solving interview, I feel the goal is to impress your interviewer, not write something particularly well documented or easy to maintain. Your interviewer is the audience, not hypothetical devs looking at your code without knowing anything in advance, and the interviewer has seen many people write the same algorithm already so they know what to expect. Well-documented code has a lot of benefits but doing it in a short interview doesn't impress most programmers, especially when the documentation is about boilerplate parts of the code; what they appreciate is an elegant algorithm. I remember reading a discussion where people were debating an interview question with various approaches, tradeoffs of code complexity vs. run speed, when Peter Norvig replied with a few lines of uncommented Python. No one proposed anything after that.
Right, I agree that the solution was fine, I was just pointing out that naming your variables that way for a less abstract problem would be a bad idea. Like, if I gave an interviewee a problem that talked about, say, stocks, I would expect variables to be descriptive (e.g. "shares", "interest", etc.), instead of "a", "b", "c". It's one thing to ignore commenting in an interview, which is totally fine, but another thing to abandon good coding style completely.

Aramoro
Jun 1, 2012




I tend to think how!! and tef are both wrong and the real answer is somewhere in the middle. How!!'s code is alright for that Reddit problem, looks like a few hours work, no one gets a task assigned to them for 3 days though, that's a bit insane. Tef's solution to the Game of Life Lite™ is a bit terse, considering the problem is only going to take 30-45 mins to write you've got at least 15 mins to add a few comments and expand those variable names. (Unless code compression is a thing in Python?)

If someone is writing a bug fix then sure, needs to be done in under an hour on a production system, and you can write a surly comment about how your colleagues are all incompetent in that time easily.

If you're writing feature code then and and you write some incomprehensible mess then it's going to get rejected at code review even if it works.

tef
May 30, 2004

-> some l-system crap ->

how!! posted:

So you're saying speed is all that matters? << Strawman argument removed>>

No, we're saying you're ignorant of how much it does.

quote:

elegant code == fun to work with (because you can easily run the code in your head)
complex code == not fun to work on (because you have no idea what the gently caress is going on)
not fun work == programmers procrastinate, get frustrated and make excuses for not getting the work done

this is hilarious.

how!! posted:

I disagree. In the refactoring thread I posted a while ago, someone posted a quote that went a little like "There are two ways to write code, one way is so that there are no obvious bugs, the other way is that there are obviously no bugs. The first is very easy, the second is very hard".

You should not take Tony Hoare's Name in Vain.

quote:

My problem

You have more than one problem.

quote:

tef's code has 'no obvious bugs'.

:krad:

quote:

When I wrote the reddit code, the process went a little like this:

I love the effort you've put into this.

quote:

edit: I admit I have the biggest ego in the world, which is why I make posts like this, hoping someday someone will say whatever they need to say to me that will convince me to not be so egotistical.

hahahahahahahahaha

tef
May 30, 2004

-> some l-system crap ->

pigdog posted:

I'm not a Python programmer, which may or may not be a factor, but with that in mind, a solution such as this doesn't give a good impression on your skills at all.

It's ok, of all the people I want to impress you are not on the list.

quote:

It looks like you're still stuck in the hacker mindset where you strive for your code to look terse, "cool" and written by a smart person who knows all the tricks of the language to make something shorter. And also takes a smart person to understand and appreciate it.

I actually went out of my way to write it in that way, as you can see from the second example. I enjoy code golf for forums posts.


quote:

Paraphrasing Martin Fowler from a book that's nearly 10 years old by now, "you do not write the program for the computer, but also for the next developer who gets to read it (who may be you in a couple of years)".

As you can see, I wrote it for the forums posters who get to read it.

quote:

It takes little time, and whoever has to work with the code later will thank you.

Send me a pull request on github for my repo tefs-code-in-posts


shrughes posted:

I am a Python programmer, I guess, and that code's perfectly fine. Exceptionally readable, actually.

Edit: The first version, of course. The second version is only mildly silly.

:3: I didn't get enough time to make it a one-liner.

Cicero posted:

It's fine for readability because it's a math problem. If the variables were representing more concrete things, then naming them like "old_b" would be a terrible idea. I think that may be where some people are confused.

(I hate to spoil this, but I renamed all of the long variable names to short ones so the post wouldn't break things)

Tres Burritos posted:

I'll hopefully graduate sometime this year and I keep tabs on this thread quite a bit. That being said, I'm almost positive that how!! is a troll. I hope.

Poe's Law.

Promethium posted:

Peter Norvig replied with a few lines of uncommented Python. No one proposed anything after that.

c.f Peter Norvig on sudoku vs TDD blogger.

Maluco Marinero posted:

But how do you know your requirements in the future?

how!! is psychic.


Aramoro posted:

I tend to think how!! and tef are both wrong and the real answer is somewhere in the middle

You should see the code I write for work

pigdog
Apr 23, 2004

by Smythe

tef posted:

As you can see, I wrote it for the forums posters who get to read it.
What may be impressive for a smarty forums reader looking for a hip and elegant brain tease may not be as impressive for someone looking to recruit a professional programmer. Just sayin.

edit: Try showing someone that code, just the code, without showing the thread and/or the context, and time how long does it take for them to say "oh, this implements game of life with inputs and outputs like this".

pigdog fucked around with this message at 16:10 on Jul 10, 2012

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
One thing that always bothered me about the code you write in interviews is that it doesn't tell you anything about what the person necessarily knows about what they think is shippable production code. We could get into the minutiae of standards and crap that plague programmer conversations around the world, but I think throwing some code in front of a guy and asking him to critique it would quickly tell you things that actually matter faster than testing whether he can produce clever code on the spot. Things like:

1. He can spot buffer overflow vulnerabilities instantly
2. He can see a deadlock / race condition situation
3. He knows not to nitpick non-functional stuff like bracing standards for Java or C during a fuckin' code reading interview (but if it's for Python he should know the standard)

It's one thing to try to impress programmers that you're basically a code junkie hacker, but it's another to prove that you're able to do the daily bullshit work of most programming jobs in the world competently. Perhaps if you're interviewing for one of those 1%er jobs you'll have to prove it all, but that's why you're just so drat good and you can pass every single interview you ever get called in for, right?

Aramoro
Jun 1, 2012




The thing about a programming test is that it's easy, really easy way to know if they know arse from their tit when it comes to code. If people complain about doing it the only reason can be is because they don't know what the gently caress they're doing. Once they've done it then you can go on and ask them some questions about it. "What changes would you make you make if you had more time" etc.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

necrobobsledder posted:

One thing that always bothered me about the code you write in interviews is that it doesn't tell you anything about what the person necessarily knows about what they think is shippable production code.

That's why you always discuss coding philosophy. The test is just a really quick way to weed out people who can talk a good game but can't actually accomplish anything.

We used to do "good code/bad code", where we wrote out some snippets of code that were functionally correct but had what we considered stylistic or architectural problems, and we asked the candidate to discuss the code with us. Stuff like "methods/variables with crappy names", "classes that did way too much", "inconsistent indentation or brace style", "methods with 16 parameters".

There was no right or wrong answer, although obviously agreeing with us about what made for bad code was a plus.

Zombywuf
Mar 29, 2008

code:
pep8 --repeat tef.py 
tef.py:2:19: E401 multiple imports on one line
tef.py:8:12: E225 missing whitespace around operator
tef.py:15:31: E225 missing whitespace around operator
tef.py:16:29: E231 missing whitespace after ','
tef.py:16:34: E225 missing whitespace around operator
tef.py:17:35: E225 missing whitespace around operator
tef.py:19:28: E225 missing whitespace around operator
tef.py:21:27: E225 missing whitespace around operator
sigh

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

necrobobsledder posted:

2. He can see a deadlock / race condition situation
I had an interview somewhere where I was given a snippet of code and had to explain how the deadlock occurs. It was a trick question; there was no deadlock :argh:

text editor
Jan 8, 2007

Zombywuf posted:

code:
pep8 --repeat tef.py 
tef.py:2:19: E401 multiple imports on one line
tef.py:8:12: E225 missing whitespace around operator
tef.py:15:31: E225 missing whitespace around operator
tef.py:16:29: E231 missing whitespace after ','
tef.py:16:34: E225 missing whitespace around operator
tef.py:17:35: E225 missing whitespace around operator
tef.py:19:28: E225 missing whitespace around operator
tef.py:21:27: E225 missing whitespace around operator
sigh

One day I wanna give a programming interview to someone and actually validate it for pep8 compliance just to get a reaction from the interviewee

Adbot
ADBOT LOVES YOU

Zombywuf
Mar 29, 2008

text editor posted:

One day I wanna give a programming interview to someone and actually validate it for pep8 compliance just to get a reaction from the interviewee

Just have them check it in and run it as a commit hook.

I don't know whether you should give credit to those that remove the commit hook though.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply