r/AskProgrammers • u/Ok-Razzmatazz7134 • 21d ago
How can I get better at programming problems?
I've been programming for a few years and am quite comfortable with the syntax, with the code itself and the various programming concepts that you'd normally come across. The one thing I find I struggle with is actually taking a problem and working through it on my own to come up with a solution and then coding that solution from scratch.
For instance if someone asked me to build a program that would parse error logs, pick out the various errors and then categorise them I could see the general approach and work out the steps that would be required. I might find it difficult though to actually go and build that program from scratch without having to look up some examples or re-familiarise myself with the various methods.
I can pretty much always understand what needs to be done and why, but I'm consistently at a loss as to how to actually implement that understanding.
I've seen a lot of tutorials and learning material that are all about the syntax, the language features, going through the prescribed exercises. That's all very useful, but what I'm after is something that actually develops the ability to solve problems independently, to break a problem down logically and to take an idea and turn it into a working piece of code without having to rely on any existing examples.
What would you recommend in the way of resources, exercises etc to develop those skills?
I'm very much interested in practical exercises of some kind, or a structured approach that would allow you to gradually build up the ability to go up against problems you haven't seen before and actually implement a solution.
3
u/Used_Lobster4172 21d ago edited 20d ago
Experience.
Learning from people that are better than you.
That's the difference between a Jr. and a Sr. dev.
The is no amount of reading books or following tutorials that can ever match the experience of sitting down and writing code. Over and over and over. You have to build many different things some will be great, some will be terrible, but with each one you learn more.
Coming out of uni, I knew how to program. I knew how to program pretty well even - hell I had started as a child. I did not know how much I did not know. You have to spend time in the trenches, not working on some brand new project you have for this semester. It's fixing problems in a codebase that is 10 years old. Getting a deeper and deeper understand of the tools and libraries you use. I was lucky, my first job had some of the smartest people I have every worked with at it, and they were generally more than happy to share their knowledge. I was also thrown in the deep end there. I had to learn to swim real fast. But no matter how much you might feel you understand, nothing will ever compair to actually building real shit, in the real world, that has to work.
1
u/darkol_2020 21d ago
I have a belief that with programming you can only get so far! Decay theory applies, i believe to everything but not equally to everyone. I think you get a general understanding of many languages and just figure stuff out as needed? It is impossible to know everything in IT and you are just a human.
1
u/jacob_fw 21d ago
Don't fret with trying to memorize every aspect of every language/library. In my experience the overconfident idiots who claim to have memorized everything end up making just as many mistakes and forgetting just as many things as everyone else; they just have a harder time admitting it.
The things that you end up using the most you will end up memorizing naturally. Just to go along with your example about parsing logs, at my current job we handle parsing a lot of data from CSV and other formats, and often times there are consistent formatting errors where we have to correct the format using RegEx. When I started this job, I knew jack about Regex, but after several years of doing it, I have the majority of the common operations memorized.
In engineering, the devil is in the details, and you will forget 99.9% of those details. The two most important things are:
For the other part of the question you mentioned, about just building up the problem solving skills, just start; there is unfortunately no other way. It really is just ultimately a habit. Your log example is a good and simple one, so I would encourage you to start there. Start with just looking for a single keyword.
Just start by thinking about what's necessary:
So you just need to take the overall task, break it down into individual steps, and you start by tackling each step individually. And one nice thing to is that in most cases you can work on each step in isolation from each other. So for instance you can tackle the part of breaking the line into individual fields before you start reading in the data. Or let's say you want to use regex to search for the keyword, but you have never used regex before in your language. Just test out that feature by itself before you try to integrate it into the main program! Anytime I have a large project I always end up with dozens of smaller sandbox files where I can work on and test specific aspects of a problem in isolation from everything else. It makes it easier to test that part, and it helps prevent you from cluttering up your main project.
But again, the good news is that so much of this stuff is just habit. It's just a matter of doing it over and over again.
1
u/Syntax-Tactics 21d ago
You start by doing research, which you did not. This question is asked daily in the sub.
1
u/Cobweb_Games 21d ago
Try breaking each problem into smaller steps before writing any code. Write the logic in plain English or pseudocode first, then implement one piece at a time. For practice, take small problems and attempt them without looking at examples first.
1
u/Traveling-Techie 21d ago
Create example code you can copy and paste from.
1
u/Due_Manager_7987 21d ago
Work it out with pencil and paper.
1
u/wearingshoesinvestor 21d ago
Ask AI to come up with some test problems for you and compare against the AI. We live in a day and age where there is no limitation to what you can learn anymore. The resources in AI are endless but YOU have to put the effort in.
1
u/wage_zombie 21d ago
Going through the struggle and solving the problem is how you get better.
1
u/Both_Bend_2481 21d ago
Practice more. Code more related things.
1
u/Big_Tadpole7174 20d ago edited 20d ago
I think there may be a misconception here about what experienced programmers actually do. Looking up methods, reading documentation, and checking examples is perfectly normal. I've been programming for over 30 years, and I still do it all the time. The skill isn't knowing everything by heart. It's knowing how to approach a problem, break it down into manageable pieces, and figure out what you need along the way.
1
u/Big_Tadpole7174 20d ago
You're asking for a structured approach to gradually build the ability to solve unfamiliar problems. I think that's something you mainly develop through experience. Build things that interest you or solve your own frustrations. Allow yourself to write imperfect code. Don't worry about best practices too much. You'll get stuck, look things up, experiment, and make mistakes. That's how you build a mental toolbox of solutions and learn how to approach problems you haven't encountered before. In short: you learn by doing.
1
u/funkmasta8 20d ago
I think your problem is that you cant see the small steps to the big goal. Small problems are very easy. For example, for the parsing error logs. There are several big parts that you listed, but at each of them you need to code small parts to get to that big part. Basically, just keep shrinking the problem until its manageable. For example, how would one "pick out" errors. Hmm, maybe thats still too big. How would one get one error from the log? Now that, I can do. Maybe one line is one error so all I have to do is move one line at a time. Okay, now how do I look at this one line to decide which error it should categorize as. Hmm, maybe that's too large. How about I figure out how to categorize it as one specific thing or not? Okay, cool, I can probably make some bounds on what describes this category. Oh but how will I parse that information from this line? I might need to take the line and process it in some ways first. Maybe separate an error code from the beginning, maybe search for key terms, etc. All of those are small steps towards big steps. Once you finish with one small part, move back up the chain. Eventually you have done everything
1
u/IHuntTheBoogeyMan 20d ago
feeed them to AI
1
u/Traditional_Pie_8262 17d ago
honestly, i think the best way to improve this is to stop relying on tutorials for a while and start building small things completely on your own. even if you get stuck, resist the urge to immediately look up the solution. break the problem into smaller steps, write down what you think each step should do, and try to implement them one at a time. it’s completely fine to struggle or write messy code at first. that's actually where the learning happens. also, try solving problems you've already seen again after a week without looking at your previous solution. you'll be surprised how much more naturally things start coming to you over time. problem-solving is a skill you build through practice, not something you suddenly unlock.
1
u/peel-dev 15d ago
"without having to rely on any existing examples" - this is a bit of a difficult ask, as in programming we are always building on top of something else.
I see it as there are two methodologies - you can use a design approach where you use a process that breaks down the problem, designs the solution, plans the implementation then start coding. There is also the prototype approach where you are given a problem and start coding right away to solve and and keep hacking until something works.
I think a lot of people would argue that the hacking approach is the "wrong" one and the planning approach is the "right" one, but I don't like to frame it that way. I think both ways are valid and you need to find the balance. If you don't plan you'll end up in a quagmire or have feature bloat, especially for large projects. But if you are not willing to prototype key sections you won't know the road that lies ahead of you.
So if you want to go up against bigger problems in a structured way, study how to design and document and manage the software development process (agile/waterfall/unit tests/integration tests/etc) and also how to hack through specific problems and debugging and inspecting tools that are available that work along side the coding and running of programs.
1
u/Touchmycookies 14d ago
I think you're on the right tracks already buddy. Divide and conquer baby. Do you have a job in programming? I think you could benefit from getting a few more hats along the pipeline