r/learnprogramming • u/Equivalent_Cow1031 • 25d ago
Programming Approaches Is experimenting and tinkering with code a good way to develop problem-solving skills as a programmer?
Hi everyone,
I'm a second-year Computer Science undergraduate currently studying DSA in Python. I've solved around 140 LeetCode problems, but I still struggle with approaching unfamiliar Medium problems independently. Quite often, I need a hint or nudge to figure out where to start or develop an algorithm that handles all possible cases.
My professor has encouraged us to avoid relying on built-in methods, external libraries or outside help, and instead implement algorithms from scratch using just our knowledge and the code editor.
Something I've noticed about my own problem-solving approach is that I tend to experiment quite a lot. I'll write an initial implementation, test it, use print statements or breakpoints to debug, change things around and try different strategies until something starts working.
I'm curious whether this is actually a good approach to developing programming skills, particularly in software engineering, or whether I should be focusing more on developing a theoretically sound solution before touching the code.
For context, I have relatively advanced experience with Java and am currently at an intermediate level with Python, although I'm still getting accustomed to its syntax and revisiting OOP.
One of my high school programming teachers always encouraged me to experiment, make mistakes and learn by tinkering with code rather than worrying about getting everything right immediately.
I'd be interested to hear other people's experiences:
- Is experimentation and trial-and-error a valuable way to develop algorithmic thinking?
- How do experienced programmers balance experimenting with code against reasoning through a solution beforehand?
- At what point does tinkering become unproductive rather than constructive?
- Is it normal to have solved 100+ problems and still struggle to independently derive solutions to unfamiliar Medium problems?
I'd appreciate perspectives from both students and experienced software engineers!
7
u/mooglinux 25d ago
Not just valuable, but THE essential way to learn. You also learn from reading as well, but you’ll be best served by experimenting with implementing what you read to cement your knowledge
5
u/desrtfx 25d ago edited 25d ago
That's how entire generations of programmers learnt before the internet with its countless tutorials and courses existed. We experimented. We fooled around. We failed. We traced. We debugged. We eventually succeeded.
So, yes, this is an excellent way of improving your problem solving skills. Way better than grinding Leetcode and the likes.
3
u/the_duke_man 25d ago
One tip is to not start with code but instead write comments. Write out in comments what each part of the algorithm should do. This is a description of the what and result, not the how. Iterate on that until you have a good mental model of the full algorithm. Then you can focus on the code (the how) without trying to build the mental model at the same time.
3
u/Regular_Antelope7381 25d ago
tinkering is good, the trap is when it turns into changing random stuff until the tests pass and you can't say why it works. one thing that helped with unfamiliar mediums: before writing anything, write the brute force in plain english and figure out exactly which part makes it slow. that slow part is usually the hint you'd otherwise go looking for
2
u/NomaTyx 25d ago
easy is usually a question of "do you know the existence of this data structure" and when you do, the problem becomes trivial. Medium is a question of knowing your algorithms, which is different.
1
u/Kadabrium 25d ago
You cant really tinker with 1 million cuda clicks per second hyperloglog simd whatever concurrency buzzword people use to bash juniors nowadays
1
u/Few-Celebration-2362 25d ago
It's literally THE way to learn problem solving skills as an engineer. You're on the right path for now
1
u/captainAwesomePants 25d ago
Yes, tinkering is fantastic. It lets you get an idea about how things are done, and then it lets you verify that by seeing whether the changes you make do what you expect them to do. Tinkering is one of the best ways to get better at all sorts of skills, programming included.
Tinkering is not an effective way to learn every skill. A great car tinkerer will eventually get very, very good at fixing cars or modding cars, but they will likely never develop the skills to design a new car from scratch or to design a completely novel feature. Same with programming.
Still, on a scale of "good ways to learn" where 1 is "talking about how you'd like to learn" and 2 is "watching YouTube videos," I'd say that tinkering constantly is like a 9.
1
u/dalce63 20d ago
NO!!! Tinkering is one of the WORST things you can do. DO NOT TINKER!!!!
19
u/[deleted] 25d ago
[removed] — view removed comment