<?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>Forem: Debjit Biswas</title>
    <description>The latest articles on Forem by Debjit Biswas (@neoxdebjit).</description>
    <link>https://forem.com/neoxdebjit</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1549997%2Ffac17b46-9f2b-4468-89dd-81fd53d53fb3.png</url>
      <title>Forem: Debjit Biswas</title>
      <link>https://forem.com/neoxdebjit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/neoxdebjit"/>
    <language>en</language>
    <item>
      <title>Why 100 lines of code is sometimes better than 2 lines of code</title>
      <dc:creator>Debjit Biswas</dc:creator>
      <pubDate>Sun, 04 May 2025 07:49:42 +0000</pubDate>
      <link>https://forem.com/neoxdebjit/why-100-lines-of-code-is-sometimes-better-than-2-lines-of-code-589d</link>
      <guid>https://forem.com/neoxdebjit/why-100-lines-of-code-is-sometimes-better-than-2-lines-of-code-589d</guid>
      <description>&lt;p&gt;In the world of programming, there's often a race to write the most "concise" or "clever" code. But sometimes, trying to squeeze logic into as few lines as possible can actually hurt more than help.&lt;/p&gt;

&lt;p&gt;Let's talk about why writing 100 lines of clean, readable code is often better than a 2-liner magic trick, with real-world examples to back it up.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Myth: Less code &amp;gt; More code
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
It's tempting to think:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"If I can do this in 2 lines, why write 100?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But here’s the truth:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Short code is not always readable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It’s harder to debug&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's often less maintainable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It usually lacks context, error-handling, and clarity&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s look at some real-life analogies and coding scenarios to understand this better.&lt;/p&gt;

&lt;p&gt;Let's give some data:&lt;/p&gt;

&lt;p&gt;You can code minesweeper with less than 100 lines of code.&lt;/p&gt;

&lt;p&gt;To code Windows 10, you need over a million.&lt;/p&gt;

&lt;p&gt;The amount of lines has absolutely nothing to do with how good your product is.&lt;/p&gt;

&lt;p&gt;The three pillars of coding: Speed, Space, Length.&lt;/p&gt;

&lt;p&gt;The best you can get is two out of three.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;payment_gateway.charge(card, amount)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Would you trust this line of code for your lakhs and crores of transaction.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import razorpay

# Initialize the Razorpay client with your key ID and secret
client = razorpay.Client(auth=("YOUR_KEY_ID", "YOUR_KEY_SECRET"))

# Create an order
data = {
    "amount": 50000,  # Amount in paise (e.g., 50000 paise = ₹500)
    "currency": "INR",
    "receipt": "order_rcptid_11"
}
order = client.order.create(data=data)
print("Order created:", order)

# In a real application, you would typically store the order ID in your database
order_id = order['id']

# Example of capturing a payment (this would be done after the customer has authorized the payment)
payment_id = "YOUR_PAYMENT_ID" # Payment ID obtained after successful payment
try:
    client.payment.capture(payment_id, {"amount": 50000, "currency": "INR"})
    print("Payment captured successfully")
except Exception as e:
    print("Error capturing payment:", e)

# Example of checking payment status
try:
    payment = client.payment.fetch(payment_id)
    print("Payment details:", payment)
    if payment['status'] == 'captured':
        print("Payment was successful")
    else:
        print("Payment failed or is pending")
except Exception as e:
    print("Error fetching payment:", e)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I would rather trust this piece of code for even my 200 Rupees payment.&lt;/p&gt;

&lt;p&gt;💡 Real-Life Analogy: Fast Food vs. Home-Cooked Meal&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🍔 A burger from a fast-food joint is quick and compact (like 2 lines of code).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🥘 A home-cooked meal takes time, but it’s healthier, customized, and you know what’s inside (like 100 lines of readable, maintainable code).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Absolutely. What matters is you have the right amount of code to solve your problem.&lt;/p&gt;

&lt;p&gt;"Everything should be as simple as possible, but not simpler."&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
