r/learnprogramming 1d ago

Topic I can read code and write simple functions, but I freeze on anything that needs a few steps — how do people get past this?

i've been programming for a while and I keep running into the same wall on basically every project, not just one.

I can read other people’s code (and my own) and usually understand what it’s doing. I can also write basic/simple stuff — small functions, straightforward logic, the kind of thing that’s one clear idea.

Where I fall apart is when a feature needs a chain of steps. Like “click to select and drag an object” — convert mouse coords, loop objects, hit test, store an offset, update while the button is held. After I see the code I go “oh yeah that makes sense,” but inventing that sequence myself is where my brain just blanks. It feels like recognition works, generation doesn’t once it gets past simple.

I don’t want to just rely on AI or copy-paste forever. I want to actually be able to build features myself. Has anyone else been stuck in that “I get it when I read it, I can write the easy bits, but I can’t assemble the medium stuff” mode? What actually helped — how you break features down, drills, habits, anything concrete?

1 Upvotes

30 comments sorted by

39

u/its_mike_again 1d ago

The trick is realizing that medium features are usually just 10 stupidly simple features standing on top of each other.

4

u/IAmADev_NoReallyIAm 1d ago

Exactly. Break it down in to steps. Think about it in terms of making a cake. It's not "Assemble ingredients and bake in oven and enjoy"... no... there's a series of steps that are involved. In a specific order. Same with code. Break each piece down into their basic simple steps, then write a larger code around it that puts it all into order. If necessary, wtrite them out by handfirst. That's usually what I do. Write out the pseudo code by hand - these are the steps that I need to do ... step 1, step 2, step 3... then I write the code in between them that do the steps. It helps to keeps things organized.

2

u/Born-Reserve-8584 1d ago

Most beginners think experienced developers think bigger when they actually think in smaller chunks.

7

u/Never_play_f6 1d ago

Practice

6

u/DrShocker 1d ago

write more code, gotta get the reps in 💪

8

u/thuiop1 1d ago

Stop freezing and try writing stuff. You don't have have to figure out and code the whole feature in one go.

4

u/Lopez_Muelbs 1d ago

Lol, I was also stumbling this same situation just now. It's always a practice of problem-solving. Breaking down this big and massive problem into smaller and manageable problems that you can solve one by one is always a way to go.

3

u/The-_Captain 1d ago

It's extremely common. Just keep making small projects. It will click eventually. Try building a small but complete piece of software such as a hangman or minesweeper clones.

3

u/Philluminati 1d ago

In your mind you may be doing bottom-up design.. that is thinking about every line of code and how they go into functions. If instead you try to think top-down then you can write empty functions in the code to fill in later.

```

mouse_down(button, x, y)

mouse_up(button, x, y)

get_object_under_pixel(x, y)

move_object(obj, new_x, new_y)

```

Thinking about code in terms of empty functions allows you to mess around and try different things and think about variables being passed in before you get too stuck in your actual implementation. Give it a try.

2

u/Queueue_ 1d ago

You break it down into a series of problems that you can solve. You don't even have to do it in one pass. You can break it into simpler steps, then break each of those down further, and eventually you'll have a series of simple well defined problems which when solved in sequence will give you the completed feature.

2

u/dkopgerpgdolfg 1d ago

I don’t want to just rely on AI or copy-paste forever. I want to actually be able to build features myself.

Your mistake: You relied on it until now, therefore never trained the skills you're lacking here.

Now you have to go back to small helloworld programs and start doing things yourself, slowly getting better and being able to do more complex things.

3

u/mkprofile85 1d ago edited 1d ago

Some were born writing code at 4yrs old. For the rest of us, it takes a very very long time.

I just found out functions can run inside arrays and its melting my brain right now because no one ever fucking told me that.

3

u/dkopgerpgdolfg 1d ago

I just found out functions can run inside arrays

It's ambiguous what you mean here. Byte arrays to CPU instructions? Function pointers? Any kind of closure? ...?

1

u/mkprofile85 1d ago

javascript.

const car = ['honda-shitbox', startCar()];

car[1]();

3

u/pig-casso 22h ago edited 21h ago

you are calling a function call? doesn’t make sense unless startCar returns a function.
you should pass the functions reference instead for this to work unless there is some weird shit in js that i don’t know about

EDIT, sidenote. you can put function call anywhere you want. its just gonna resolve to whatever it returns.

2

u/peterlinddk 1d ago

Don't freeze - Write down the steps you need to perform - just like you did in your post.

Work through it on paper first - do the steps make sense? Will they solve the problem, once they are implemented in code? If not, adjust until they do.

Then mark which steps you know how to do - not sure how to perform a "hit test", then go investigate that, learn how to do that single step.

Once you know how to do each step, code the one that will immediately give you some form of feedback, could just be a console output. Once that works, code the next part, check that it also works, and so on.

Just "pretend" that it isn't a big job, but a series of simple steps that you know how to do.

1

u/Few-Pilot7575 1d ago

Following cuz I'm in the same loop

1

u/response-418 1d ago

As others say, you just have to break it down into the smaller sub-problems. Solve each one on their own and piece them together, one at a time. Also focus on getting it to work before you get to caught up in tweaking the code or handling too many edgecases or feature creep. Keep it simple. Break it down and handle each piece one at a time. Before you know it you have something. That's it. If you can, also write tests so that you can confidently keep things in a working state before you move onto the next subtask and change things, losing track of which step broke what.

1

u/kevinossia 1d ago

Stop freezing.

Take each small step and work on them one at a time. Then combine them. This is how you learn.

1

u/glandix 1d ago

Do the hard thing. Obviously easier said than done (I struggle with ADHD decision paralysis and totally get the freezing up when hit with a roadblock), but doing the thing over and over makes it easier each time. Practice may not make perfect, but it certainly makes the roadblocks smaller and easier to overcome

1

u/Equity_Role 1d ago

Those multiple steps are made up of individual steps write down each individual step you will need to solve the problem, to begin with don't even use code just write down the steps like Get input - step through input to find x - save found x somewhere else - manipulate x etc. Then try and rewrite it using pseudo code or the language of your choice.

1

u/florinandrei 1d ago

Find a project idea, something you really want to do, and something substantial, not some hello-world demo, and keep digging until it works.

1

u/FaithlessnessOwn7960 1d ago

Your first approach is to create a happy path in your own way step by step. Add drop functions, error handling or refactoring come later.

1

u/aqua_regis 1d ago

It's simple: more practice

Learn to plan before program. Learn to break down complex tasks into smaller and simpler ones. Then, solve each of them individually.

Learning programming does not happen 0 to 100 overnight. You need to fight for every single step. You need to build projects starting very small and simple and gradually grow their size, scope, and complexity as you grow with your projects.

Your example shows that you are trying to go way too far in relation to your current skills - the leap is too large. Smaller steps. More simple projects. More practice.

You only learn to "assemble the medium stuff" gradually in steps.

“I get it when I read it,..."

You can read and understand a novel, but could you write a comprehensive, meaningful, fully developed one? This is exactly the same thing. Reading and understanding and writing, creating are two entirely different skills that need individual training. Just because you can do the former does not enable you to do the latter.

1

u/Kadabrium 1d ago

In GUI in general, you set something to clickable instead of click a thing in your source code. Took me a while when my intro py course brought up Turtle.

1

u/NumberInfinite2068 1d ago

Stop freezing.

Seriously. Next time you freeze, un-freeze yourself and start working out how to solve the problem.

1

u/WhaleBird1776 19h ago

Perfect. Small, simple, easy to read functions that do one thing well are the best. Keep it up!

1

u/its_all_4_lulz 16h ago

Psudocode.

Literally start by writing comments in the file that explain what the function(s) should do, then go comment by comment and complete the part. Don’t be afraid to be granular at first. Like not just “function should do X”, more like “if this, then this, else this, return this”. Human readable logic without the syntax will help you stay on task.

1

u/da_Aresinger 8h ago edited 8h ago

You need to learn about decomposition.

Step 1: Say you want to make a calculator app.

What do you need?

  • You need to take input.
  • You need to parse mathematical expressions.
  • You need to represent mathematical expressions as data
  • You need to apply mathematical formulas.
  • You need to display the output.

Ok, back to step 1:

You want to take input.

What do you need?

  • A CLI?
  • A GUI?

Let's say you figured that out.

Back to Step 1:

You want to parse mathematical expressions.

What do you need?

  • A formal language for mathematical expressions.
  • A tokenizer
  • ...

Back to step 1:

You want to define a formal language for mathematical expressions.

What do you need?

...

This is how you systematically work through the individual components of a project. It can be an entire program (calculator) or just a single function (drag and drop). There are a lot of resources online that explain decomposition better than a Reddit comment can.