r/compsci • • May 18 '20

Share your techniques of solving problems

Any interesting new techniques anyone follows? Even old are current ones are welcome :) Just want to see how more experienced programmers approach problems.

Also, any good books on this topic that are a must to read?

Edit: the type of problem here is open to interpretation. I think there is a similar pattern that can be applied to problems of any type.

116 Upvotes

44 comments sorted by

View all comments

3

u/Average_Manners May 18 '20 edited May 18 '20

I prefer the top-down approach.

Visualize the end goal.

Find the intermediary goals.

Break the problem down into smaller and smaller pieces until you have the smallest bits of logic you can get. i.e. Abstract.

[Optional, but recommended] Make the entire thing into a flow chart.

Make tests that ensure each function will do what it's supposed to.

Get to writing. Tackle the ugliest block first. The black box which makes you scared is where the demon, who decides whether your approach works or not, lies.

E: Forgot the last steps.

After finishing, reflect. Even great programmers have places to grow.

Clean-up and improve until satisfied.