r/cpp_questions • u/Icy-Stretch-4643 • 4d ago
OPEN C++ Messy Coursework, Need Guidance
Hey everyone!
I'm a first-semester BS Data Science student, currently studying Programming Fundamentals in C++.
Our professor initially focused on programming logic and fundamentals, covering topics up to loops, functions, user-defined data types (UDTs), 2D arrays, etc. Things were making sense until we moved towards deeper concepts like memory representation and manipulation.
Along the way, we also covered the Turtle library for logic building, C-style strings, and an introduction to OOP, even though pointers haven't been introduced yet.
I'm now struggling to prioritize what actually matters and would appreciate guidance on three things:
- Prerequisites before OOP: Which topics should I properly master before starting OOP? What is essential, and what can wait until later?
- Topic prioritization: Is it normal to find deeper concepts like memory representation and manipulation overwhelming at this stage? How deeply should I study these topics as a beginner, and which ones can I temporarily skip without compromising my fundamentals?
- Paper coding: I performed poorly in my midterms, particularly because I struggle to write code on paper. What are some effective ways to improve my dry-running, tracing, and problem-solving skills without relying too much on an IDE?
I'd really appreciate practical advice, especially from people who have been through their first semester of CS or a similar computing degree.
Thanks!
4
u/WorkingReference1127 4d ago
All this comes with a big disclaimer of check what your course syllabus wants you to learn, and learn that. But if I were to speculate on what I personally think is sensible:
I wouldn't spend too much time on prep. OOP isn't a topic, it's a paradigm. You can start off by writing classes which handle a little bit of encapsulation and some member functions and you already have your foot on the ladder. You can of course go deeper and deeper and get into more and more pedantic things; but you don't need to. This isn't a chapter in a textbook, it's a pattern which goes as deep as the rest of the language.
You should know that if you allocate with
newthen you need to guarantee that you always clean up withdelete, and this will pretty immediately lead to RAII pattern - where you are able to automate this with class constructors and destructors from your OOP practice.But I wouldn't get too bogged down in how everything is represented in memory or bitwise manipulation unless your course asks you. And even then it's the simple end like treating an unsigned integer as a collection of bits and using the bitwise ops on it rather than trying to figure out all the possible ways that
std::listmight be laid out in memory.Is the problem the medium or your ability to code? If you had a very basic IDE in front of you (think notepad with syntax highlighting) would you be able to write the code? Go away and try it without falling back on research or AI or whatever it is you use.
But assuming that it's your mentally tracking through what a particular piece of code does, there are two main facets to this. First, you should understand what the control structures you are using do. So rather than mapping
for(int x = 0; x < y; ++i)to just "repeats y times" you should be able to track through whenxis created, when it's incremented, and when the loop stops. The other facet is practice, plain and simple. You won't get a good feel for how all this works from reading a textbook. You need to go out and write code, discover the weird emergent behaviours and places where it doesn't do what you expect, understand why that is, and then internalise the tools.2
u/VastInterior 4d ago
A good debugger is "dry-running / tracing" on steroids.
Practice stepping around functions and into subfunctions and seeing the effect of code.
It's an excellent learning / understanding tool.
Again, the debugger is your friend in understanding memory.
In modern C++ you're explicitly discouraged from using bare pointers... they are sharp tools _everyone_ cuts themselves with and safer / better tools are available for most tasks.
They are something that is used heavily "under the hood" in the std library, but at this early stage of learning, don't step into library functions but treat them as "black boxes" to step over and see the net effect of.
2
u/alfps 3d ago
Few if any programmers write code on paper. Most programmers rely on more or less immediate feedback from an editor's syntax checking and compiler's analysis. Forcing programmers to code on paper, without computers, has been tried, so called "cleanroom" coding. It didn't work and AFAIK hasn't been tried again since the 1980's. When I tried to google up an old war story about that I didn't find it, but the Google search AI helpfully remarked that "Paper exams test memorization and mental tracing, which are completely different muscles from actual software development." (!).
I guess for exams you have to train on exactly that. Perhaps form a study/training group? Having others to discuss it with and compete with can be motivating.
But ultimately paper coding relies also on general coding skills, which you train by coding ON A COMPUTER.
2
u/Discordbothost 1d ago
Make a trace table before running the code. For int sum = 0; for (int i = 0; i < 3; ++i) sum += i;, record i and sum after each body: (0,0), (1,1), (2,3). Include the final failed test at i=3. Then step through it in the debugger and find the first row where your prediction differs.