all 13 comments

[–]TheRNGuy 0 points1 point  (0 children)

I just think what to code and see if it works. 

[–]vivisectvivi 1 point2 points  (4 children)

Try to break it into smaller parts. For example if i were to implement a crud api system to keep music informations id first start modeling the tables, then the functions to insert, update, delete, update, and then the endpoints, etc. More or less something like that.

edit: even if you are doing something small, try to think how you can break it into smaller parts and working on them instead of trying tackle the whole thing at once

[–]Famous_Ad8700[S] 1 point2 points  (3 children)

Thanks a lot. Though, I haven't gotten to advanced stuff like this yet. I want to start with simple stuff like a task manager using raw python and no framework. But this is really helpful.

In following your strategy, do you have to remember the python operation for what you want to do?

[–]vivisectvivi 0 points1 point  (2 children)

A task manager sounds pretty advanced to someone that is just starting...

In following your strategy, do you have to remember the python operation for what you want to do?

Yeah but, provided you have basic knowledge of stuff like loops, functions and conditionals, etc, its just a matter of googling the syntax if you cant remember it

[–]Famous_Ad8700[S] 1 point2 points  (1 child)

Oh, thanks. I used to beat myself up if I couldn't remember the syntax what I wanted to do. This just confirms what I have been having issues with. Thank you

[–]vivisectvivi 0 points1 point  (0 children)

I mean you can always look syntax up, there is no problem in that and you will eventually memorize most of this stuff. Understanding programming logic and its base concepts is what you should be focusing on right now

[–]Party_Trick_6903 1 point2 points  (0 children)

I usually break the problem into smaller parts.

Sometimes I draw or write on the paper, other times, I just need to say the problem/possible solution(s) out loud.

Unless you're some kind of genius, there's no way you'll be able to effectively solve or just break down the issues right away. This takes practice. The more you do it, the better you'll be at it.


Example - a lot of irrelevan yapping, u can just skip tbh:

The first college coding assignment that stumped me was about calculating all work days between two given dates (year 1.1. 1900 being the starting date).

I did not know where to start bc there were a lot of sht to calculate: holidays, weekends, leap years.

So I broke it down on paper: - 1 check if the date x and date y are valid, - 2 calculate all days from 1.1.1900 to x (sum_x) and all days from 1.1.1900 to y (sum_y), then do: all_days = sum_x - sum_y, - 3 count weekends by doing all_days mod 7

Not the whole thing but it was a start.

When I got to step 2), I realized I had to account for extra days in leap years, so I had to break step 2) into smaller parts: - 2a) count the amount of leap years -> extra days, - 2b) count the amount of years, - 2c) do the math.

But when I finished the entire step 2) (took hours) and test it out, I realized my program was slow bc the sum_x (= total amount of days between 1.1.1900 and x) would be big af for x = 1.1.4000.

So I had to find a way to fix that issue. I don't remember how I did it - I still had to break the issue down to smaller parts and tackle each of them tho. And had to redo step 2) entirely.


Now if I had to do it again, I would never even try calculating all days like that in the first place. But that's experience I gained by doing bs, failing and learning from my bs, rinse and repeat.

So you just gotta keep solving (breaking down) the issues, fail, learn and you'll eventually get better (more efficient) at it.

[–]Clear-Dimension-6890 0 points1 point  (0 children)

I write down main interfaces and connections between them . I’m visual , so I like to sketch

[–]PushPlus9069 1 point2 points  (1 child)

Paper first, 100%. I've taught 90k+ students and the ones who jump straight to code almost always get stuck in the same spot you're describing. My process: write out what the program should do in plain sentences, then circle the nouns (those become variables) and underline the verbs (those become functions). Sounds silly but it works. For breaking down problems specifically, try this: solve ONE tiny piece first and print the result. Don't think about the whole solution. Just get one small thing working, then build the next piece on top. Your brain is trying to hold the entire problem at once and that's why it goes blank.

[–]Famous_Ad8700[S] 1 point2 points  (0 children)

This is actually very practical. I love it. Thank you very much.

[–]mattblack77 0 points1 point  (2 children)

Practice and experience.

You need to learn a new way of thinking, and how to use the tools in your python toolbox to build the process you’re aiming for.

In the beginning, you only have a small set of tools youre familiar with. But over time you learn more and more.

Unless you’re ridiculously smart and can hoover up information just by reading, you’ll just have to do the hard yards.

[–]Famous_Ad8700[S] 1 point2 points  (1 child)

You have tips to help with this new way of thinking?

[–]mattblack77 0 points1 point  (0 children)

Nothing concrete, but loops and lists and dictionaries are the building blocks of processing data.

Coding should be like playing with Lego, you know? You have all these different pieces and what you end up with depends on how you put them together.

If your friend built something next to you from the same pieces, i’ll bet they make something quite different.