How to Create/Use Reusable Code

Feb 5 2009 8:28 PM
I am reaching the point in my application where I find myself copying code and making slight modifications to it. I realize that there are ways to create code that can be reused. The changes I am making each time I copy the code could be sent as parameters when I call that code.

My problem is that I don't know how to do it or where to put it. I don't know the proper terms to use to research the topic.

I have a C# application with several windows forms. I create new forms and put all my code within the .cs file for those forms. I am working exclusively with private void classes and really need to expand my knowledge.

I hope that some of you can point me in the right direction by telling me the proper terminology for what I'm trying to do so that I can research the topic. Details would be great to, but I'd really appreciate help with terms/names for the things I need to know for creating reusable code within my project.

For a bit of specifics about what I'm doing: I'm using VS2008. My application is an interface to a SQL Express database. I have created code for adding/modifying/deleting records based on user inputs. As I create new forms, I often want to call the same code I have used for other forms. I need to know how to put that code in some global location or class so that it can be called from individual forms and not copied into each form's .cs file.

Thanks.

Answers (4)