How do I design a class in Python?

后端 未结 6 1650
终归单人心
终归单人心 2021-01-29 16:59

I\'ve had some really awesome help on my previous questions for detecting paws and toes within a paw, but all these solutions only work for one measurement at a time.

No

6条回答
  •  臣服心动
    2021-01-29 17:31

    The following advices (similar to @S.Lott's advice) are from the book, Beginning Python: From Novice to Professional

    1. Write down a description of your problem (what should the problem do?). Underline all the nouns, verbs, and adjectives.

    2. Go through the nouns, looking for potential classes.

    3. Go through the verbs, looking for potential methods.

    4. Go through the adjectives, looking for potential attributes

    5. Allocate methods and attributes to your classes

    To refine the class, the book also advises we can do the following:

    1. Write down (or dream up) a set of use cases—scenarios of how your program may be used. Try to cover all the functionally.

    2. Think through every use case step by step, making sure that everything we need is covered.

提交回复
热议问题