They imagine all the possible ways they could solve the problem. They imagine what else the code might do. They imagine what else might be needed to solve the problem. And they try to think about how different solutions might work not only today but also solve problems tomorrow.
The ability to imagine is a critical programming skill. You can practice this skill many ways.
For example, what if I asked you to build a car? What are some questions you would need to answer before you could build your car? Not only questions about shapes and colors, but also what you might need a car to do. For example, maybe your car also is a quiet place to study and get away from people. So your car might be big inside. Or small, cozy, and comfortable.
How many people need to fit into your car? What will you use for fuel? How about an engine, how would that work? If you built a two story car, like a two story house, would that meet your needs?
Or maybe your car simply gets you to school and back. You only need a frame, seats, wheels, a way to steer, and an engine.
Which raises another set of questions: what parts will your car need? Does your car need to go fast? And if you really want to be silly, could you turn a cow or your pet into a car? A cow (or pet) would give you your engine, frame, and wheels but how would you steer? And you’d need a place to store food so your animal could keep moving: where would food be stored?
If you have a pen or pencil and blank paper, write out and draw your questions and answers to define the problem of building your car. Think as deeply as you can about all the possible uses for your car, all possible problems you might encounter today and tomorrow with your car. Then work out solutions and test how well they solve the problems your car needs to solve.
The links below offer more ideas about how to imagine solutions to problems like building a car. There also are a few articles about how people design software programs.
Learn More
Design Thinking
http://www.forbes.com/2010/01/14/tim-brown-ideo-leadership-managing-design.html
http://designthinkingmovie.com/
http://designthinking.ideo.com/?p=409
https://en.wikipedia.org/wiki/Design_thinking
http://www.creativityatwork.com/design-thinking-strategy-for-innovation/
Design Thinking for Educators
http://www.designthinkingforeducators.com/
Design & Thinking (documentary)
http://designthinkingmovie.com/
https://www.youtube.com/watch?v=uilcaXYnluU
IDEO Design Thinking Blog
http://designthinking.ideo.com/
How to Design a Computer Program
http://www.yacoset.com/Home/how-to-design-a-computer-program
http://www.yacoset.com/Home/your-first-programming-assignment
How to Become a Programmer: 8 Steps to Building an App from Scratch
Scroll down to see the full article.
https://www.codementor.io/learn-programming/how-to-build-app-from-scratch-beginner-programmer
Software Systems Development Life Cycle
https://en.m.wikipedia.org/wiki/Systems_development_life_cycle
Software Development Process
https://en.m.wikipedia.org/wiki/Software_development_process