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

后端 未结 13 1751
离开以前
离开以前 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:59

    I've enjoyed TDD every since it was introduced to me. Helps me plan out my code, and it just puts me at ease having all my tests return with "success" every time I modify my code, letting me know I'm going home on time today!

    0 讨论(0)
  • 2020-11-30 10:00

    I did something similar.

    • Figure out the rules/logic.
    • Figure out the math.
    • Then try and code it.

    After doing that for a couple of months it just gets internalized. You don't realize your doing it until you come up against a complex problem that requires you to break it down.

    0 讨论(0)
  • 2020-11-30 10:03

    My dad had a bunch of flow chart stencils that he used to make me use when he was first teaching me about programming. to this day I draw squares and diamonds to build out a logical process of how to analyze a problem.

    0 讨论(0)
  • 2020-11-30 10:04

    Keep in mind, if you get 5% off then another 5% off, you don't get 10% off. Rather, you pay 95% of 95%, which is 90.25%, or 9.75% off. So, you shouldn't add the percentage.

    0 讨论(0)
  • 2020-11-30 10:05

    the old-school OO way:

    • write down a description of the problem and its solution
    • circle the nouns, these are candidate objects
    • draw boxes around the verbs, these are candidate messages
    • group the verbs with the nouns that would 'do' the action; list any other nouns that would be required to help
    • see if you can restate the solution using the form noun.verb(other nouns)
    • code it

    [this method preceeds CRC cards, but its been so long (over 20 years) that I don't remember where i learned it]

    0 讨论(0)
  • 2020-11-30 10:09

    I think there's a better way to state your problem.

    Instead of defining it as 'a system,' define what is expected in terms of user inputs and outputs.

    "On a window, a user should select an item from a list, and a box should show him how much it costs."

    Then, you can give him some of the factors determining the costs, including sample items and what their costs should end up being.

    (this is also very much a TDD-like idea)

    0 讨论(0)
提交回复
热议问题