Process to pass from problem to code. How did you learn?

后端 未结 13 1782
离开以前
离开以前 2020-11-30 09:40

I\'m teaching/helping a student to program.

I remember the following process always helped me when I started; It looks pretty intuitive and I wonder if someone else

13条回答
  •  生来不讨喜
    2020-11-30 09:49

    I think there are about a dozen different heuristics I know of when it comes to programming and so I tend to go through the list at times with what I'm trying to do. At the start, it is important to know what is the desired end result and then try to work backwards to find it.

    I remember an Algorithms class covering some of these ways like:

    • Reduce it to a known problem or trivial problem
    • Divide and conquer (MergeSort being a classic example here)
    • Use Data Structures that have the right functions (HeapSort being an example here)
    • Recursion (Knowing trivial solutions and being able to reduce to those)
    • Dynamic programming

    Organizing a solution as well as testing it for odd situations, e.g. if someone thinks L should be a number, are what I'd usually use to test out the idea in pseudo code before writing it up.

    Design patterns can be a handy set of tools to use for specific cases like where an Adapter is needed or organizing things into a state or strategy solution.

提交回复
热议问题