<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rishabh Joshi</title>
    <description>The latest articles on DEV Community by Rishabh Joshi (@rishabh_joshi_73c4e082fec).</description>
    <link>https://dev.to/rishabh_joshi_73c4e082fec</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4169210%2Fc1256151-6764-4ac8-bb87-c4e2bc33d69e.jpg</url>
      <title>DEV Community: Rishabh Joshi</title>
      <link>https://dev.to/rishabh_joshi_73c4e082fec</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rishabh_joshi_73c4e082fec"/>
    <language>en</language>
    <item>
      <title>Duplication vs. Coupling: When do you actually refactor duplicate code in Python?</title>
      <dc:creator>Rishabh Joshi</dc:creator>
      <pubDate>Wed, 07 Oct 2026 14:56:44 +0000</pubDate>
      <link>https://dev.to/rishabh_joshi_73c4e082fec/duplication-vs-coupling-when-do-you-actually-refactor-duplicate-code-in-python-2ef0</link>
      <guid>https://dev.to/rishabh_joshi_73c4e082fec/duplication-vs-coupling-when-do-you-actually-refactor-duplicate-code-in-python-2ef0</guid>
      <description>&lt;p&gt;When building and maintaining larger Python codebases, one of the classic debates between senior engineers is balancing the &lt;strong&gt;DRY (Don't Repeat Yourself)&lt;/strong&gt; principle against &lt;strong&gt;premature coupling&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Consider a situation where two or three separate modules have identical 10-line boilerplate (for example, database connection lifecycle handling, recurring input validation checks, or retry logic):&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
python
# Seen across module_a.py and module_b.py:
managed: bool = conn is None
if managed:
    conn = init_db(DB_PATH)
try:
    yield conn
finally:
    if managed:
        conn.close()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>python</category>
      <category>architecture</category>
      <category>programming</category>
      <category>discuss</category>
    </item>
  </channel>
</rss>
