Shared/Common code and Source Control
-
I'm wondering how other people manage common, utility or shared code? Say some extension method's etc. Do you just add a file with this code and share it amongst your projects? Do you have a snippet type program and just copy/paste into/out of that? Or do you build up a separate library and reference that? If you do the latter how much do you put in, i.e. do you think there's an issue with that library containing much more code than you need?
-
I'm wondering how other people manage common, utility or shared code? Say some extension method's etc. Do you just add a file with this code and share it amongst your projects? Do you have a snippet type program and just copy/paste into/out of that? Or do you build up a separate library and reference that? If you do the latter how much do you put in, i.e. do you think there's an issue with that library containing much more code than you need?
By definition common code can not be snippet - snippet is for repeated code structures not for repeated code! IMHO the best way is a separate library. I'm also do such utility methods stateless an static. I'm also think that there is no such a thing too large library - it only a matter of code organization. There is nothing wrong with a single library with thousands of methods (if the project requests it) as long as the methods are organized...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
I'm wondering how other people manage common, utility or shared code? Say some extension method's etc. Do you just add a file with this code and share it amongst your projects? Do you have a snippet type program and just copy/paste into/out of that? Or do you build up a separate library and reference that? If you do the latter how much do you put in, i.e. do you think there's an issue with that library containing much more code than you need?
Similar to Eliyahu, I prefer a Utility library for such code. I'd write one file for each type which gets extended by an extension method (my way of code organisation). Similarly, other utility methods get grouped into files by their underlying business object.
-
By definition common code can not be snippet - snippet is for repeated code structures not for repeated code! IMHO the best way is a separate library. I'm also do such utility methods stateless an static. I'm also think that there is no such a thing too large library - it only a matter of code organization. There is nothing wrong with a single library with thousands of methods (if the project requests it) as long as the methods are organized...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
Thanks for that, I went down that route, and created a set of libraries by function (IO/data/etc) rather than one large single library.
You may consider an other addition to that... I'm creating my libraries in a totally different solution (no as part of my main development solution) than create a local nuget package from the outcome and add it as reference - that handles me all the necessary dependencies an updates every time I update the util libraries...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
-
I'm wondering how other people manage common, utility or shared code? Say some extension method's etc. Do you just add a file with this code and share it amongst your projects? Do you have a snippet type program and just copy/paste into/out of that? Or do you build up a separate library and reference that? If you do the latter how much do you put in, i.e. do you think there's an issue with that library containing much more code than you need?
Depends. First, one be sure that the shared code really should be shared. The fact that it seems like it is common functionality doesn't necessarily mean that it will remain that way. (Really a bad idea to start adding conditional logic to control different logic flows due to different applications.) Second, how is the rest of the business applications structured. Primary if you have two applications X and Y that you want to use your common code M, do X and Y have their own delivery schedules or are they always delivered together. If they have their own deliver schedules then a common library MUST have its own delivery schedule as well. That is the only way to insure that X is using the version of M that it was developed with and Y is doing the same. Third if different deliver schedules are needed then one must deal with different versioned apps, and if one must deal with git as the source control system then one has a problem since git only deals with that via different repositories. There are additional issues depending on what language is being used and how applications are delivered.
-
I'm wondering how other people manage common, utility or shared code? Say some extension method's etc. Do you just add a file with this code and share it amongst your projects? Do you have a snippet type program and just copy/paste into/out of that? Or do you build up a separate library and reference that? If you do the latter how much do you put in, i.e. do you think there's an issue with that library containing much more code than you need?
I have a separate project in my solution that contains such code i.e. code that is shared across other parts of the application. This can then be distributed as a self contained assembly. If using .NET then you have the option of placing this assembly in the GAC where other applications can also use the same functionality.