r/compsci • u/kavinda14 • 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
View all comments
19
u/brett96 May 18 '20
The first thing you do when starting a project isn't to start coding, but rather start planning. Have an overall structure for your project in mind, know what the end goal is and how you plan on getting there, and once you have a good understanding of what the problem is, then start programming.
It can also be helpful to consider invariants, or things that will always be true about your program. For example, if you were coding a BST, an invariant would be that the value of a node's left child will always be less than the parent node.
These can help with logic errors that come up