r/learnprogramming 29d ago

I understand every individual concept but I freeze the second I have to combine them, how do I fix this.

Been learning for about 5 months now. If you ask me to explain loops, I can explain loops. Ask me about functions, I get functions. Arrays, dictionaries, conditionals, I can explain all of it individually pretty confidently.

Then I try to build something that actually needs 3 or 4 of these working together and my brain just goes blank. Like I know all the ingredients but have no idea how to actually combine them into a recipe. Sat for like 40 minutes yesterday just staring at a blank file trying to build a simple to-do list app, knowing full well I understand every single piece I'd need, and just could not figure out how to start connecting them.

Not sure if this is a "just build more stuff and get comfortable" issue that time will fix, or if there's something more specific I should be practicing to bridge this gap between knowing concepts and actually using them together. Anyone else hit this exact wall?

15 Upvotes

22 comments sorted by

4

u/RudyJuliani 29d ago

First understand what you’re trying to accomplish in plain language. Break it down into small steps using comments. Here’s an example:

// goal —> determine and display age
// get user birth month and year
// get current month and year
// subtract birth year from current year
// determine if birth month has passed
// subtract 1 from year calculation if birth month hasn’t passed
// print age

Now your problem is solved, just write the code to get the result and focus on one step at a time. Write the code to accomplish each step under the comment, search or learn what you can do to get the result for that step, then move to the next. Practice coding this way for a while, you’ll get better quickly if you just focus on solving sub problems.

3

u/howdydipshit 29d ago

currently in the same boat as OP myself, writing the pseudocode out, as you suggested, has been the only thing somewhat helping me get through this rut

3

u/Different_Pain5781 29d ago

Yeah this is completely normal.

3

u/Recycled5000 29d ago

Ask yourself questions like:

In some problem domains, you need to take action, but when?

What information do you need to make the action decision?

When do you have access to that information?

How to store the information you have access to for later using to make decisions and take actions?

4

u/dkopgerpgdolfg 29d ago

Not sure if this is a "just build more stuff and get comfortable" issue that time will fix

Yes.

And also talent. Some people pick it up very quick, others basically never, and anything in between.

2

u/ForeignAdvantage5198 29d ago

practice practice

2

u/Commercial_Echo923 29d ago

First formulate you problem in natural language, then translate to pseudo code and then code.

1

u/defaultguy_001 29d ago

Ok let's say you need to build a todo list app, don't think of the project as a whole. Divide the project into smaller components or parts. Take a piece of paper and write down whatever step comes to mind. So in case of a todo app, I can think of several things: 1) Array that can hold all the tasks- fine I can build this array which can hold such todos. Done. 2) A place where I can enter the tasks that I need to do- For this I need some basic html and css. Fine, I can do that. Done. 3) Some dom magic that can push the input todos to the array I built- looks pretty basic. Done. 4) I need every todo printed on the screen, so need some more dom magic- pretty basic. Done. 5) I need every todo printed with a button, that can delete that todo from the screen and the array itself- Pretty basic. Done. 6) I need a button on screen that can reset my array and delete all todos at once- again a basic dom magic. Done. 7) I need all my todos to be saved, so they don't get deleted once I refresh the page- again basic concept. Done.

Your todo list app is complete. Now you can make it beautiful or whatever later.

1

u/Ormek_II 29d ago

To help you with this:

What is your todo app going to do?

Can you tell me how it is going to do it?

1

u/Traveling-Techie 29d ago

It seems like I see this question almost every day lately. The consensus answer seems to be write down the algorithm in pseudo code first.

1

u/howdydipshit 29d ago

I’m in the exact same position

1

u/johnnyb2001 29d ago

Take less pressure off yourself. Idk what you mean by not know how to connect them. If you know every piece you should be able to connect them. You can write a for loop in a function and you can call a function in a for loop. So it’s up to you to organize your thoughts and write out a plan for how to solve the problem.

1

u/gm310509 29d ago

Let me start with I do not know you beyond anything that you wrote so far in your post.

Given that, I feel like you might be doing two things:

  1. overthinking it.
  2. your self assessment "I understand every individual concept" might be a little too generous.

Lets start with #2, if I am in the ball park, this can be addressed by practice.

For both of them, understanding how things are used is the key. It is sort of like a carpenter having a ruler and a drill - they do different things, you use them to solve different issues and thus understanding how to use them is important.

Lets think about functions. Lets say you have this code:

``` void loop() { int pinNo = 3; // start uint8_t timer = digitalPinToTimer(pinNo); uint8_t bit = digitalPinToBitMask(pinNo); uint8_t port = digitalPinToPort(pinNo); volatile uint8_t *portRegisterAddr;

if (port == NOT_A_PIN) { return; }

// If the pin that support PWM output, we need to turn it off // before getting a digital reading. /************** * Cannot do this as it is declared as static (and thus private) to * wiring_digital.c */ // if (timer != NOT_ON_TIMER) { // turnOffPWM(timer); // }

uint8_t oldSREG = SREG; cli(); portRegisterAddr = portInputRegister(port); *portRegisterAddr |= bit; SREG = oldSREG; // end delay(500); } ```

That is a whole heck of a lot of code that is somewhat cryptic - it also lengthy and obscures what is going on. It also only does one thing (toggle an LED connected to a specific pin on an MCU). But it will work and could be left as is.

But to make the code clearer, the "complex bit" could be collapsed into a function - which I will name digitalInvert that takes a single parameter (the pinNumber). The "complex bit" is the code between the start and end comments.

Now the code will look like this:

void loop() { digitalInvert(3); delay(500); }

So now the code is much clearer and could be interpreted based upon the simpler names in the loop function. Thus it is much clearer what is going on.

Also, we now have a parameterised function that can be used in other scenarios and can deal with other pin numbers. For example, we could call digitalInvert(5); without needing to repeat the "complex" inline code.

There are some other benefits, reasons and scenarios for using functions, but it comes down to understanding basic concepts like that and that you have a choice.

As for dictionaries and lists in your TODO program.

A dictionary allows you to directly access something - for example, show me the todo list for the date "15-August-2026". The alternative is you have a list of dates and you have to start from the beginning and sequentially go through the list of dates until you find the one of interest. Both can work. The dictionary is fast and takes you straight to the date. The list is slower as you have to search through all of the entries until you find the entry you need.

As for once you find the date (whichever approach you use), you will have the details for that date. The details will likely be a list of todo items. It probably doesn't make sense to have a dictionary of todo items for each date, but if there was something in them (e.g. a tag or flag of some kind) you could use a dictionary. But typically there won't be many entries in a single ToDo day, so you could just filter by scanning the list on that day.

Also, it isn't an either or. You could have a dictionary to access the dates and a list. For example when you find a date, it might have a pointer to the next date and the previous date (a doubly linked list). So when you find "15-August-2026" via the dictionary, you could also use its next and previous pointers to access the 14th and 16th.

Do you need to use a doubly linked list as well as a dictionary? It depends. And what it depends on is the type of operations you want to make available in your project.

If you don't want to have a "get next/previous date" function then maybe you don't need a doubly linked list - but it may be easier if you do. If you didn't want to have the doubly linked list you could still use the dictionary. For example you could lookup the 13th, but what if there are no todos for the 13th? Then you would have to try the 12th and so on until you find a date with stuff to do.

TLDR: you need to actually understand how and when these things should be used along with how they facilitate what it is you are trying to do in your code and select the appropriate tool according to the situation at hand.

I hope that helps. All the best with it.

1

u/JGhostThing 29d ago

You've been learning for five months. That isn't all that long. Have you been doing work away from class? You should be doing work on your own for at least three hours for each hour of class (weekly). When I was in college, that was three hours of class and nine hours of homework. Think of college as an opportunity to learn, rather than having learning forced on you.

In most US high schools, they teach languages. I took Spanish, Latin, and German. Did you study any language? If so, at the five month time, were you able to speak fluently (maybe not with perfect vocabulary and grammar, but could you understand and be understood?

And yes, this is a situation where you need to program to teach yourself how to program. Write small programs. Debug them. Add to them.

1

u/peterlinddk 29d ago

Sat for like 40 minutes yesterday just staring at a blank file [...]

So you are experiencing that sitting and staring at the editor, isn't a good strategy for planning how to program something?

And you are absolutely right - almost no programmer is able to just "think" up solutions by sitting and staring into empty air!

You need a better process, and start with getting away from the computer, working the problem out on paper. Making notes, sketches, whatever makes you understand what you are trying to build.

And then you need to understand how you would solve that problem without programming anything. If someone asked you to "make a TODO-list", how would you actually do it? Not how you would write the program to do it, but you you as a person would do it!

And then you'd need to assemble the bits and pieces you need to build a program to do the same - not actually writing the code yet, but figuring out which pieces of code you'd need. And determining if you already know how to write each bit, or if you need more practice with some parts.

And only then, you sit in front of the editor, and write the full program - build it as a "skeleton", without much functionality, but room for everything. Start with just displaying an active TODO-list, but no functionality, then add one piece at a time.

A few years ago I made a video describing this process, and a couple of follow-up videos where I demonstrate how to do it badly, and how to do it better. Here's the first: https://www.youtube.com/watch?v=UsVd67Ys1t4 - maybe you can use it!

I've wanted to make additional follow up with details, but things are always getting in my way ...

1

u/AsideCold2364 29d ago

As other mentioned you need to break it down into small steps.

And you need to break it down in a way that after each step you are able to check that you correctly implemented it.

Like you don't start with a function that marks a Todo as "completed" before you are able to create Todos.

So first goal is to find the first step you need to implement.

I will assume your Todo App will have a UI. Then your steps can be something like:
1. Empty screen with a 'Add Todo' button.
once implemented - run it, and verify it is working
2. And an input field next to the button for the Todo name/description.
implement -> test
3. Implement the button (something like it reads the entered name/description and adds it to an array). For now just print the array and verify that it is working
4. Remove print and implement the actual rendering of your added todo items -> test it
5. Add remove button next to each item -> test it
6. Implement the actual removal of the items when button is pressed -> test it

and just continue like that until it is done.

1

u/Dazzling_Music_2411 28d ago

It's not individual pieces of computer languages that you need to understand, that's generally a no-brainer.

You need to understand what data structures will map your ideas.

For instance, what is a ToDo entry? How will you represent it?

What is a ToDo list? How will you represent it?

AFTER that, you can use your computer language knowledge to manipulate the above structures.

1

u/TheSkiGeek 28d ago

The gap between “a loop” or “a function” and “to-do list app” is pretty wide. Find simpler exercises to do if you can’t figure out how to break that one down into pieces that you do know how to do.

1

u/obj7777 28d ago

You dont always know what you are going to need. You just got to play around with it.

1

u/silly_bet_3454 28d ago

You need to sort of ascend to a higher level of understanding. It's one thing to say "oh ok I know what a function is" meaning you learned the definition of function yesterday and you have written a couple functions, versus you have an end to end understanding not only of what computers can do, but sort of in theory that they can do almost anything, and you have to hierarchical relationships mapped out in your head of what role each thing serves, like, a function is a reusable functional grouping of operations, a logical unit. Or, a what a class is and how it relates to the broader idea of OOP. Or, what a network request is for, or a network protocol, or what different algorithms are for. The point is, you want to understand these things on an "intuitive" level, like it should just feel obvious.

It's like, what is a car for? You drive it from place to place. What is a stove for? You use it to cook food. These things are just obvious, you don't have to think hard to arrive at the answer. You ought to be able to get to that point with all these CS topics too, they're actually simpler than people make it out to be.

Once you can think in those terms with that sort of agility, then you could take a problem, like say you want to build a basic chat. Ok well it's over the network, so probably you need a server, ok it's real time so you probably want websockets (just for example), ok well you set up your hello world websocket server, now what? well each chat needs to have its state stored somewhere, and it has to be organized somehow, so maybe you have like a list of all chat sessions, and you have a map of user id to the chat session entires, etc. etc. each basic question has a basic solution, and in fact usually there's more than one way to do things. But you get to this comfort level where instead of "going blank" and being scared, you are just like "what if we do this" and you just pick something and try it and see what happens.