Since September, I’ve been learning C++ in my Computer Science class. To read more about C++, click here. It’s no cake walk, but it’s not an unattainable skill either. I could go on and on about the topics we covered – I will after Finals because hello free time – but this post just contains tips to get you through that rough beginning.
On self-teaching: I think this is a fine option if approached correctly. Find a decent programming textbook, a legitimate website, and an online course to follow.
I reference cplusplus.com
And I hear good things about edx.com which offers 100% free and self-paced courses.
Only use forums when absolutely necessary and only to find little tidbits that steer you in the right direction. Most code and/or advice, that I’ve seen out there, is going to fall under the following categories:
- BAD code
- Things that aren’t applicable at your level. (I’ll say more about this in a minute because it raises a big point)
- Decent code that gives you a general idea of what you should be thinking (rare)
Try to stick with the book, guides that someone took time to create instead of a random forum post, and videos from good programmers on YouTube.
Back to that second bullet point. I’ve often noticed a major difference between the self-taught programmer versus formally educated programmer is the self-taught programmer isn’t learning at the right order and pace.
In my CS class, we take things one step at a time. We learn an idea, apply it, learn another, apply it, and so forth. Sometimes those basic ideas are rarely used later on or you’ll eventually learn a better approach, but you shouldn’t try to use advanced ideas before you’re ready. That’s why I recommend following a textbook so the ideas are being approached in the right order. It helps to avoid getting really confused and writing over-complicated code. So that’s why referencing forums is especially dicey – you might feel tempted to grab someone’s code that is using concepts ahead of your learning. But if you’re inserting those concepts into a program without truly understanding how they work, well, that’s just asking for trouble.
On studying: There’s no glossing over concepts in programming. I’m certainly guilty of skimming through my readings in other classes, but doing that in programming will come back to haunt you. I usually need to read and watch everything several times.
On assignments: Especially as beginners, good programs aren’t written in one day. Start early, allowing plenty of time for bad things to happen. Even if you’re not ready to tackle the entire assignment, write what you can. You will run into compile, runtime, and worst of all, logic errors. You will get mentally burned out. You will need to take breaks. Even if that isn’t true for every assignment, prepare like it will be true for every assignment. Sometimes the programs that seem easy will challenge you in unexpected ways.
On learning good habits: Writing neat code is as important as writing code that works. No one likes reading a block of horribly indented text and that’s even more true if that block of text has all kinds of symbols. Find out if your IDE has features for proper indentation. In QT Creator, pressing ctrl + A, then ctrl + I indents everything correctly. Get into the habit of indenting the program yourself, then use the auto-format tools to see how good you are at free-handing it. Remember that no auto-format tool will fix everything for you, especially if you have things on the “wrong” line. For example: Braces should always be on their
On handling broken programs: The debugger is your friend. I exclusively code in QT Creator, but the debugger should work similarly and easily across all IDEs. Set a break point at the start of your code and “step over” every line while paying attention to what’s happening with your variables. If you’re debugging a function, “step into” it to see what’s going wrong (or hopefully, right).
On libraries: Functions make your life easier so take advantage of them. Get familiar with the many libraries available for C++. You can find that here. For example, cmath. It contains trigonometric functions, exponential and logarithmic functions, rounding and remainder functions, power functions, comparison functions, and more. Other good ones to know are cstdlib, cstring, and ctime.
On asking for help: One of my greatest downfalls was not asking for help fast enough. I’d struggle with a program for days, sometimes meeting with my instructor the day an assignment was due. No one is going to hand you the answers, but someone can point you in the right direction. Most of the time, that’s all you’ll need to get the kinks out of a program. If your instructor is okay with it, discuss issues among your peers. It’s usually fine as long as you don’t share code.
C++ programming tutorials in the future! Happy programming!