The thing about computer programming is that it’s a complete pain in the ass when you’re trying to figure out the problem, yet when you finally solve it, when you finally have that aha moment, the feeling of accomplishment is unlike anything you’ve felt when you’ve accomplished something. You think holy shit, I can make technology work, and that feeling is totally worth the long stretch of hours or even days when computer programming feels like a pain in the ass.
I had this post sitting on my drafts for a few weeks, so I decided to make it pretty and post it. Enjoy!
what my teachers told us.
Take 10 minutes, 20 or even 30, whatever you need and think about which design
pattern (if any) is appropriate for what you are going to code. Really think
about it, you’ll be glad for those “wasted” minutes when you have to change or
add something on the code and it only takes you 30 minutes instead of 5 hours.
Seriously, there’s nothing worse than check your own code two months later and
don’t remember what it does. Comment everything important, avoid really obvious
Use spaces. Separate your code in blocks by functionality. Read Clean Code by Robert C. Martin, it’s
really useful. Also, follow whatever convention/standard the code has (like the
Java Code Conventions), especially if it’s a shared code.
Refactoring is your friend.
Nobody likes those looooooooong methods with
tons of lines. Usually (almost always), that means you’re mixing functionality.
Separate the code in more manageable methods. It also helps to make the code
more reusable… which lead us to 5.
5. DO NOT
COPY AND PASTE CODE. →
If you have the same chunk of code twice or
more times, you’re probably doing something wrong. Read no. 4.
It’s always funny to name your int variable “elligent”
or your char, “mander”; but that doesn’t say anything about what it is for.
Test, TEST, test, tEST. Also, test as you code. Don not wait until you’re done
with the program to test it or you’ll regret when you find a giant bug you don’t
even know where it came from.
Automated testing is usually worth it. It also helps to save a lot of time with
retesing and regression testing.
my first year, I used to think that I could manage without knowing how to do it
and by printlning every time I had a problem. Wrong. Sometimes, I wouldn’t even
find the bug and checking for “lost” println is a waste of time.