Skip navigation

What are best practices for reusing tiny snippets of code across projects?

Original author: 
Stack Exchange

Stack Exchange

This Q&A is part of a weekly series of posts highlighting common questions encountered by technophiles and answered by users at Stack Exchange, a free, community-powered network of 100+ Q&A sites.

Stack Exchange user and C# developer George Powell tries hard to follow the DRY principle. But as any good dev knows, it's not always possible, or even optimal, to stay original. Powell writes:

Often I write small methods (maybe 10 to 15 lines of code) that need to be reused across two projects that can't reference each other. The method might be something to do with networking / strings / MVVM etc. and is a generally useful method not specific to the project it originally sits in.

So how should you track shared snippets across projects so you know where your canonical code resides and know where it's in production when a bug needs to be fixed?

Read 15 remaining paragraphs | Comments