{"id":1251,"date":"2021-10-11T09:43:35","date_gmt":"2021-10-11T15:43:35","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=1251"},"modified":"2021-10-11T09:43:35","modified_gmt":"2021-10-11T15:43:35","slug":"copy-paste-is-not-a-code-reuse-strategy","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2021\/10\/11\/copy-paste-is-not-a-code-reuse-strategy\/","title":{"rendered":"Copy &#038; paste is not a code reuse strategy"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Code reuse is an admirable goal for any developer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Being able to re-use well written well tested code is a good thing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Especially if you can reuse it across multiple facets of one project, or across several projects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And I wouldn&#8217;t be surprised if a lot of people start out reusing code using copy paste from one place to another.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, copy paste isn&#8217;t usually a well regarded code reuse technique.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Why not ? <a href=\"https:\/\/stackoverflow.blog\/2019\/11\/26\/copying-code-from-stack-overflow-you-might-be-spreading-security-vulnerabilities\/\">Stack overflow wrote a blog about<\/a> the reasons. You might copy &amp; paste someone else&#8217; insecure code into your projects and thereby introduce security vulnerabilities. That&#8217;s certainly a possibility.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But what if you&#8217;re just copying &amp; pasting your own code around ? Where&#8217;s the harm ?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose you have some code you really think is top notch. And you want to reuse it over &amp; over. Suppose you want to reuse it in the event handler of numerous controls across several projects in Xojo.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And sometime later you find there&#8217;s a bug in it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now how many places do you have to fix in one project ? Or worse across many projects ?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is where copy paste as a code reuse technique can cause you extra work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You have to find &amp; fix all that code in every project you&#8217;ve used it in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I&#8217;ve been using externals in SVN (yes I still use SVN)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And in every project that uses these shared modules its a  simple &#8220;update&#8221; and they have all the latest code from all the shared items.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Git has similar capabilities.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code reuse is an admirable goal for any developer. Being able to re-use well written well tested code is a good thing. Especially if you can reuse it across multiple facets of one project, or across several projects. And I wouldn&#8217;t be surprised if a lot of people start out reusing code using copy paste &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2021\/10\/11\/copy-paste-is-not-a-code-reuse-strategy\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Copy &#038; paste is not a code reuse strategy&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-1251","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=1251"}],"version-history":[{"count":1,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1251\/revisions"}],"predecessor-version":[{"id":1252,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/1251\/revisions\/1252"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=1251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=1251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=1251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}