Feb 15, 2024 22:36
No problem. Good luck, and take heart: nobody is born understanding programming, and it's a difficult task that takes time to pick up.
Feb 15, 2024 22:36
Nowadays, you can dump these requirements into ChatGPT and get a (hopefully) more or less working program out in 5 seconds. But if you don't understand how it works or how to write such a program yourself, it only kicks the can further down the road, since eventually, you'll get to a point where ChatGPT can't figure it out (or you're doing a hand-written test). There's really no substitute for grinding through and hand-coding the temperature converters and array searching (etc) mini-programs described above (that I know of).
Feb 15, 2024 22:36
That's unfortunate, since the only way I know of to learn programming is to actually do it on progressively harder problems. That said, a good deal of education (and work, later) comes down to the rather brutal "here's a bunch of requirements; figure it out yourself", so this is a good opportunity to try self-learning and self-practicing the material. This assignment is somewhat "generous" in that it tells you which programming concepts you'll need to complete the task. This doesn't happen much in the "real world"--it's just a set of business requirements without any programming concept.
Feb 15, 2024 22:36
Usually, before an assignment like this, there would be a series of simpler assignments like printing "hello world" to the screen, writing a Fahrenheit to Celsius temperature converter function, finding the largest element in an array, printing the contents of a file, processing user input, storing information in structs, creating arrays of structs, etc. The assignment is basically a matter of combining all of these basic concepts into a fairly involved full application.
Feb 15, 2024 22:36
No problem, you're clear. So did you get a chance to write the simpler programs yourself, or have you only watched your teacher write them? If you haven't written the simpler programs yourself, that's pretty much required. This app involves at least a dozen concepts that you'll want to have programmed and experimented with enough to understand in isolation before starting on it. If you haven't done these simpler programs yet to explore arrays, structs, functions, conditions, loops, variables, input/output, etc, then I suggest working on them, starting with the simplest.
Feb 15, 2024 22:36
What do you mean by "theoretical programming" exactly? The description here seems pretty concrete. Are you sure you're breaking the problem down into small enough tasks that you can complete the first one? For example, "Structs: the student will be created not as a single variable, but as a struct." Can you create an empty Student struct? Next, add the integer id field into the struct, and repeat, building up to the full program (eventually). This would be a difficult assignment if you haven't built smaller programs using the techniques it mentions, like structs, arrays and so forth.
Feb 15, 2024 22:36
No problem, it's often part of the process to chat a bit to figure out one's intent. Welcome to the site! So the instructions you shared seem pretty clear to me. What aspects were you stuck on? "The program should contain:" is a helpful point that lists all of the programming concepts you'll need to complete the task. If any aren't clear, that may indicate a knowledge gap, a missing prerequisite. If you haven't programmed with one or more of those concepts yet, that's a sub-problem I'd break out and learn about, since this project is about synthesizing a series of fundamental skills.
Feb 15, 2024 22:36
OK, that helps, thanks. Can you edit your question to include some of that information so it's easier to answer? It's hard to make a recommendation when the question is as broad as it stands currently. The exact code isn't important, but I'm trying to get a sense of what you're stuck on. What theory have you covered and what programming experience do you have? It sounds like a beginner-level C++ program, so if you haven't had exposure to C++ yet, it may be hard to begin. You might want to remove the lesson-ideas tag since that's more for educators.
Feb 15, 2024 22:36
What was the project? What sort of analysis or processing were you trying to do on it?
Feb 15, 2024 22:36
Are you asking as a student or an educator? Do you have any examples of a software project that you (or your students) were unable to analyze the requirements for? In general, I'd say: practice on small projects and build up to larger ones.
 

 The 2nd Monitor

General discussion about codereview.stackexchange.com - Welcom...
May 25, 2021 19:36
Nice of you to say
May 25, 2021 19:30
Hi @Mast congratulations on the moderator election and thanks for helping keep the site running smoothly
 
Aug 6, 2019 01:43
I think you're right--this can be written without the inner function, and it's much tighter as a result. See my update and thanks for the tip.
Aug 5, 2019 23:32
No problem--happy coding!
Aug 5, 2019 23:17
Not necessarily--it's a subjective thing, so you can make a good argument for your latest version. At that point, my biggest beef would be the lack of braces :)
Aug 5, 2019 23:15
level is still "local" to the while block in the iterative version, but it'd be a bit silly to go and put deepest in there on the stack as well when it'd just be a reference to the outer scope anyway.
Aug 5, 2019 23:10
Also, check out the iterative version for comparison. In this case, all the needed state is on the explicit stack but it's not such a terrible thing that we have a "best" variable in the outer scope. I'd say the code is about as clean as the recursive version.
Aug 5, 2019 23:09
We do, but sometimes it's just more convenient to bump something up a scope. I can get away with deepest being outside of the local scope because it's very intuitive when it gets modified and the alternative of passing it in as a reference parameter or using a return value doesn't really gain a whole lot of safety since we have a nested function that has tight scope already. In your code, notice that you've had to introduce more complex conditionals and variables to make it all work, counteracting the safety. I still prefer my original, but right idea! Which code is easier to understand?
Aug 5, 2019 23:09
We can do that, but what is gained? The idea is to keep the code as tight as possible, using as few variables and conditionals as we can. If we move level outside of traverse, we extend the scope of level (similar to a global variable). The value of currentLevel in a given stack frame is hard to determine from reading the code. Parameters are good in this case, I would argue, because it's clear what level is and how it's changing from one frame to the next because it's local to each frame. Having to foo++ and then foo-- later on just to keep state correct should be a red light.
Aug 5, 2019 23:09
No problem--check out side effect on wikipedia for more information on mutation.
Aug 5, 2019 23:09
If the function tells the client that it's going to permanently modify (mutate) the objects, then it's OK. For example, Array#push clearly modifies the object it's called on rather than returning a new copy. In your case, the function deepestNode is similar to Array#find in that it performs a search. You wouldn't want Array#find to mess with the objects it was supposed to search through, I'd guess.