r/cpp_questions • • 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:

  1. Prerequisites before OOP: Which topics should I properly master before starting OOP? What is essential, and what can wait until later?
  2. 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?
  3. 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 Upvotes

5 comments sorted by

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:

Prerequisites before OOP: Which topics should I properly master before starting OOP? What is essential, and what can wait until later?

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.

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?

You should know that if you allocate with new then you need to guarantee that you always clean up with delete, 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::list might be laid out in memory.

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?

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 when x is 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

❞ I performed poorly in my midterms, particularly because I struggle to write code on paper.

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/n1ghtyunso 3d ago

Paper coding might test your ability to step through a simple program in your head.
I can't say if its useful or not, but for what its worth in 11th grade our programming syllabus did paper coding tests for some initial beginner stuff.
At the very least this was still in this century.

I don't think its the same as cleanroom coding you are talking about though.
It makes no sense to do paper coding on anything remotely complex, which seems to be more what cleanroom coding is about?

Here it might just be a specific teaching approach, like it was in our school.
Surely they too will drop it soon in favor of an actual 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.