r/learnprogramming • • Mar 22 '22

Don't be that guy.

I just took over a project for a guy who left. Don't be this guy:

  • ZERO comments in your codebase.

  • One and two character variable names with no discernable pattern.

  • Comment characters used to comment out big chunks of code for no discernable reason.

  • No error checking.

  • Reliance on data files that you forgot to include or explain, going in to meaningless data frame names.

  • Making outrageous claims about how much your code improves things with zero baseline performance.

People like this think you're an idiot because you can't make their code work, and get to be all smug. We will track you down and find you. You will need references someday....oh my.

2.6k Upvotes

427 comments sorted by

View all comments

174

u/lolitoxico Mar 22 '22

For all learners here, most of the time :

Readability > Performance > Short code.

Learners in school often brag about writing the same program than their classmates with less lines

And sometimes those learners get hired and still have this habit.

don't

56

u/[deleted] Mar 22 '22

something like

char (*(*x())[5])()

26

u/WhoTouchaMySpagoot Mar 22 '22

Is this for real? And if it is what does it do

10

u/brutexx Mar 23 '22

Guess we’ll never know

0

u/[deleted] Mar 23 '22

[deleted]

3

u/WhoTouchaMySpagoot Mar 23 '22

You’re the man

3

u/[deleted] Mar 23 '22

It declare x as function returning pointer to array 5 of pointer to function returning char

1

u/WhoTouchaMySpagoot Mar 23 '22

I’ve only had one semester of c programming and after that never really much used it. Is this something you would use in real life?

2

u/[deleted] Mar 23 '22

Sure. I copied that code from one of the project at my workplace(I’m a C++ developer).

1

u/arnitdo Mar 23 '22

Look it up on cdecl

1

u/BeardSprite Mar 23 '22

I c char and I leave.

1

u/pekkalacd Mar 23 '22

Beautiful

1

u/KaoIo Mar 25 '22

I knew how to read this I promise

28

u/Independent_Feed5651 Mar 22 '22 edited Mar 22 '22

This.

Code which is easy to understand and easy to change is the most important rule.

That doesn’t mean trying to “future proof” your code with additional tech debt. That doesn’t mean adding unnecessary comments. It means laying your code out in a way which allows a newcomer to understand what you’re doing almost instantly… via: layout (project files and class layout) and naming (files, classes, functions, variables).

Performance seems important.. but if you build an app in a semi-intelligent way, most performance gains can be had using simple data structures which can be inserted in later if necessary.

Also.. my pet peev: using design patterns which over-complicate and over abstract a simple app. If a majority of devs think your design pattern choice was unnecessary.. then it was.

1

u/psioniclizard Mar 23 '22

Hahah I agree on design patterns! They are great but also not. When working in C# I'd use them all the time and they did help (I think), but my god so much abstraction! Now I work in F# everything is just cleaner and I don't need as many layers to achieve what I want.

My point is it's important to realise what design patterns bring to the table, does it actually help or is it making up for issues in the language?

11

u/[deleted] Mar 23 '22

according to upvotes on leetcode:
Short code > Performance > Readability

1

u/Campes Mar 23 '22

Facts. Fewer lines of code doesn't always make code more readable and clean.