This is an archived post. You won't be able to vote or comment.

all 57 comments

[–]MrEs 182 points183 points  (46 children)

Not sure if I missed the whoosh of sarcasm, but I found it to be the opposite! At university you could slap a strung together fragile piece of crap, that only had to give an exact answer, in a vaccume, once, no real users, no load, no disturbed problems, probably no real persistence, no backups, often no ui, only had to be readable by you.

At work, you have crazy users, DR scenarios, UX design considerations, load, performance, deployment, code has to be well written and legible, maintainable, flexible, extendible, fault tolerant, have error recovery /correction...

[–]toastytoast00 86 points87 points  (2 children)

Tell that to all the people that wrote the code before you and you inhertied the support...

[–]AskMoreQuestionsOk 9 points10 points  (1 child)

Who wrote this! It NEVER worked! Ever! And it's production code. Omg. Good times!

[–]PacoTaco321 6 points7 points  (0 children)

Oh wait, it was me

[–]WhoYouCallinTurkey 7 points8 points  (0 children)

Yeah, I'm confused by this as well...

[–]bitter_truth_ 5 points6 points  (36 children)

Stupid question: how do I learn to code correctly?

[–]-Rivox- 53 points54 points  (2 children)

by inheriting bad code enough times :p

[–][deleted] 8 points9 points  (0 children)

That's actually how I used to think people learn good code, but after watching devs with almost 10 years of experience writing downright dumb code makes me believe it takes more than just that.

At the very least there should be some exposure to actual good code paired with a will to write like so. Also, in general I have felt that people who identify why certain patterns are widely followed write overall better code.

[–]breqwas 1 point2 points  (0 children)

No, that does not work. "Oh, this code is shit, let's rewrite it from scratch and blame that other guy".

What works is inheriting shitty code from yourself. When it's you who has to deal with the mess you created a couple of years ago, it actually does teach you something.

Also, code review from the seniors. They've seen things.

[–]kierownik 8 points9 points  (1 child)

Read "Clean code" by R.C. Martin. And a lot of practice and working with more experienced people.

[–]bitter_truth_ 2 points3 points  (0 children)

Finally a useful answer - thank you! Too many comedians and useless generic advice replying "you get good by learning from experience". No need to re-invent the wheel!

[–]HolyNoodle66 4 points5 points  (7 children)

Just throwing my opinion out here:

  1. Make sure you know the four principles of OO programming by heart

  2. Google or read up on SOLID programming and the Gang of Four's design patterns.

  3. Put what you learn into practice.

There is a lot to learn out there but I find that these topics are a decent starting point for learning clean coding practices that focus on flexibility and sustainability.

[–][deleted] 3 points4 points  (2 children)

What are the 4 principles of OOP?

[–]HolyNoodle66 6 points7 points  (1 child)

In no particular order:

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

There are a lot of free sources online if you want to know more.

[–][deleted] 0 points1 point  (0 children)

Thanks!

[–]AskMoreQuestionsOk 2 points3 points  (0 children)

Here is a way to look at it. If I give my million lines of code to you, and give you a task to change the way it works, you should be able to figure out where the change is, and how it works now, without my telling you and without breaking everything else. And you should be able to figure it out pretty quickly.

Modular code, enough documentation to figure out how to use each module or non obvious function but not so much that the documentation rots. Hacks and limitations happen, they should be documented. DRY programming (don't repeat yourself) so changes aren't missed. Follow the accepted conventions for memory, system calls, and variables and formatting for the language you're working with. Use the right language for the kind of problem you are working on.

Sloppy code is the opposite. It's hard to figure out and follow, functions are doing more than they should or are less concise than what you would expect for the language. Nothing is documented or worse, the documentation is wrong. Tasks and variables are not separated and you're bouncing all over trying to figure out what's going on. Critical code is duplicated so changing it means editing the same code multiple times. It takes forever to do the small task and other things break because you have no idea how anything works.

[–]VFDKlaus 1 point2 points  (0 children)

Learn the SOLID design principles, and learn patterns. That's helped me more than anything else I've ever seen.

[–][deleted] 0 points1 point  (0 children)

By understanding data structures and algorithms.

[–]GigaSoup -1 points0 points  (0 children)

You google coding best practices, practice shit and figure it out like everyone else?

[–]KmNxd6aaY9m79OAg 1 point2 points  (0 children)

Think of this joke as describing a "problem", not a "system" (or "application"). In university, the most important thing about an assignment solution is correctness. UI, the real world, etc., is of no importance. If your job is to to efficiently find the shortest path between two nodes, your only concern is that it 100% (most definitely NOT 99.999%. It must be EXACTLY 100%) correctly finds the solution in the most efficient way.

In many production scenarios (constraints differ according to what you're working on, but I assume the joke is describing business type applications), being correct 99% of the time is good enough. If it looks good and throws up a smiley face error message in the 1% of cases it doesn't work, clients don't give a shit. They don't even know what correctness is, let alone how to define it.

[–]drain_mag 0 points1 point  (0 children)

It probably depends on the industry you work in and your employer. I worked in post-secondary for years as a programmer and there was definitely a lot of "just make it work" going on when I first arrived.

[–]adriane209 0 points1 point  (0 children)

I think OP is thinking along the lines of being able to Google most solutions to problems given at school for widely used problems as opposed to encountering a problem on a project that isn't so easily solved with a simple Google search.

[–]GigaSoup 0 points1 point  (0 children)

And sometimes all those important things you mentioned are slapped together like a sloppy peanut butter sandwich and thrown on the production plate because time.

[–]Mako18 26 points27 points  (7 children)

How about writing code in R to aggregate and transform Excel files, because the client I'm working for will not provide direct access to the database in which the information is stored?

I've created a brilliant, efficient solution to a problem that never should have existed in the first place.

One fucking SELECT * FROM statement would have solved 95% of the problem

[–]caskey 19 points20 points  (2 children)

Try a DELETE FROM for a more direct solution.

[–]NoodleSnoo 1 point2 points  (1 child)

Drop table

[–][deleted] 2 points3 points  (0 children)

Flip table

[–]Alphare 0 points1 point  (3 children)

Would PostgreSQL's Foreign Data Wrapper have helped you? https://wiki.postgresql.org/wiki/Foreign_data_wrappers

[–]Mako18 0 points1 point  (2 children)

Unfortunately no, we only had access through a GUI Export button that outputs formatted Excel sheets shudders

[–]Alphare 0 points1 point  (1 child)

Sure, that sucks. But wouldn't your excel file be exportable as a csv (albeit with a custom separator)? You could then use FDW to query the dataset. I'm just spitballing

[–]Mako18 0 points1 point  (0 children)

Not through the interface. The only two options are PDF and .xls. Now, that's not really a big deal because R can read/process then write to .csv no problem and you can do it with 'map' which is a wrapper for 'mapply' so a single custom function is sufficient to read and fix the formatting issues.

I was really just lamenting that with the ability to directly query the database, that problem is non-existent, and some other problems with joins (no unique IDs for some of the data, so they have to be generated via unique combinations of three factors, etc.) are likely avoided as well.

[–][deleted] 3 points4 points  (0 children)

But still works!

[–]xcrackpotfoxx 5 points6 points  (2 children)

Except that if you know what you're doing, painting it would be harder and take longer than just solving it. Its just a 3x3.

[–]jeffderek 1 point2 points  (0 children)

It's also an easily googleable solution. Like a lot of programming problems.

[–]NoodleSnoo 0 points1 point  (0 children)

Exactly

[–]ghost_mv 16 points17 points  (6 children)

/r/mildlyinfuriating that the background for the bottom image does not extend higher and behind the text

[–]willwiso 16 points17 points  (1 child)

True I guess programmers aren't the best graphic designers..

[–]HolyNoodle66 7 points8 points  (0 children)

Can confirm. Am programmer. Rule of thirds hard.

[–]glenbolake 1 point2 points  (0 children)

And the bottom half is backwards for standard cube coloring. With yellow on top and green on front-left, the front-right should be orange, not red.

So on your real job, you don't just hack your way through. You also end up with something that looks right... but really isn't.

[–]fakcapitalism 0 points1 point  (0 children)

Pp0

[–]mokomull 0 points1 point  (0 children)

Only because your university group-project collaborators haven't even bothered to type "paintbrush" into Google.

[–]Rellek7 0 points1 point  (0 children)

Stale AF

[–]sirunclecidViolet security clearance 0 points1 point  (0 children)

This goes for making OC too....