I’ve tried two different methods of reusing code. I have a solution full of just class library projects with generic code that I reuse in almost every project I work on. When I get to work on a new project, I will reuse code from this code library in one of two ways:
- I have tried bringing the projects I need from this code library into my project.
- I have also tried compiling down to a .dll and referencing the .dll from a folder in the root of my current solution.
While the second method seems easier and lighter to implement, I always find myself making small tweaks to the original code to fit it into the context of my current project.
I know this is a bit of a vague question, but has anyone had success with other methods of reusing class libraries on new solutions?
In short, what you are doing is right, you want to move the common code into a class library (DLL) and then reference that in any projects that require its logic.
Where you are going wrong is that you are not maintaining it. If you need to make little "tweaks", subclass your existing code and extend it, dont change it.. If there are major changes needed, then re-think the design.