Right? It's gotta be a troll. Coders are so meticulous about methods that there is a long-standing battle over using 4 spaces or the tab button, so I don't see how anyone could teach programming and tolerate that level of garbage code.
I have been programming since I was 13 and I have never seen any other programmer, whether in college, university, or at work, talk about 4 spaces vs the tab button.
It's a portability issue more than anything else. I get students submitting code with all sorts of crazy indenting because they're mixing tabbing with spaces under the assumption that tabbing is x spaces.
Oh, the struggle is real. It is particularly vicious when you have different people working on the same project using different editors. What you end up with is a weird mixture of spaces and tabs. And then some poor third person takes it into their third editor and what they end up with is a giant unreadable mess.
And then there are parsers that need tabs instead of spaces and parsers that croak if you mix them. Urgh. One company-wide policy is usually a good thing.
It got me at work. I code primarily in Java and use Eclipse like everyone fucking else and I use tab and it's fine because everyone's Eclipse is autoconfigured the same exact way. Except this one guy who uses Netbeans and got really mad at me because he didn't configure his tabs on Netbeans and pulled me aside and told me to switch to 4 spaces.
It's the kind of thing that never crops up in real life, but online is a holy war. And most of the drama stems from the tabs people not understanding that you can configure your IDE to insert 4 spaces instead of the tab character when pressing tab. They literally think people are typing out 4 spaces on a new line (Also ignoring most IDE layout magic.)
u/PlayMp1when did globalism and open borders become liberal principlesJun 25 '17
Okay, not a coder, but I've taken a couple classes (took an intro Python class and an intro to programming class that used Visual Basic). Not exactly informed but not lost.
Here's the advantages I can think of for 4 spaces:
Consistent. No matter what editor you're using and who's working on it, 4 spaces is the same size every time.
Allows for divisions and multiplications like 2 spaces and 8 spaces, whereas tabs are not divisible.
Looks pretty.
Advantages for tab:
Hilariously faster. 1 keystroke vs. 4. It takes me about a half second to tap the space bar 4 times.
Looks the same as 4 spaces.
Within one editor it's always the same size so if everyone is on the same page, tabs look fine.
Based on this, I get the feeling that 4 spaces is better practice, like commenting, but it takes a long time compared to tabs, which means it's bad for business because it's slow, just like commenting. So in short, using spaces is better, but it's time consuming, which clueless managers don't like, so people use tabs and fail to comment their code because they're trying to rush out code as quick as possible.
The TerraFrame.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile it! The solution? Copy half of the init() code into a new method, called codeTooLarge(), and call that from init().
That seems like a first year class to me. I mean, I'm teaching myself coding using a "for dummies" book and similar projects are covered early on in it.
This doesn't even sound like that though. This sounds like a teacher who is like "hey, this guy made the effort and just because his program won't actually, you know, work doesn't mean I have to fail him". A teacher who didn't care at all would, before looking at anything else, try to break your program and if it did he'd hand it back to you, say "it's broken; fix it or get an F" and be done with it.
I love how he complains about parents that flip a dump truck whenever their child does poorly, yet believes that giving kids A's is the only way to reinforce good behavior.
From what the guy said the student can't even understand the concept of variables outside of programming. I would've said they were in some kind of Elementary School intro to CS class but then the guy says the student got an internship so now I just say the student doesn't exist.
I get why people are reluctant to go with an F, especially if the student is trying and working hard and doing so could, fuck up their graduation requirements and mean they can't afford to graduate school.
But come on at least give them a D-.
18
u/AetolButter for the butter god! Popcorn for the popcorn throne!Jun 23 '17
Why should he graduate, though? He's clearly in the wrong field if the concept of variables is stumping him.
This is how you ruin someone's life. This kid is gonna try to become a programmer and then have his work shut down brutally. He will realize he was lied to and cheated by this insane person.
Getting one A won't mean that you will end up graduating successfully. All that happens is that this kid passes this very shitty intro class, gets his ass kicked in the first real class, and has to transfer to another major.
I think its BS anyway though. I don't know of a school that will let you retake an intro class 4 times.
This guy seems like the kind of person who doesn't tip because "tipping is fucked up thing oppressing the common worker man" and yet still goes out to eat and doesn't tell his waiter about it.
On a more personal note, fuck this guy so hard. I've spent more effort teaching kids GameMaker for a summer camp than he has getting a kid through a fucking college computer science class.
I don't even know who he's helping with this. He has to work harder to justify that A when, given the code block he was presented with, it would be easy as balls to make a case that causes it to fail. The student definitely doesn't benefit from this; if they go into the real world coding like this they're going to get canned very quickly and with prejudice (I almost added "within a week" but I've seen some shitty coders stick around far longer than they should have) and really their best case scenario is that another teacher is completely unsympathetic and just says "find a tutor or whatever but your code doesn't perform and if you can't make it perform you will fail my class" before they graduate with a degree they can't use. It doesn't even really help the parents all that much if they're paying for this kid's education because, again, it'll be a worthless degree to the kid if the manage to graduate with it.
This seems a lot less like someone who "doesn't care" than someone who is actively sabotaging their school's curriculum.
What's even funnier is that he ends up arguing that he was correct because he got the student a job working at a company doing html maintenance. So he basically is saying he was right to forceably pass the student through a computer science degree to do something only vaguely in the same field as computer science.
Everybody wins! Except for the company who thought they were hiring someone who has an idea of basic programming structure when they ask him to do something in jQuery! Hooray!
Because this is America goddamnit and EVERYONE deserves an A, no matter how little effort they put in to something, or how dumb they are. Have you ever seen a 5 year old coloring something? They're old enough to be careful, but they scribble quickly and relentlessly, because we don't reward quality, we simply reward for the sake of rewarding. "Oh, that's the most beautiful thing I've ever seen!" and it's black crayon scribbled haphazardly across Snow White's face. And the minute you say "It looks like you put zero effort into this coloring" the parents throw a fit, and that carries through all the way to college.
0.o Some people express serious criticisms of the coloring when they take a look to a kid's drawing, really?
I mean, honestly. How is praising a kid for coloring outside the lines worse than this? At least art is subjective. Also, you can't reasonably expect a five-year-old to actually be a good artist and at that age, encouragement is probably the most important thing. You should reasonably expect that a guy in a CS class understands algebra. This honestly sounds like someone who needs to be taking some sort of remedial math class.
It just boggles the mind that this guy can be one of those people who rails against "participation trophies" and then does shit like this, which is a million times worse.
It's just another way to state the problem of grade inflation. If every student has the same grade then the scale is failing to differentiate them. How does it help a company choose the best candidate?
Well it only applies to the students in this particular class. Giving a whole class all A's versus all F's makes a difference in how they appear to stack up with other students in that university who didn't take that class.
Admittedly, GPA is less important than it used to be. Even companies with GPA cutoffs just take your self-reported grade at face value. I have had a few places ask for transcripts, though.
So... the student doesn't understand the concept of X as a variable but understands the concept of A and B as variables? If he doesn't get variables wouldn't he, upon seeing "return the sum of A and B", immediately ask the teacher what A and B are and then return the sum of those two numbers and only those two numbers?
The code is checking whether the inputted number ( n ) is a prime number. The most efficient way to do this is with a short algorithm that doesn't even take up more than a few lines of code as shown here.
The original post has almost 1000 lines of code that is just straight up checking for EVERY SINGLE PRIME NUMBER from 0 to 30000 (???).
Haha, that's true... I meant compared to other general solutions. It runs in, what, 2sqrt(log(n)) ? It was shown in 2002 you can do it in polynomial time.
1
u/PPewtI welcome the downvotes because Reddit does not define meJun 25 '17
The polytime algorithm is neither practical nor easy to implement, and the other good (but not proven polytime) algorithms are also not really reasonable for students at this level.
As an aside, 2sqrt(log(n)) is polytime. The naive algorithm is 2n, or 2sqrt(n) depending on how naive we're talking.
I agree for an intro course most of the methods are not going to be feasible. Trial division, Fermat, and maybe Miller-Rabin.
ECPP: way too hard to implement. Proof in heuristically polynomial time, and commonly used for large general form numbers.
APR-CL: way too hard to implement. Proof in sub-exponential time. The exponent is log(log(log(n))) which makes a fun digression into slow growing functions, as it is effectively a constant for the size of practical inputs. Which means it's effectively polynomial time over our inputs, and with a smaller exponent than AKS.
AKS: Feasible to implement, but IMO for general students it has too many little complications for the benefit. Maybe useful to show the importance of testing (but again a lot of work for that). Polynomial time with exponent ~6 and high constants, which means (as PPwet mentioned) it's not very practical. It eventually does beat trial division.
Factoring methods: State of the art in 1975, faster than AKS for hundred digit inputs but AKS will clearly win as the inputs get much larger. Likely too much work for students as you need at least one decent factoring method. Probably some confusion over partial factoring (of n-1) to prove primality (of n).
Trial division: Easy to implement and we can have fun adding optimizations. Exponential time in size of input as mentioned.
Fermat, Euler, Miller-Rabin, Lucas, BPSW, etc.: Fun times. Seems doable for most programmers, but your mileage may vary. Seems to be hard for people to follow the random vs. deterministic aspects (e.g. deterministic M-R base sets for all 64-bit inputs). Getting the math ideas is going to depend a lot on your students.
True. I certainly wouldn't try to get students in an intro programming course to implement the AKS primality test.
n was the parameter referring to the integer we were checking. In that case it's 2sqrt(log(n)) . That's exponential time because we talk about time complexity in terms of the bit length of the input, which is ~ log(n).
1
u/PPewtI welcome the downvotes because Reddit does not define meJun 25 '17
I mean, if it's exponential time then define n in a way that it's an exponential function (such as n = bit length, 2sqrt(n) = runtime), because 2sqrt(log(n)) is bounded above by a polynomial.
Both are valid ways of writing the time complexity in complexity theory. Since n was already define I used log(n). And it's not called polynomial time regardless of how we write it, because that is always defined in terms of the bit length of the input.
Frequency of use determines whether efficiency is a concern. A new nanoseconds here and there isn't worth the horrific, maintainable mess of such a solution if it's not a bottle neck/time critical path.
Not as much frequency of use as size of the input. For example; To construct an RSA key, you need to find very large primes. Using the above method, our sun would burn out before it was done checking.
Passing students who don't understand the material frustrates me to no end. I saw an engineering student, who had passed Calc I - III and was in differential equations, who did not know how to take the derivative of a polynomial. He had the same professor for the entire calc sequence, and this professor made tests embarrassingly easy and exactly like the study guides, so students could easily pass them without knowing the underlying techniques.
However, differential equations was taught by a different professor. She took her job very seriously and instilled great passion in the subject, and in fact was the reason why I became a math major. Unable to take derivatives or integrals, the student was horribly lost and had to withdraw.
2
u/PlayMp1when did globalism and open borders become liberal principlesJun 25 '17
who did not know how to take the derivative of a polynomial
How the fuck? I can basically remember how to do that and the last time I did it was when I got a D+ in Calculus 1 my senior year of high school (I'm not great at math, I did okay, mostly Bs, up until my second semester of precalculus and then fell on my face for both that and calc 1). How would you get to differential equations while not knowing how to do that?
It's the most fundamental operation, right? The student was lazy, the professor didn't teach well, the homeworks were online and easy to abuse, and he gave study guides that were the exact same questions as the exams with only the numbers changed. It was horrifying.
The professor had been there a while and was one of the few who had tenure, so as a lowly tutor I knew I had no say in the situation. But God, do I wish he would get out.
That is the claim, yes, but it's not really believable. The poster said there were about "a 1000 more lines of this", which wouldn't really make any sense.
Frequently in a programming assignment you're told what "unit tests" your code has to pass (i,e. "I will be passing your code the following inputs and expecting the following outputs: ...") and so I've definitely seen students that have occasionally taken the shortcut of programming the specific input/output cases for the unit tests because they couldn't get the general functions to behave properly, but nobody would do that for a 1000 of them; it would be for like 10-20.
Conversely, if you're trying to program a comprehensive sum function just by calling out individual cases, even an idiot would go in numeric order, right?
On top of that if, as the 'teacher' claimed, the student doesn't get variables there should be at most one case presented because the student wouldn't understand that A or B could represent multiple numbers. He would either have the one case for the numbers he suspects A and B to represent or no cases because he would just flat not understand the assignment.
Do people actually expect that shit to work? Even my high school CS teachers at least skimmed the code after checking the test cases; I couldn't imagine it getting past the army of TAs that college professors have at their disposal.
u/PPewtI welcome the downvotes because Reddit does not define meJun 25 '17
Also what damn university course is getting you to write a calculator? My little cousin had to do that as an entry to a fucking apprenticeship.
Universities generally start first year assuming people have never coded before. Also, depending on how sophisticated said calculator is it can be a bit of work for people with some experience.
It could be one of the python 1 type courses. In the university I went to, they were in part meant for people who hadn't coded before. The first round or two of assignments were really simple.
2
u/PlayMp1when did globalism and open borders become liberal principlesJun 25 '17
Also what damn university course is getting you to write a calculator?
Intro programming courses, usually. I never even wrote a calculator in the Python class I took like 3 years ago.
Building my first GUI calculator in Java and Swing felt pretty good. Didn't follow any tutorials, but it wasn't trivial. Calculators, like the standard calc.exe in windows, do a lot of things invisibly that I didn't anticipate when I started. Granted, that's a bit higher difficulty than the command-line calculators that they typically start you out with, and which was clearly being shown in the post.
98
u/Aetol Butter for the butter god! Popcorn for the popcorn throne! Jun 23 '17
I am... utterly baffled. By the post, by the student in question, and by the teacher who thinks anything other than failing him is appropriate.
39
u/stellarbeing this just furthers my belief that all dentists are assholes Jun 23 '17
Please be a troll; I don't want someone to be programming software that creates code that fucking bloated.
If your student can't comprehend rudimentary algebra, he shouldn't be writing code.
I can't code for shit, but I know that's not the way to do it.
28
u/Carosello Jun 23 '17
This is how you ruin someone's life. This kid is gonna try to become a programmer and then have his work shut down brutally. He will realize he was lied to and cheated by this insane person.
32
u/KuiShanya I don't care what any of the doctors say. Jun 23 '17
This guy seems like the kind of person who doesn't tip because "tipping is fucked up thing oppressing the common worker man" and yet still goes out to eat and doesn't tell his waiter about it.
On a more personal note, fuck this guy so hard. I've spent more effort teaching kids GameMaker for a summer camp than he has getting a kid through a fucking college computer science class.
15
u/moudougou I am vast; I contain multitudes. Jun 23 '17
0.o Some people express serious criticisms of the coloring when they take a look to a kid's drawing, really?
6
u/shockna Eating out of the trash to own the libs Jun 24 '17
This.... This doesn't belong on /r/badcode.
This is more along the lines of /r/programminghorror, and a ghastly display at that.
9
u/reallydumb4real The "flaw" in my logic didn't exist. You reached for it. Jun 23 '17
That's not how any of this works
4
u/SnapshillBot Shilling for Big Archive™ Jun 23 '17
I still miss ttumblrbots sometimes.
Snapshots:
I am a bot. (Info / ^Contact)
4
u/Xealeon As you are the biggest lobster in the room Jun 23 '17
So... the student doesn't understand the concept of X as a variable but understands the concept of A and B as variables? If he doesn't get variables wouldn't he, upon seeing "return the sum of A and B", immediately ask the teacher what A and B are and then return the sum of those two numbers and only those two numbers?
4
u/hypochondriac12 Jun 23 '17 edited Jun 23 '17
Can someone explain why the code is bad?
3
u/[deleted] Jun 24 '17
brb posting this in bad code.
3
u/[deleted] Jun 24 '17
Passing students who don't understand the material frustrates me to no end. I saw an engineering student, who had passed Calc I - III and was in differential equations, who did not know how to take the derivative of a polynomial. He had the same professor for the entire calc sequence, and this professor made tests embarrassingly easy and exactly like the study guides, so students could easily pass them without knowing the underlying techniques.
However, differential equations was taught by a different professor. She took her job very seriously and instilled great passion in the subject, and in fact was the reason why I became a math major. Unable to take derivatives or integrals, the student was horribly lost and had to withdraw.
1
u/[deleted] Jun 23 '17
Have I misunderstood, or does this student put separately all possible outcomes of the math functions in the code?
1
u/dumnezero Punching a Sith Lord makes you just as bad as a Sith Lord! Jun 23 '17
Poor student didn't have any good math teachers..
1
u/maenads_dance Jun 24 '17
Title is excellent.
1
u/happyscrappy Jun 24 '17
This headline is awful. Clearly good practice says you should have written:
And don't even get me started about your brace placement.
1
u/AN_EXPERT_REDDITOR Jun 27 '17
omg kys pleb, port to brainfuck then lets talk
/s
0
u/[deleted] Jun 23 '17
[deleted] — view deleted comment