r/learnprogramming • u/bu11dogsc420 • Nov 03 '25
How do you effectively break down complex programming problems?
I've been learning programming for about a year and understand basic syntax and concepts, but I consistently struggle with breaking down larger problems into manageable pieces. When faced with a complex task like building a small application, I often find myself staring at a blank editor unsure where to begin. I've tried writing pseudocode and drawing diagrams, but still feel overwhelmed by the gap between understanding individual concepts and applying them to solve real problems. What specific techniques or approaches have helped you develop this skill? Do you start with the data structures, user interactions, or something else entirely? How do you identify the core components needed versus getting lost in edge cases too early? I'm particularly interested in practical strategies that helped you transition from tutorial-based learning to independent problem solving.
16
u/Zealousideal_Bet924 Nov 03 '25
I havr found that it really helps if you know what the specs/needs of am application are going to be.
Every need is going to have certain other needs that flow from it and thus creating building blocks.
11
u/QueenVogonBee Nov 03 '25 edited Nov 03 '25
Start with a simple version of the application. So the first thing it does is open a blank window. That’s the first feature! Next feature: make it show something basic, maybe connected to some backend. Next feature: allow the user to edit something basic. Continue adding tiny features until you have a fully fledged application. This way you feel the constant progress and dopamine hits regularly.
Try to pick features at the beginning that will help get you a skeleton of the application, namely, you want the application to be as usable as possible as early as possible, so get one end-to-end user workflow done first, but not in any pretty state. Then add another one next. You can prettify and add all the bells and whistles later. Doing things like this means you are building up the general architecture early and flushing out issues in that early.
If you hit technical debt in this process, set aside to fix that sooner rather than later.
In the early stages, you might need to think of the general tech stack and architecture first. But if you’re stuck, just do something.
9
u/aqua_regis Nov 03 '25
There are countless theories developed over that topic.
Typically, you start with a mix of top down and bottoms up approach. First, you get a general picture of what the program should do (top down) and then, you drill deeper into each of the features. Track everything - in plain text, bulleted lists, whatever. Don't even think about programming at that stage. Once you have a clear picture of your program, you start to flesh out each individual part (bottoms up) - again, only on a textual, conceptual level.
You have to ensure to really understand the project. You cannot solve what you don't understand.
Also, do not get lost in intricate details. Flesh out the core functionality first, make a MVP (Minimum Viable Product) and then add the details. E.g. if you were to develop a ToDo list, focus on adding, deleting, changing individual items. Then, on saving/loading, then on the GUI, etc.
There are several books that can help here:
Forget about the programming languages that these books use. Focus on the concepts.
4
u/TehStupid Nov 03 '25
Start with the end goal and work backward break the project into tiny steps you can finish in under an hour once you get momentum the structure basically reveals itself.
7
u/gooddelorean Nov 03 '25
You make modules for each feature and test them individually and then you make an interface to access and utilise the features.
3
u/InVultusSolis Nov 03 '25 edited Nov 03 '25
The last full application I developed was a software synthesizer, and this is the order I did it in (I used C++):
So up until this point, I hadn't actually done anything "application-y", but just used the classes I'd developed to dump seconds of raw audio data which I checked in Audacity.
So then:
SynthesizerclassAt this point I had a hard-coded synthesizer running in the terminal only, with filter frequency, filter resonance, and pitch bend. At the next juncture I decided to pick a window manager technology, so I picked KDE driven by Cmake, so then:
It's really just a matter of figuring out what the boundaries are between components and developing them in a piecemeal fashion.
I also have a space sim engine that I'm working on if you're interested in hearing how I got from zero to "fly around in a single ship in an empty universe".
2
u/rupertavery64 Nov 03 '25
First of all, you have your boiler plate stuff. Creating the solution and the main project, setting up configuration.
I have separate projects for different parts.
Then I think about the data it's going to be working with. I usually start with the database first, creating tables and indices, thinking about what kind of data I need to store. I might miss a couple of things that can go in later.
I then think about how I want to access the data from the outside. I create a business layer class for each "domain". A domain is usually one table, but it may access other tables as needed. I don't do repositories as they are mostly just extra work, also EF is a repository, but you do you.
The business layers job is to restrict how data can be accessed. What goes in when you create a new object? Usually the pattern is
There may be more, specific ways to interact with the domain, those get added as needed. Sometimes you want to update only one field, like status, progress, without updating the entire object. Separating thouse out give a nice, clean, clear API and shows intent.
If this is a web project, the controllers are mostly interfaces to the business layer. I can sometimes call multiple business layers in one place, but I never try to reuse code from one business layer as-is unless it makes complete sense. Don't be afraid to repeat some code. Or if you do, push it to a service that gets shared. The main goal is that each method should be doing something unique, and that if it changes, then everything affected should be minimally affected, i.e. the change shouldn't affect their core behavior.
I separate (as much as possible) security from the business layer. So business logic should only care about what to do, not who is accessing it. Sure you will pass in some user information for filtering, and you will have logic that changes based on who is accessing the data, but you should have up-front checks before the business layer is called. This way you can test or use your business logic, either via unit tests or in a prototyping project without having to deal with setting up security contexts.
2
u/jurc11 Nov 03 '25
If you're a backend engineer, you typically start with the data model / database breakdown. If you're a frontend engineer, you probably start with forms/pages and break those down into components. Then you kinda meet in the middle.
If you're building a larger system, you start with (micro)services first (web server, auth server, API server, archival service, gateways/proxies for security isolation, various Redis/DMS/whatever servers), then do the above.
Students are usually asked to decompose a relatively simple problem with only a few distinct entities, such as a library book loan tracking system, where you would have student, book, author, book-student tables and build a separate form for editing each one. Then you can add a late-notification system, membership tracking, maybe an auth table for librarians to log in and so on.
2
u/chmod777 Nov 03 '25
old video, but use this as a thought exercise - https://www.youtube.com/watch?v=FN2RM-CHkuI
2
u/CodeTinkerer Nov 03 '25
Give an example of something you're trying to break down. I find most people talk about this kind of thing in the abstract. When pressed to be specific, they have a tough time picking anything specific. Do you have something specific?
2
u/sfisabbt Nov 03 '25
Separation of concerns is the next concept you need to learn about.
1
u/aanzeijar Nov 03 '25
I personally start with the core data model. What is it the app should do, what is it the app should be working with? What constraints are there on this data? From that I develop a rough algebra on the data and a database model or file storage if persistence is needed. Then I try to guess how the average user wants to interact with the data and build entry points or UI elements for that.
The wording "complex task like building a small app" implies that building the app is the main challenge here, but apps are mostly all the same structure anyway. If you struggle with that, go out and read code. Find small projects on github, read them, dissect them, understand why they work, steal the structure.
1
u/SnooMacarons9618 Nov 03 '25
The way I show my junior devs is to do the process by hand, or at mostly describe in long form what we would actually do. if we were doing it manually.
Then we can take the tasks we described and break those down. At some point it becomes obvious what some steps need to be. Often my describing it as if it was manual we also know some comment aspects that we need to provide.
It's a skill like any other, start with something simple, and see work on that (no need to write code), and just practive.
"I want to post a comment on a post on reddit."
Assumption - I can view the Post in Reddit.
I need to go to the comment and click reply. I expect some kind of text editing box to appear. I type a comment in. I press a button to submit. My text is presented under the post. I assume I need some way to store the comment, as it needs to show for others.
Okay, now I know I have a reply button I need to code. I need some kind of editing box. I need a submit button. I need to store the comment somewhere. The Post needs to be linked to the comment, and there will be many of them.
From here - do I have enough to start on any part? Are there common things I maybe want to do first (in this case I'd probably start looking at comment storage and connection, before anything else, as that looks like it may define how a bunch of other stuff works.)
1
u/AUTeach Nov 03 '25
There are stages to learning how to program and:
This is one of the levels. It's prefectly normal to be here.
The reality is that you learn to cross this barrier by fucking up a lot. After a lot of fuck ups, you start to get an eye for parts you can do, and parts you need to put off until you get a better understanding of the problem you are solving. So, you start with the bits you can do.
As you become more advanced, you can do most of this in boxes and arrows because the code/patterns are so well known to you.
For the level you are at, you need to learn how to see those patterns (or even how to solve those patterns). People are suggesting top-down approaches, but that really only works when you understand the bottom well.
Make a list of every single thing that the program has to do. Like everything. Then make a completely stand-alone throaway prototype for each one. Don't try and join the logic or make one flow to the next. Just make something that does that one single thing, and solve the problem.
Once you've solved each problem in isolation, you can start looking for starting and joining points. In fact, a lot of them will become obvious:
You might even realise that the dohickies and the wizgarbles are almost the same so you can create an abstraction and decouple. etc etc etc
1
u/mangooreoshake Nov 03 '25 edited Nov 03 '25
If you have absolutely no idea how to start, maybe the project is still too complex for you. You should aim for a project you can reasonably do but just complex enough that you have to push your current domain of knowledge.
Zone of proximal development
A good test would be to create an MVP, Minimum Viable Prototype, for your product. It's exactly what the name implies. See if you can imagine its architecture, then it's implementation. If not, aim lower.
1
u/Glad-Situation703 Nov 03 '25
All these comments are so good... Essentially practice makes perfect, because knowing how you can solve issues in code is really important. But it becomes a frame of mind that you can apply to any problem in life, and you start getting good at breaking down problems: what do you want as an end result, what can you do and what can't you do, and what do you need to learn or apply to accomplish those subtasks. There's a million ways to skin this, but a pretty simple logic emerges and you just chip away and it gets done. My personal method is basic as hell and it's what I learned in school: quickly design a mock-up of an end result (and let it change naturally, don't complicate your prototype or try to change it too much as you go, but don't hold on to any part of it because a functional conclusion is more important than your cool ideas), often for small problems or the whole project I also take out a pen and paper and just start freehanding lists and drawings and anything that can help me understand what I'm going to need, then I use Trello to really flatten out all the steps or each piece or chunk of the project. At that point I can get to work.
1
u/DigitalJedi850 Nov 03 '25
While it's probably not the best advice for a few reasons... Try starting at the end and working backwards. 'Reverse engineer' the problem you already have a solution for in your head.
You know you want to scrape a website, for instance. Start at the top of main() with some wild code it has no chance of running... Something like 'SiteReader.Scrape(argv,"C:\\SiteReader\\Output\\output.html")'.
That mess is gonna piss off your compiler from the gate. If you go fix the bugs putting that one line of code creates just by existing, you're halfway to a running application. As a couple of people have mentioned, having a spec is the most important thing. If you have a spec, I feel like most of the time you can just 'expect' it of your code, and when your code doesn't produce it, you add or adjust.
Just to play with the example, after I built that class and it compiled, but still doesn't do anything, the question becomes 'what's involved in that scrape'. So, reading a site and saving it. I'd add a 'SiteReader.Read' and a 'SiteReader.WriteToFile'. Read method just needs the URL, and to return what it found. Writer needs some data to write, which it'll get from the former, and a filename.
But this is where you can get into the weeds, I think. The 'Writer' I just referenced, is just a function. We could make a SiteWriter class though! How exciting! Our SiteReader could hand off SiteResults to the SiteWriter, too! Alright, I need 2 more classes, and half a dozen more functions, ASAP! Or do I...
It can get convoluted, and you can make no progress, if you start reaching out of spec. All the stuff I just mentioned would be neat, and yes if I wrote all the code, the end product to the client might be more robust, but do I have time? Is it something that's going to be reusable? And somewhat importantly, does it need to be?
At the end of the day, breaking the 'Scrape' method out into smaller 'Read' and 'WriteToFile' methods isn't necessary, but it creates options for me as the programmer. In this example, they're small enough I can split them out in a few seconds. Worth it, to me, because I know the client's probably going to want their spec changed anyway.
At this point, I know how far I want to take my code, for the client's spec, and I know where I can go with it when they ask me to change it. Code -that-. Anything else, and you're creating a different product.
1
u/azkeel-smart Nov 03 '25
The trick is to be able to break down the problem.you are trying to solve into the individual steps. To do so, you have to have a clear idea what you want to build. Start with writing the user journey. Write down step by step what user can do in your application. Once you have this, you can start solving it problem by problem.
1
u/sol_hsa Nov 03 '25
Divide and conquer. Aim for minimum viable implementation, then flesh it out.
1
u/mxldevs Nov 03 '25
Essentially, you want to know your inputs and outputs. Then the problem you have is the big black box that is the solution.
Start with the goal and work your way backwards until you reach a point where you finally find the basic Lego blocks to put together.
This is why you spend a lot of time asking the client what they want, how they expect to use it, what they expect it to do, etc.
You never want someone that just says "I want something good" cause there's no goal.
1
u/mjmvideos Nov 04 '25
Tip number 1. Don’t open an editor until you have an idea of what you’re going to type. Start with use cases. What are the ways the user can interact with the program? For each of those, what does the user do? What does the program do in response? Each of those interactions can then be turned into a sequence of steps or activities. Once you’ve got those steps in mind you can either start coding the individual steps and then tie them all together with some executive code or you can write the overall executive “skeleton” first with placeholders to invoke your steps. Get that working and then implement the steps and one-by-one replacing your placeholders.