How do programmers practice code reuse

前端 未结 14 1249
天涯浪人
天涯浪人 2021-02-13 14:14

I\'ve been a bad programmer because I am doing a copy and paste. An example is that everytime i connect to a database and retrieve a recordset, I will copy the previous code and

相关标签:
14条回答
  • 2021-02-13 14:43

    Check out Martin Fowler's book on refactoring, or some of the numerous refactoring related internet resources (also on stackoverflow), to find out how you could improve code that has smells of duplication.

    0 讨论(0)
  • 2021-02-13 14:43

    For the example you give, the appropriate solution is to write a function that takes as parameters whatever it is that you edit whenever you paste the block, then call that function with the appropriate data as parameters.

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