<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: How (And Why?) To Wrap External Libraries?	</title>
	<atom:link href="https://www.codejourney.net/how-and-why-to-wrap-external-libraries/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codejourney.net/how-and-why-to-wrap-external-libraries/</link>
	<description>Pragmatic full stack software development</description>
	<lastBuildDate>Thu, 24 Aug 2023 15:49:04 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>
		By: Dawid Sibiński		</title>
		<link>https://www.codejourney.net/how-and-why-to-wrap-external-libraries/#comment-244</link>

		<dc:creator><![CDATA[Dawid Sibiński]]></dc:creator>
		<pubDate>Sun, 05 Mar 2023 16:36:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.codejourney.net/?p=4346#comment-244</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.codejourney.net/how-and-why-to-wrap-external-libraries/#comment-243&quot;&gt;Dmytro&lt;/a&gt;.

Hi Dmytro, thanks for your comment.
Extremism is always bad  <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" />  I don&#039;t recommend wrapping &lt;em&gt;every&lt;/em&gt; library. I wouldn&#039;t even think about abstracting stuff like &lt;strong&gt;mobx&lt;/strong&gt; or &lt;strong&gt;react-hook-form&lt;/strong&gt;. This would lead to - as you mentioned - having hundreds of wrappers with probably more logic inside the wrappers themselves than the actual library provides.

Referring to your first remark - if the wrappers are implemented incorrectly, i.e. having a lot of logic inside them instead of only exposing the 3rd party code with minimum amount of own code, then I&#039;d agree it is a nightmare debugging this. However, to me, a wrapper should be minimalistic in a way that no documentation is needed for it. It only acts as a proxy to the external code. I create wrappers only for stuff that can be exposed via simple API, without much additional logic inside.

Regarding the second point - I had pretty different experiences here  <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" />  I saw external libraries used so extensively in the code that no one would even think about replacing them. And that&#039;s often problematic.
If you need to change your wrapper&#039;s API because of the changes in the wrapped library, then you either didn&#039;t think abstract enough when creating the wrapper or you shouldn&#039;t have created it in the first place (see my previous remarks about what not to wrap).
 
Wrappers&#039; role is not only to hide the 3rd party implementation details. They let you &lt;em&gt;think first, use later&lt;/em&gt;. First: think which features of a library you might need, try to abstract them (in a form of &lt;em&gt;contract&lt;/em&gt;). Later: use the contract&#039;s implementation(s) in your code.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.codejourney.net/how-and-why-to-wrap-external-libraries/#comment-243">Dmytro</a>.</p>
<p>Hi Dmytro, thanks for your comment.<br />
Extremism is always bad  🙂  I don&#8217;t recommend wrapping <em>every</em> library. I wouldn&#8217;t even think about abstracting stuff like <strong>mobx</strong> or <strong>react-hook-form</strong>. This would lead to &#8211; as you mentioned &#8211; having hundreds of wrappers with probably more logic inside the wrappers themselves than the actual library provides.</p>
<p>Referring to your first remark &#8211; if the wrappers are implemented incorrectly, i.e. having a lot of logic inside them instead of only exposing the 3rd party code with minimum amount of own code, then I&#8217;d agree it is a nightmare debugging this. However, to me, a wrapper should be minimalistic in a way that no documentation is needed for it. It only acts as a proxy to the external code. I create wrappers only for stuff that can be exposed via simple API, without much additional logic inside.</p>
<p>Regarding the second point &#8211; I had pretty different experiences here  😉  I saw external libraries used so extensively in the code that no one would even think about replacing them. And that&#8217;s often problematic.<br />
If you need to change your wrapper&#8217;s API because of the changes in the wrapped library, then you either didn&#8217;t think abstract enough when creating the wrapper or you shouldn&#8217;t have created it in the first place (see my previous remarks about what not to wrap).</p>
<p>Wrappers&#8217; role is not only to hide the 3rd party implementation details. They let you <em>think first, use later</em>. First: think which features of a library you might need, try to abstract them (in a form of <em>contract</em>). Later: use the contract&#8217;s implementation(s) in your code.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dmytro		</title>
		<link>https://www.codejourney.net/how-and-why-to-wrap-external-libraries/#comment-243</link>

		<dc:creator><![CDATA[Dmytro]]></dc:creator>
		<pubDate>Sun, 05 Mar 2023 08:00:54 +0000</pubDate>
		<guid isPermaLink="false">https://www.codejourney.net/?p=4346#comment-243</guid>

					<description><![CDATA[Oh, how much those bull*t I saw in all my recent projects
What this approach actually brings to the table:
1. For each new developer: instead of looking into the library itself (usually well-documented), you need to debug a custom wrapper (usually not documented). What if you have 30 external libraries (and wrappers)? Or 100+? 
2. How often do you really need to replace libraries in your project? I can&#039;t remember any strong case in about 9 years of my work (including positions as Senior/Tech lead). And do you think you wouldn&#039;t need to change your wrapper&#039;s interface (API) in case of some drastic change? 

This works in only one particular case - if you are ready to support and spend time on documentation for your wrapper. Elsewhere, it will cost you (mostly new developers in a team) a lot of headaches.]]></description>
			<content:encoded><![CDATA[<p>Oh, how much those bull*t I saw in all my recent projects<br />
What this approach actually brings to the table:<br />
1. For each new developer: instead of looking into the library itself (usually well-documented), you need to debug a custom wrapper (usually not documented). What if you have 30 external libraries (and wrappers)? Or 100+?<br />
2. How often do you really need to replace libraries in your project? I can&#8217;t remember any strong case in about 9 years of my work (including positions as Senior/Tech lead). And do you think you wouldn&#8217;t need to change your wrapper&#8217;s interface (API) in case of some drastic change? </p>
<p>This works in only one particular case &#8211; if you are ready to support and spend time on documentation for your wrapper. Elsewhere, it will cost you (mostly new developers in a team) a lot of headaches.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
