How do programmers practice code reuse

前端 未结 14 1290
天涯浪人
天涯浪人 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:42

    I think the best way to answer your problem is that create a separate assembly for your important functions.. in this way you can create extension methods or modify the helper assemble itself.. think of this function..

    ExportToExcel(List date, string filename)

    this method can be use for your future excel export functions so why don't store it in your own helper assembly.. i this way you just add reference to these assemblies.

提交回复
热议问题