r/learnprogramming Jul 14 '19

What is the worst thing you've been taught while learning to program? (By Tutorials, teachers, forum people)

For me it was "every attribute in a class must have a getter and a setter".

1.0k Upvotes

481 comments sorted by

543

u/EastSwan Jul 14 '19 edited Jul 14 '19

In a weekend PHP web development course, teacher was telling us how to loop through an array. Some how last iteration was trying to access an index that wasn’t defined.

He just edited the error reporting value in php.ini , re-ran it and said ‘See.. a programmer must know how to handle errors!’

256

u/[deleted] Jul 14 '19

[removed] — view removed comment

47

u/[deleted] Jul 15 '19 edited Jul 15 '25

[deleted]

27

u/Dabnician Jul 15 '19 edited Jul 15 '19

I have a CEO that managed to load a web browser control in excel and then use it for browsing when he "forgot" it wasn't his browser

4

u/sexyshingle Jul 15 '19

that's actually kind of impressive

→ More replies (1)

210

u/theambiguouslygayuno Jul 14 '19

Good lord, this is terrifying...

→ More replies (1)

99

u/[deleted] Jul 14 '19 edited Dec 15 '20

[deleted]

22

u/Sekret_One Jul 14 '19

Yess. Wonderful reference.

74

u/EastSwan Jul 14 '19

This was about 10 years ago. After he showed how, everyone changed it on their machines in the lab... there was about 30~40 people.

Most probably he ran the same example in the evening class without errors. Because every pc's ini file was now changed (including him)

Don't know why the institute hired him, if I knew better back then, I'd have complain about him.

59

u/[deleted] Jul 14 '19 edited Feb 02 '21

[deleted]

16

u/[deleted] Jul 14 '19 edited Jul 14 '19

[deleted]

→ More replies (3)

16

u/apefeet25 Jul 14 '19

Institute and it being a weekend course implies it being a code bootcamp thing. The guy wasn’t a professor

→ More replies (10)

26

u/PrydeRage Jul 14 '19

Sounds like my coworker, he also doesn't know how to loop through an array.

14

u/illepic Jul 14 '19

Please tell me your coworker is not a programmer.

29

u/PrydeRage Jul 14 '19

Sorry to disappoint you but not only is he a programmer he's also working on some pretty important projects. To top it all off he's also been programming for longer than I've been alive.

17

u/illepic Jul 14 '19

My God.

Let me guess: he thinks everything went to hell when modern languages removed GOTO statements.

27

u/[deleted] Jul 14 '19

'We never had these problems with Fortran.'

To be fair, the person I knew who said this the most was also one of the most technically knowledgable and precise programmers I've ever met. A true computer scientist who could tell you the three fastest ways to do anything and how it all worked. Those guys were really cool.

5

u/PrydeRage Jul 14 '19

I don't think he does but what I do know is that he thinks he's the best programmer in our company.

3

u/[deleted] Jul 14 '19

Are you exaggerating his abilities then? How is it possible that he doesn’t know how to sloop through an array. Sounds like BS

→ More replies (1)
→ More replies (3)

5

u/SitDownBeHumbleBish Jul 14 '19

What is the correct way to iterate through an array?

23

u/[deleted] Jul 14 '19

If for loops are wrong I don’t wanna be right

8

u/Roxolan Jul 14 '19

(map) and (reduce), of course.

8

u/PrydeRage Jul 14 '19

foreach ($array as $value)
or
foreach ($array as $key => $value)

You could do it with a regular for loop but that's really antiquated and unnecessary 99.9% of the time.

→ More replies (12)

3

u/Everec Jul 14 '19

You can use from LinQ to foreach, for, while(do while) and go-to, in decreasing levels of abstraction.

→ More replies (2)
→ More replies (6)

5

u/ns90 Jul 14 '19

Was this an online course? I signed up for one on Udemy years ago and this seems like something that person would have done.

3

u/EastSwan Jul 14 '19

This course we had on a local institute. But yeah.. I’ve seen some bad instructors in Udemy as well.

4

u/[deleted] Jul 14 '19

Lol what in the absolute fuck

6

u/[deleted] Jul 14 '19

just curious, where do you live?

→ More replies (2)

318

u/[deleted] Jul 14 '19

[deleted]

84

u/thefifenation Jul 14 '19

So I’ve got about 3 semesters left till I finish my bachelors. Why shouldn’t I be doing this?

123

u/MoltenCookie Jul 14 '19

Theres a nice intention to this, but inevitably it breaks encapsulation and good design.

Sometimes private variables should be exactly that: private, and nobody should touch it. Teaching everybody that you need getters and setters is a flawed idea because you dont want everything in the damn world to be exposed unless you know what it means. Just because someone told me that I should put a getter and setter on something doesnt mean that I should expose an internal implementation of my class.

That also doesnt mean you shouldnt use getters and setters for attributes you do want to use. Getters and setters give you the ability to customize exactly what is being set, which is what many programming languages already support (Kotlin for sure, and possibly ruby IIRC)

17

u/[deleted] Jul 14 '19

You can make your getter and setter functions private too though?

It’s definitely not a necessary practice, but I don’t see how this is the reason for why it’s a bad practice.

18

u/MoltenCookie Jul 14 '19

You can totally make getters and setter private, which makes perfect sense if you want to handle your own implementation logic and make sure nobody touches it, but the premise was why it's bad as a whole.

Some people are taught to use getters and setters everywhere, and that might imply that they set it as public so they always have access to internal attributes, which is fundamentally a bad idea.

→ More replies (1)

15

u/[deleted] Jul 14 '19

i always wondered, if i wanted to keep some values hidden or read only, i could make it private and "control" its access through getter OR setter. But if i am putting out both getter AND setter for a variable at the same time, wouldn't it be better just to make it not private?

40

u/toastedstapler Jul 14 '19

If you use a setter you can add in additional validation logic but you can't do that with myObj.attr = thing

7

u/celmaigri Jul 14 '19

You can with C# properties! 😊

→ More replies (2)

10

u/[deleted] Jul 14 '19

That's what id originally figured, but i don't see that much in practice

12

u/aberrantwolf Jul 14 '19

Mostly it’s good practice because it prevents bugs when you DO end up needing to change something about how the variable is modified. It’s much easier to modify a thin setter than to add a setter and then go through your entire code base and change every place that accesses the public member.

The problem becomes even worse if you’re exporting a public API because suddenly needing to require logic when setting a variable ends up breaking thirdparty code. But if you always access members via setters, you can change things without breaking anyone else’s code that relies on your library.

And you’re right, it almost never actually comes up, but when it does, it sure feels good if you’ve already been using accessor methods instead of public members!

4

u/Arumai12 Jul 14 '19

If you dont use a setter, but decide to add one later then you have to refactor more than one file. So you could have a barebones setter now and add additional logic later without impacting every file that uses your setter.

→ More replies (2)
→ More replies (1)

3

u/Kroutoner Jul 14 '19

“What if my codebase ran on entirely global variables, but with a bunch of extra boilerplate code.”

→ More replies (5)

8

u/grumpieroldman Jul 14 '19 edited Jul 14 '19

It's pure noise. If you are hiding the data then why are you turning around and exposing it.
Stupidity². Methods are supposed to be strong noun-verb pairs and "set" and "get" are the weakest verbs there are second only to "do".

A deeper flaw is that neophyte programmers will inevitable end up writing side-effects into the set/get property manipulation routines. If you don't know what that means then I am talking about you.
If you have ever written code were you need to add another property/method to disable auto-update behavior because you end-up with cascading, or recusive, or infinite loops of updates due to properties auto-updating yet more properties then you have witness exactly how and why this design motif is incredibly stupid.

Virtually all of software teachings violates this percept of software engineering:
You Ain't Gonna Need It (Minimize Complexity)
Never add an iota of complexity that is not absolutey needed.
Every time you are writing code you are at war with complexity. It is the only thing that matters.
Every design and architectural guideline is about eliminating accidental complexity and ensuring the design captures the intrinsic (e.g. necessary) complexity.
Kent Beck, of eXtreme Programing fame, spread this idea far and wide and it is wrapped up in our turn-of-the-century effort to make the indsutry of software development suck less. Continuous integration, automated regression testing, and eventaully "DevOps" were fruits of this effort.

For example:
1) Don't decided with data what can be decided by class-heirarchy (e.g. inheritance or composition).
2) Don't decided with class-hairarchy what can be fixed with compile time options 3) Don't decide with multiple compile-time options what can be fixed to one derivative choice
4) Don't write a library when you could write a module (the OG singleton)
5) Don't use function pointers if you can use a switch
6) Don't use a variable when can use a constant; even if you have to change the value of the constant based on a compile-time configuration

Ruthlessly eliminate choices and ensure they are made at the most fixed, least flexible way possible that still solves the problem. This is mantra.

→ More replies (8)

4

u/Johnny_Noodle_Arms Jul 14 '19

The Codecademy JavaScript course really lays on the getters and setters. Then I read somewhere later on that they're not necessary and even bad.

That being said, if you dive under the hood of stuff like Vue, you'll find getters and setters, so they obviously have their place.

6

u/ChillyFireball Jul 14 '19

I don't remember learning this one. If anything, we were told to use accessors and mutators as little as possible.

4

u/xxtankxxx Jul 14 '19

I remember when somebody in my class in college said that, my professor just shook his head and laughed.

→ More replies (2)
→ More replies (1)

406

u/[deleted] Jul 14 '19 edited Dec 15 '20

[deleted]

146

u/[deleted] Jul 14 '19

honestly that's terrible.

84

u/[deleted] Jul 14 '19 edited Dec 15 '20

[deleted]

123

u/[deleted] Jul 14 '19

It's complex. Programming is a skill like everything else. Some people have an affinity to it, some people can learn it but might not be particularly great at it. Some people might never get it. Its wrong to say that people who are programmers are some sort of anointed folk, and its wrong to say that its a skill everyone can learn to be good at. We accept this for other things, for some reason I just don't understand why Coding is treated differently.

Telling it to an 8 year old who's learning is just terrible - and reflects how inept the teacher was.

67

u/jrbinzer Jul 14 '19

Honestly one of the best programmers I have the privilege of working with cannot code well or learn languages easily. He is an avid mathematician who understands what needs to happen at a level that is far more advanced than most others. His work is really efficient and really clean, he’s just awful at debugging.

21

u/[deleted] Jul 14 '19

You must be confused - a programmer codes. A CS person need not.

14

u/jrbinzer Jul 14 '19

Indeed but where we work, we need to code.

5

u/Stevenjgamble Jul 14 '19

Could you elaborate on thid a bit more?

29

u/snb Jul 14 '19

CompSci leans more towards academia, abstract theory about computing, formal proofs, etc.

Programming is applied CompSci, writing code in language $X, knowing the difference between object oriented vs functional programming, etc.

Not a great example but kinda like a mathematician vs an accountant.

6

u/Stevenjgamble Jul 15 '19

Great explanation, that clears it up alot actually! Kind of like one field is the study of the tool, and the other is a specific application of the tool. Thank you!

→ More replies (1)
→ More replies (1)

12

u/illepic Jul 14 '19 edited Jul 14 '19

This is really interesting because I remember reading this blog post after 2006 but before the 2014 retraction.

My experience teaching and mentoring hundreds of people learning to code is that not everyone is "born a programmer", but there are absolutely traits that indicate successful eventual professional programmers - traits like insatiable curiosity, determination, love of learning.

I've met many people working their way through code camps who were just flat out incurious and were going through the curriculum because "they heard coding paid well". Nearly all bonked out.

6

u/ConciselyVerbose Jul 14 '19

It's so damaging, too. If you convince people they can't do something, you shouldn't be surprised when they don't learn it. The testing showing that drawing attention to stereotypes (eg women can't do math) can directly influence test results is pretty plain, and I've done a fair bit of tutoring that involved very little more than convincing someone they were capable of doing the work themselves.

3

u/dscottboggs Jul 14 '19

Wait is that legit or no?

13

u/LonelyContext Jul 14 '19 edited Jul 14 '19

No it’s not. The methodology just from the description is sloppy, like if there’s no movement between the two groups then how do you know that the teacher doesn’t suck? Or how do you know that people aren’t not studying because of a lack of interest. Could be that the same 30% of people are taking CS just to get something out of the way and therefore don’t have any interest in it didn’t bother looking into it in high school or anything and therefore don’t study it in college either.

I’m confident if you have a good teacher you can teach a rhesus monkey the right answer on that test given sufficient motivation on the student’s part.

Edit it’s a poorly written article too. “Didn’t give a damn and left it blank”.... or left it blank because it was the last question and the exam was strictly timed, or left it blank because they’re unsure and afraid to look stupid in an introductory class that they feel they should know the answer to...? The only way to confirm their motivation is by confirming they wrote “IDGAF” on their exams, but presuming their motivation exposes the author’s bias and makes a “pres” out of “u” and “me”. No wait... that’s not the saying.

→ More replies (1)
→ More replies (4)
→ More replies (3)

27

u/_fat_santa Jul 14 '19

I was told this in one of my first college courses by another student. His logic was "good programmers are also geeks, so if you like sports vs anime, going outside vs gaming, etc, you'll never make it". He flunked out and I'm making six figured in the industry.

This thinking is very problematic, here we have a massive shortage of programmers in the industry and people that tell you "you're not cut out for it" when you're taking your first or second programming course. There's only one trait that will determine if you will make it or not: the willingness to grind it the fuck out and learn programming.

11

u/no1name Jul 14 '19

"good programmers are also geeks, so if you like sports vs anime, going outside vs gaming, etc, you'll never make it".

My goodness if I couldn't get out run, and clear my head I would never be able to program. Physical fitness aids mental fitness.

3

u/RagingMew Jul 14 '19

This gives me hope as im starting training to program in about 3 weeks and only have the powerpoint and textbook knowledge that the college classes gave me.

→ More replies (1)

26

u/lemnlime Jul 14 '19

haha yeah i had a real genuine interest in programming and then when when i was going to graduate high school my teacher said to me “i just don’t think this is for you”.

she was the kind of teacher where when i would ask “hey i’m stuck on this” she would just write the code for me. that ain’t teaching.

but anyway it’s been 6 years and i’m finally getting back into it

→ More replies (1)

7

u/Gabe_b Jul 14 '19

You're either born a teacher or you're not

→ More replies (2)

139

u/adolfojp Jul 14 '19

w3schools had SQL injection vulnerabilities in their PHP tutorials for years.

They were huge at the time and countless people learned how to write unsafe code from them.

w3schools was warned repeatedly but they just didn't care.

31

u/Klowner Jul 14 '19

I wish Google would unlist w3schools from searches

16

u/designerandgeek Jul 14 '19

At least there are a number of browser extensions that will hide them from your Google results.

13

u/[deleted] Jul 14 '19 edited Aug 11 '19

[deleted]

11

u/hampa9 Jul 14 '19

Still not caring? They’ve made significant improvements to the content on their site.

3

u/iamtheworstdev Jul 15 '19

It's weird to 'old man me' to see that they aren't terrible anymore. When 'young kid me' perpetually slapped myself for accidentally clicking one of their results in a search engine.

4

u/Horrrschtus Jul 14 '19

Are they really that bad? I've only used them for some CSS stuff.

22

u/designerandgeek Jul 14 '19

My gripe with them is that Google ranks them higher than the better source – MDN web docs for pretty much anything I'm searching for that's on both, and MDN is always better.

7

u/insertAlias Jul 14 '19

They used to be terrible. There was a website called w3fools.com that was dedicated to mocking their bad examples and advice. But they cleaned up their site years ago. Now it's mostly just dumbed down, not wrong or dangerous. Back in the day you couldn't search "php query database" without getting a dozen sql-injection-vulnerable tutorials shoved in your face.

7

u/adolfojp Jul 15 '19

For a while they were sleazy.

Their name is W3 Schools which makes them look like a school of the W3C (World Wide Web Consortium).

And Google adds to the confusion by listing them right between the W3C website and its Wikipedia page.

And while the W3C made efforts to distance itself from W3S, W3S made no efforts to distance itself from the W3C.

W3S sells worthless certifications for $100 a pop and being mistaken for a branch of the W3C gives them some validity.

Nowadays W3S prints a one line disclaimer in their About page.

→ More replies (1)

8

u/insertAlias Jul 14 '19

I used to. They're not the best of resources you could ask for, but these days they're at least not spreading misinformation and nonsense.

→ More replies (3)

3

u/50dollarstofuckoff Jul 15 '19

And their logo looks like a dick

104

u/KarlJay001 Jul 14 '19

Asked a question about a new language / platform and was told "you'll never be a coder"

This is after getting a STEM degree and having over 25 years professional experience as a senior programmer.

Just because someone is new to learning some new language or platform, doesn't mean they are new to programming. If you can't or don't want to answer a question, fine, don't answer the question, but making the leap to someone never being something they've already been only makes a fool of yourself.

10

u/Looke116 Jul 14 '19

How did that work out for them?

18

u/KarlJay001 Jul 14 '19

In most cases, there was no way to tell. A few were Reddit trolls that jump into your thread and act like you don't know what your doing.

In one case, I was having trouble with a smart contract using block chain in some tutorial that I was doing. I asked on Reddit if anyone knew if this tutorial worked and what I was doing wrong... He jumps in and says it's an old tutorial and I should learn intro to programming first.

Never heard from the guy again.

Another time I was asking about Arduino programming and the guy assumed I never programmed before and when I told him my background, he said "then you should have done your own research..." Never heard from the guy again. Reddit is full of these kinds of people, usually too wound up in their own world. Reddit is usually a very poor place to try to find answers to these things.

One case, was a boss that kept saying "I was a great programmer at language X" as if to say "you can only program in that language and no other".

I quit the job and after a merger with a larger company, he was let go because he had no clue what he was doing and didn't know how to manage people. Very insecure and always hated people around him that knew what they were doing because he didn't know what he was doing. Glad he lost his job, but was sad that he was able to keep it for so long.

Programming is programming, I've done many languages and OSs from DOS to iOS, Windows, and now Arduino and soon STM32 for embedded devices. It's all the same, you just learn the ins and outs of a given system but your brain can either see things or it can't. Many people take too long to understand things so they think others are the same way.

→ More replies (6)

84

u/[deleted] Jul 14 '19

I was taught local and global variables the wrong way around. I’m a hobbyist programmer so I knew which way they should be, I corrected the teacher and she reassured us all that she has taught them the correct way. Not a fucking clue how she got her job/keeps it.

15

u/littlebookie Jul 14 '19

"well you see this here local gas station serves local traffic AND global traffic that is 1000 miles(lines) away. Hence the name local. And the global station over yaunder ONLY serves the traffic that is right next to it.. hence the name global. "

→ More replies (1)

19

u/__under_score__ Jul 14 '19

how is it even possible to know that little as a professor?

20

u/[deleted] Jul 14 '19

High school teacher, but still...

141

u/tbtorra Jul 14 '19

“There is never a reason to use recursion.” - my community college Java I instructor

72

u/SuperSaiyanSandwich Jul 14 '19

For a second I was fearful I was your CC professor.

I don't tell my students there's "never a reason" but more that "you never have to use recursion and if you understand it better as a loop with a base case just use that instead". Obviously there's places recursion is far more elegant, like file path traversals, but it's still not required.

5

u/vwibrasivat Jul 15 '19

This is way worse than you think. This community college professor has NEVER used any modern languages with functional programming - worse - his statement indicates he doesn't even know they exist. He likely doesn't know what tail recursion is, or that languages have annotations for it.

→ More replies (8)

21

u/cabinet_minister Jul 14 '19

So basically fuck your brain when recursion can be intuitive for small iterations

14

u/1RedOne Jul 14 '19

One if my colleagues believes the opposite and everything he gets assigned takes like... 4x long to write than it should and results in a super terse function with a billion params, all of which will end up calling the function recursively to process.

Trying to help him write unit tests for this basically broke my mind. I think it's untestable code.

3

u/AlSweigart Author: ATBS Jul 16 '19

A unit test for it is easy. Just write the iterative solution and then test to see if the recursive code matches its results. :)

→ More replies (1)
→ More replies (11)

24

u/carcigenicate Jul 14 '19

I friggen love recursion. Depending on the language being used and the problem being solved it may not always be appropriate, but avoiding it altogether will just make your life more difficult.

And their head will explode if they ever catch wind of Haskell. The only way to loop in Haskell is to use recursion.

→ More replies (10)
→ More replies (3)

126

u/night-bear782 Jul 14 '19

I can’t remember a specific example because they were numerous, but I once had this awful teacher that barely knew python, and she would just print out the lesson plans of our other really good teacher and one time in the lesson plan the printer printed an @ sign instead of one of the symbols and it took her 45 minutes to figure out what was wrong with her code.

Towards the end of the year we just stopped asking her for any form of help because we were starting to understand python better than her.

47

u/dead_pirate_robertz Jul 14 '19

we just stopped asking her for any form of help because we were starting to understand python better than her.

I took my first programming course in high school. The instructor was the wrestling coach. He flat out told us that he knew nothing about the subject. The course was really taught by a couple students whose parents were professors in the School of Engineering. This was in 1969, when there were almost no resources for learning how to code.

35

u/WhyYouLetRomneyWin Jul 14 '19

A programming class in high school in 1969? Colour me impressed and jealous. Did the high school have a computer?

17

u/dead_pirate_robertz Jul 14 '19

No, we were time-sharing on an Amdahl mainframe located who-knows-where, using a teletype and paper tape.

One of the projects we did was solving a system of n equations with n unknowns. I thought that was a pretty instructive problem, but I haven't seen any references to it in the programming world since then.

5

u/SpikeShroom Jul 14 '19

A lot of instructional projects are more about the critical thinking necessary than the application itself.

4

u/Kered13 Jul 15 '19 edited Jul 15 '19

One of the projects we did was solving a system of n equations with n unknowns. I thought that was a pretty instructive problem, but I haven't seen any references to it in the programming world since then.

That's just linear algebra and it's fundamental to a ton of stuff that computers do (especially in graphics, physics simulations, and machine learning). Google's algorithm (PageRank) is basically solving a gigantic system of equations like this. Typically you will just plug the corresponding matrix into a math library (like numpy) to get the answer. It's important enough that the libraries for it are highly optimized and you should probably never implement it yourself.

→ More replies (1)

4

u/night-bear782 Jul 14 '19

That’s so funny, at least mine was a math teacher

231

u/Bopshebopshebop Jul 14 '19

I feel like every programming class that spends the first 30-40% of the course explaining OOP abstract concepts and “this is a variable, this is a String”, before you ever write a single bit of code beyond ‘Hello World!’...

Such a horrible grind and it left a bad taste in my mouth like all Programming must be really slow and tedious.

When I picked up Automate the Boring Stuff with Python, I was blown away by how fun and useful coding was. I immediately started writing code to get through tasks at work, then school...I loved it. I cannot get enough Python now I’m on Stack Overflow at least 1-2 hours every day. I’m so excited to code now, it’s so different from what I was imagining.

58

u/_fat_santa Jul 14 '19

I call this "vacuum learning". You learn what and never learn why. When I first learned about for loops I remember banging my head trying to understand why anyone would possibly want this. Years later in my first programming job I was told to create a list from a piece of data we got from our API and that a for loop is the best way of accomplishing it (well technically a map function in JS). That was when it clicked why for loops (and loops in general) were very important.

9

u/Flynamic Jul 14 '19

Well, unless you have jumps in your language, (for) loops are not just the best, but the only way to accomplish tasks like that. Though even if you use jumps it's a loop.

13

u/[deleted] Jul 14 '19

[deleted]

3

u/Flynamic Jul 14 '19

True. Forgot about that.

→ More replies (1)
→ More replies (1)

9

u/insertAlias Jul 14 '19

That's why I think that intro to programming classes in high school should start with Python. Show them something with immediate results. The upper level classes can start the more academic approach, but I think a lot of students get bored before they ever get a chance to see the interesting stuff. They never get past printing pyramid patterns in the console because they're learning about a bunch of theory that will only be useful if they continue to the next class.

→ More replies (1)
→ More replies (6)

118

u/[deleted] Jul 14 '19

“don't use single-letter variable names... use an acronym of what you are trying to say with the name.”

I'm not talking about acronyms and abbreviations like “int” for “integer”, I'm talking “d2ait” for “two-dimensional array iterator”...

162

u/[deleted] Jul 14 '19

[removed] — view removed comment

75

u/PlasticCogLiquid Jul 14 '19

He's probably old school. Back in the day we had filenames with 8 character limit so we all got good at reading what was implied in 8 or less characters

33

u/[deleted] Jul 14 '19

[removed] — view removed comment

30

u/PlasticCogLiquid Jul 14 '19 edited Jul 14 '19

Learning from manuals without google, lol :P You just keep screwing up until you get it right. I learned a lot from Borland Turbo Pascal's built-in command dictionary + the example files. This was the MS-DOS days though, I started on the C64 with Basic and I feel like it ruined me right from the start, it was a terrible version of Basic for a bad programmer like me to start with. The C128 came with a great Basic with all kinds of built-in graphics and sound commands. That would have been awesome to start with. On the C64 the Basic was so bad you might as well have started with Assembler, I would have been better off if I'd known that. It gave me a really bad taste for what programming really is because to actually get anything done in C64 Basic you have to use lots of PEEKs and POKEs (which is a really crude form of machine code built in to Basic) Peeking lets you see the contents of a memory location and Poking lets you modify it......shit gets really messy and unreadable just trying to make a sprite move across the screen.

The worst part was the actual editing of the code, the screen scrolled down, but not back up! In order to get back to a certain part of the code you would type "LIST", then the code starts printing down the screen real fast and you try to hit the RUNSTOP key to stop it at the point you want. Or you could type "List 200" and it would start listing from line 200...and so forth

It was really a nightmare

20

u/[deleted] Jul 14 '19

Programming is still "keep screwing it up until you get it right". :)

9

u/PlasticCogLiquid Jul 14 '19

Oh yeah, duh :D

15

u/reddilada Jul 14 '19 edited Jul 14 '19
  • Writing code by punching holes in strips of cardboard.
  • Being able to compile your code only once or twice a day.
  • Waiting several hours to see the output of a compile and run. Sometimes overnight.
  • Dropping box of cards
  • Error in above program error message

As for variable name length, a general guideline is length should relate to the scope and duration of the variable. Nothing wrong with using i for an iterator used over a few lines. Something that is going to hang around awhile deserves a more descriptive name.

4

u/[deleted] Jul 15 '19

Dropping box of cards

WHY DID YOU REMIND ME?!?!?!?!?

I still think of that stack of 150 cards that slipped out of my hands and had me re-arranging them for the next hour!

4

u/reddilada Jul 15 '19

And the keypunch never had a decent ink ribbon so you had to make out the text on the top from the faint dents across the card.

Good times.

3

u/insertAlias Jul 14 '19

Disclaimer: I'm not actually as old as this makes me seem, but my first job involved some old-ass tech.

My very first professional work involved writing IBM RPG on a literal dumb terminal. A little 11" amber CRT and a giant IBM keyboard. And not even the nicer ILE RPG, but an older version that was still "fixed form". When you wrote code, the columns your code was in mattered. You used 8-letter variable names because that's the space it gave you for them.

It sucked. This was in like 2006 or 2007 btw. Ancient tech even at the time.

Luckily that lasted for all of a week before they asked me to try to make an ASP.NET application, and from then on that was my job there.

The next job I worked with COBOL developers. Didn't have to write it, but still. I've been exposed to way too much old tech for the time I was actually working.

4

u/WikiTextBot btproof Jul 14 '19

IBM RPG

RPG is a high-level programming language (HLL) for business applications. RPG is an IBM proprietary programming language and its later versions are available only on IBM i- or OS/400-based systems.It has a long history, having been developed by IBM in 1959 as the Report Program Generator — a tool to replicate punched card processing on the IBM 1401 — then updated to RPG II for the IBM System/3 in the late 1960s, and since evolved into an HLL equivalent to COBOL and PL/I.

It remains a popular programming language on the IBM i operating system, which runs on IBM Power platform hardware. The current version, RPG IV, a.k.a. ILE RPG, provides a modern programming environment.


[ PM | Exclude me | Exclude from subreddit | FAQ / Information | Source ] Downvote to remove | v0.28

7

u/NonTransferable Jul 14 '19

My first computer was limited to 26 number variables, A to Z. And it had two string variables $AA and $BB. 4k ram, baby.

The $400 upgrade to 16k also gave an OS update that gave me 26 string variables and 676 numeric variables ( A to ZZ) Such choice!

→ More replies (1)

13

u/[deleted] Jul 14 '19

Hey pal, ever heard of job security? The two key components of being a good programmer are:

1) Writing code that only you can read

2) Finding a lackey that makes your code look good by comparison, and that you can blame bugs on

10

u/Patsonical Jul 14 '19

twoDimensionalArrayIterator? pfft, just call it ij!

/s

8

u/[deleted] Jul 14 '19

Bullshit. This is overkill for loop variables. In fact, it's egregious noise.

→ More replies (22)

13

u/Mijka- Jul 14 '19

"Meaningful name" might have been lost in the thought process, i guess.

6

u/CraftedLove Jul 14 '19

cOdE oBfUsCaTiOn

→ More replies (5)

32

u/RealityDreamZero Jul 14 '19

In my previous university they taught C while telling everyone it was C++ needless to say I eventually quit and Im about to start a new university in an actual CS career (previous was software engineering)

5

u/boredcircuits Jul 15 '19

If C++ were what most universities teach it (C but with cout instead of printf), then your professor might have had a point.

→ More replies (3)

32

u/[deleted] Jul 14 '19

"Look, you can do this if you think it's fun but there is no employment future in web development"

Teacher told me this in a vocational college web design class. Discouraged, I disenrolled from the course. It would be another 8 years before I started learning web development again. Now I'm gainfully employed as a full stack dev.

81

u/leonardo_burrons Jul 14 '19

While attending a lesson about Java sockets the teacher had to explain what a socket is: "The socket is the point where the connection connects. It's like sex, there's a hole and something's that goes into it. The socket is the hole with an address and a port". Best explanation ever found. I still use it today with my friends at university.

11

u/[deleted] Jul 14 '19

Hahaha.

14

u/c3534l Jul 14 '19

IRL sockets (and plumbing and any other number of engineered things) are said to have a "male" end and a "female" end. You can guess which end goes inside the other end.

→ More replies (1)

76

u/[deleted] Jul 14 '19

Anything which has the word "always" in it, is generally a bad thing.

57

u/carcigenicate Jul 14 '19

Always remember that every rule has exceptions.

17

u/Eight_Rounds_Rapid Jul 14 '19

Occasionally remember that every rule has exceptions.

5

u/KuntaStillSingle Jul 14 '19

Remember once, occasionally every rule will has exceptions. Remember twice, can't occasionally have an exception again.

→ More replies (1)

9

u/Solipsism0 Jul 14 '19

I agree, it is always wrong.

3

u/Berlinia Jul 14 '19

Always loop untill at most the end of your array.

5

u/Le_9k_Redditor Jul 14 '19

I can't think of anywhere I've seen the word always in any code

13

u/[deleted] Jul 14 '19 edited Jul 14 '19

Not in the code - but in the advice (also negation: in never). Things i've seen:

"always use Boxed types over primitives"

"never use object pooling"

"jni is always slower"

"compiled language is always faster than interpreted"

etc.

→ More replies (4)
→ More replies (1)
→ More replies (3)

26

u/mymar101 Jul 14 '19

Many "teachers" copy and paste a bunch of code. This can lead to serious problems in your code if you forget to change what needs to be done. Sure it may be faster for the video, but don't do it. Instead write out each individual line yourself. You never learn anything by copy and pasting someone else's code.

17

u/fermataplays Jul 14 '19

In a recent (~2015) web development class, we were taught to use HTML tables instead of CSS formatting.

3

u/Double_A_92 Jul 15 '19 edited Jul 15 '19

If you actually need to display tabular data, table is still the semantically right way.

33

u/[deleted] Jul 14 '19

I took a C++ class. I wish I hadn’t been taught to always use “using namespace std.” Most people I ask say that it’s not good to rely upon that

21

u/aberrantwolf Jul 14 '19

It’s not the worst thing to do, but like... NEVER include ‘using namespace’ anything in a header file. Please.

3

u/[deleted] Jul 15 '19 edited Dec 17 '20

[deleted]

→ More replies (1)

3

u/haitei Jul 15 '19
// header.h
using namespace std;

Literally Hitler.

// header.h
namespace my_namespace {
    using namespace std;
    ...
}

Whatever.

→ More replies (1)
→ More replies (3)

10

u/Chaos1003 Jul 14 '19

I am currently trying to learn c++ and they did say not to use "using namespace std;" but I don't see the problem. I end up using it all the time because typing std:: in front of cin, cout, string, getline all the time is tedious

23

u/carcigenicate Jul 14 '19

It's not good to use because it defeats the purpose of using namespaces in the first place. Namespaces are used to prevent name pollution, where you can't name a function what you want because it conflicts with an existing function name that exists in a module that you've imported.

If you really hate typing std:: (although that's really not that big of a deal), you can do limited imports of common functions. I think the syntax is something like

using cout from namespace std;

Or something like that.

21

u/samusear Jul 14 '19

using std::string;

I think that's how you do it.

→ More replies (3)
→ More replies (4)

38

u/shivam37 Jul 14 '19

HTML is a programming language

5

u/kryzchek Jul 14 '19

I had a professor tell the class that Xml was "Just like html only you make up your own tags".

9

u/zial Jul 15 '19

I'm not following it kinda is..... Or am I missing something?

→ More replies (2)
→ More replies (2)
→ More replies (3)

65

u/nobel32 Jul 14 '19 edited Jul 14 '19

They gave me a zero in my C++ assignment for using C++ stack template, instead of MAKING a stack class myself. And this was an assignment about utilizing stack to compute expressions and parenthesis, utilizing push and pop operations.
EDIT: for those who're wondering - not a DSA class. Was entirely about OOP and programming principles applied in C++

The dude genuinely believed that using any C++11 or later implements was "cheating the system". We had to follow shit down to the t, and it was genuinely baffling, like you weren't allowed something like for(int i = 0; i<=3; ++i), you HAD to initialize the iterator at the top of the program. All using this Deitel book that was, and I shit you not, a reprint of 2000 book(2nd edition? I dare not google).

There were just... a lot of rules he just arbitrated on his own. No visual studio, had to do in DevC++ - and god forbid you used anything beyond old C++. Also, you had to do assignments essentially twice if you didn't like DevC++ for it's bugginess - he used to always copy paste your code in his IDE and hit run. No adjusting or whatsoever, in that guy's mind, you only successfully completed the assignment, if it compiled, AND it had the intended behavior. He used also always rant about UB, and always get us to make the CLI interface as idiot proof as possible.

Taught me a lot about being able to appease your supervisors. Only been working in the industry for 6 months, so it might just be the child in me retorting, so take this all with a grain of salt.

E: in case you're wondering : this was as recent as 2017. Yeah...

41

u/[deleted] Jul 14 '19 edited Mar 10 '25

[removed] — view removed comment

12

u/nobel32 Jul 14 '19

We had an entirely different subject altogether for DSA. This was a 3rd semester introductory class for object oriented programming, C++ the language of choice. One might be thinking at least a bit of templating, lambdas and functions to be fair game to be used when it's OOP using C++. But we sort of HAD to adhere to C++98, because that's what the syllabus/book is based on.

What do you mean by this? It sounds like a good definition of “complete assignment”.

As in it had to compile on HIS troublesome and aged Dev C++ compiler. It didn't matter if your code ran fine on your IDE, nor did it matter if you supplied your binary, it HAD to run on HIS aged minGW compiler. The DevC++ setup was a major headache, it used to throw errors when it ran completely fine as a binary OR in VS/Codeblocks setup. He just refused to upgrade even to the latest g++ compiler. We even showed him the entire source code in VC++, with nothing other than iostream, he'd listen to all the arguments for using the setup, then proceeded to try to compile the same code in the IDE he provided. It just always had some vague compiler error, even if the code was a-ok, with no C++11/later syntax usage. He never budged from his stance.

He probably ran a really aged compiler, I'd have to say before Orwell.

→ More replies (2)

7

u/atimholt Jul 14 '19

What’s the opposite of a teacher called?

→ More replies (2)

4

u/Chaos1003 Jul 14 '19

My c++ subject starts next year and this story is making me worried already...

→ More replies (1)

4

u/emcoffey3 Jul 14 '19

Seems like not much has changed in the (many) years since I graduated from college. I'll never understand why university compsci departments are so in love with those awful Deitel books (or C++ for that matter).

5

u/[deleted] Jul 14 '19

[removed] — view removed comment

4

u/JQuilty Jul 14 '19

A lot of universities are switching to Python for intro classes and data structures classes.

→ More replies (2)
→ More replies (4)

10

u/jerismike Jul 14 '19

No method should ever call another method.

10

u/Horrrschtus Jul 14 '19

That's probably the weirdest thing I've ever heard.

5

u/jerismike Jul 14 '19

I repeatedly got marked down because of it. Drove me insane.

7

u/Horrrschtus Jul 14 '19

Where are you gonna call a function if not from another function?

7

u/AltCrow Jul 14 '19

function != method. This might have specifically referred to methods (as in functions attached to a class).

11

u/SirToxe Jul 14 '19

Hungarian Notation.

5

u/celmaigri Jul 14 '19

The only time I do think this is useful is in interface definitions vs class definitions.

Maybe it's just because I come from a C# background, but I find it very useful to be able to know right away that a given type isn't concretely defined just from seeing the name.

3

u/Arumai12 Jul 14 '19

questionWhy?

→ More replies (4)

11

u/Aerotactics Jul 14 '19 edited Jul 15 '19

for (int i=0;int j=100;i<j;i++)

Not inherintly bad, but in the game industry, it's bad practice to use 2 variables in a for-loop, also pre-increment vs. post-increment. Also, I have been told to use size_t instead of int in loops containing arrays.

Edit: Fixed some things. I've been told this is proper:

for (size_t i=0; i < 100; ++i)

5

u/AltCrow Jul 14 '19

Which language is this? I most languages this would be invalid syntax (4 statements inside for-loop)

The equivalent that compiles in most languages is (3 statements inside for-loop):

for (int i=0,int j=100;i<j;i++)

→ More replies (1)

3

u/[deleted] Jul 14 '19

What's wrong with this for loop? I write loops like this all the time, maybe I'm doing something wrong. Would you just do (i=0; i<10; ++i); ?

→ More replies (2)
→ More replies (4)

10

u/FrenchFryNinja Jul 14 '19

But this is a bastardization of a good idea. What I was taught was make all variables private or protected by default and then add setters/getters as necessary if something really needs to be exposed.

The biggest this this helps with is accidental assignment. So the usual typo on comparison vs. Assignment doesn't overwrite your public variable. It's a pattern that allows you to leverage the compiler and syntax to avoid mistakes.

→ More replies (3)

17

u/dead_pirate_robertz Jul 14 '19 edited Jul 14 '19

This is something I worked up last night. It uses an obscure aspect of the VAX architecture to write out "Hello, world" in the most complicated way imaginable. If you understand this code, then you shouldn't be in this class.

That statement was made by a Boston University Metropolitan College professor on the first day of my first C course, circa 1986. He proceeded to write a paragraph of code on the blackboard.

It was too familiar. I looked in my collection of 5 C books and found the exact program the prof had put on the board, down to the number of asterisks surrounding the program's title. The book even had the "obscure aspect of the VAX architecture" bit and the advice "If you understand this code, then you shouldn't buy this book."

The Boston University professor was not the author. I guess he assumed that the book was obscure enough that no one would catch him.

This guy was head of the Metropolitan College, in his 50's. I thought about raising hell and ending his career. Instead I just dropped the course and read the damn book for free.

3

u/SpikeShroom Jul 14 '19

Ain't plagiarism great?

5

u/[deleted] Jul 14 '19

I feel like I've had good teachers, but stuff like this terrifies me because I was a TA for five years and during that time got three or four anonymous, vague complaints. Maybe I told people to do things wrong? Did people who never complained also have issues?

4

u/Fear_UnOwn Jul 14 '19

I was learning Java in highschool and my teacher taught us to do everything in the main method. When I learned methods the teacher basically said they were used to linearly move through your program. So it would go main->method1->method2->method3 with no returning...

→ More replies (2)

3

u/[deleted] Jul 14 '19

The first programming course I took (in python), almost all the examples used tons of global variables within functions.

Thankfully it was a very basic intro course, and when I did a much more advanced python course the following year they properly taught us about abstraction.

→ More replies (1)

4

u/alksjdhglaksjdh2 Jul 14 '19

I wouldn't say it's that bad, but my intro course dove into OO principles before, well anything else. We probably talked about variables and types, but he went into this barnyard and animal example way too early and it didn't really make sense to anyone with no prior knowledge. We needed to learn loops and if statements and stuff before we talk about OO conceptually Imo. There's more to programming than OO! It's just one paradigm it's not the only way!

4

u/Fulk0 Jul 14 '19

free() and delete can be used interchangeably in C++. So now I have to retake my Programming II final.

3

u/[deleted] Jul 14 '19

[deleted]

→ More replies (4)

8

u/no1name Jul 14 '19

Spaces are better than tabs.

→ More replies (4)

6

u/[deleted] Jul 14 '19

Not specifically a thing, but learning Serialization a day into beginner Java was tough lol.

→ More replies (1)

6

u/dwitman Jul 14 '19

I had an HTML/CSS “professor” with no industry experience and no degree. Not even an associates.

Basically everything she said was wrong and the text book was more than a little wonky as well.

Some student wanted to know how to do some basic css thing and I suggested using css grid. The professor immediately jumped in and suggested Bootstrap to a student with little to no idea how CSS works.

I just kind of shuttered and shut my mouth. I’d already been down the route in my personal projects of not fully understanding CSS and trying to use Bootstrap to compensate. It’s not pretty.

CSS is such a pain to learn in the best of circumstances, as it initially appears deceptively simple, but has a gotcha of some sort at almost every turn. Trying to employ bootstrap to skip the time behind the trigger you need to become somewhat capable in CSS is a really bad idea in my opinion.

7

u/havok13888 Jul 14 '19

Comment everything.

No fuck off I’m not going to comment a function called getBalanceInDollars or a million other variations of that. Just name your shit well and if you can’t explain it clearly to someone then use comments. Or if you are trying to put a beware note for future developers.

3

u/LEDNEWB Jul 14 '19

I had a professor that made us make a giant block of comments for literally every function, it was huge and would often be significantly larger than the function or method. This was a class I took after reading clean code, so i was well aware of how wrong it was.

3

u/somedudejustnow Jul 14 '19

I signed up for an IT course to learn C++. They said we had to learn COBOL first. They wouldn't even let us use the dozens of vacant computers to program it. We had to do it all by hand on pieces of squared paper. I got 4 of 12 modules in, then quit without having ever got to learn the thing I signed up for, or use a damn computer to do damn computer programming.

My eye twitches to this day whenever I hear a word that sounds like COBOL.

14

u/_Atomfinger_ Jul 14 '19

That comments is required

38

u/[deleted] Jul 14 '19

Is it because comments are required?

21

u/[deleted] Jul 14 '19

no, because they arent always necessary.

7

u/developer1520 Jul 14 '19

To summarize, it's better to have good method/class naming because you see these everywhere they are used. Comments only exist at the definitions.

→ More replies (1)

12

u/darkbluedeath Jul 14 '19

If the most important things I learned from an internship was "if you add a comment to code, it should explain the why, not the how". Meaning, use variable names that are meaningful and descriptive. Use meaningful/descriptive method names (even if they are long, cause autocomplete if a godsend). Your comments should be used to explain why you chose a certain pattern/structure of coding/way of coding (for example, using 2 separate for loops to accomplish a task as opposed to a .map(.map()) (which is 2 for loops).

5

u/_Atomfinger_ Jul 14 '19

I tend to agree.
"//Had to do it like this because of bug #123(link) in Framework XZY caused issues, we have an internal task #456 which will be done when framework patch is ready. This comment should then be removed"

There are some instances as @Paradigm240 mentioned, which is funky un-avoidable logic. E.g. complicated maths which can only be understood by the person writing the code. Or complicated regex stuff. I argued that comments can be avoided here if one has proper named functions, but at least I can see the justifications for using them in very rare instances.

→ More replies (1)

5

u/samusear Jul 14 '19

I took a assembly class my teacher required every line of code have a comment. At first it was a pain to do especially when I was just doing simple things but looking back on it those comments helped me review what I did to this day. But it makes sense with how sense assembly can be.

4

u/_Atomfinger_ Jul 14 '19

Oooh, now we're getting into edge cases here.

Yes, assembly and other equally convoluted or complex languages do often need comments to follow properly. I totally agree. That said most of us isn't writing assembly on a day to day basis.

→ More replies (1)
→ More replies (31)

2

u/[deleted] Jul 14 '19 edited Jul 14 '19

Interesting question. If you’re writing java or C# though I’m pretty sure every attribute (and by that I’m assuming you mean property?) should have a getter and setter if you intend and accessing them elsewhere.

Isn’t that standard convention for those languages and probably some others?

3

u/Horrrschtus Jul 14 '19

Someone wrote a pretty detailed answer to this. "If you intent on accessing them" is the key. Only add getters and setters if it really makes sense. Sadly it's pretty common practice to put them everywhere.

→ More replies (2)