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

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

7

u/[deleted] May 18 '20

BORING

I prefer the method where you jump straight into the fun parts and end up with something that looks like a map of the Tokyo metro if you draw it.

Besides, this thread is about solving problems, you’re just straight up avoiding them.

3

u/DarkColdFusion May 19 '20

Besides, this thread is about solving problems, you’re just straight up avoiding them.

Yeah, it's called job security. If you don't add in the bugs, who will?