<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Swapnoneel Saha]]></title><description><![CDATA[I build tools that make developers faster and help startups grow. I specialize in building agentic workflows, OSS infrastructure, high-performance web systems, and creating technical content. I've spent years building products used by thousands, from developer-facing infrastructure at Keploy and Wizdom to building the user base for early-stage startups. My work sits at the intersection of agentic AI, open-source ecosystems, and growth engineering.]]></description><link>https://swapnoneel.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 23:53:15 GMT</lastBuildDate><atom:link href="https://swapnoneel.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How I made an AI Agent write in my voice]]></title><description><![CDATA[You can make AI write in your voice, but a prompt won't get you there.]]></description><link>https://swapnoneel.hashnode.dev/how-i-made-an-ai-agent-write-in-my-voice</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/how-i-made-an-ai-agent-write-in-my-voice</guid><category><![CDATA[AI]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Tutorial]]></category><category><![CDATA[Blogging]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Mon, 06 Jul 2026 10:30:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/63d030c779a109e4ff1581c1/ff048b85-b181-40b7-af5b-ae8e8d1c667d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let's be honest, AI-written blogs have a certain... vibe. You know it, I know it, and your readers can smell it from the very first paragraph.</p>
<p>But here's my take: you can make AI write in your voice, just not with a "generic" prompt. What actually worked for me is an agent skill with three parts: a voice profile built from seven of my real writing samples, a kill list of AI phrases, and a feedback loop that turns my edits into permanent rules. And here comes the twist, the blog you are reading right now is the very first output of that system!</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/28o1zintr6j86wowkvn0.png" alt="Hand-drawn illustration showing why a generic AI prompt creates bland writing, while a voice system with profile, kill list, and feedback loop creates personal output." /></p>
<p>So, let me walk you through exactly how I built it, and you can judge for yourself whether it sounds like a human or not.</p>
<h2>Why does AI writing sound so... AI?</h2>
<p>Before fixing the problem, let's understand it from the ground up.</p>
<p>An LLM is trained on billions of documents, so by default, it writes like the average of all of them. That's where phrases like "in today's fast-paced world"s come from, and those perfectly balanced conclusions that never pick a side. It's not that the model is dumb. It's that the average of a million voices is no voice at all.</p>
<p>And your voice is the exact opposite of average. It's the specific way you break grammar rules, and the things you're willing to admit that others won't.</p>
<p>I've written multiple technical blogs for different startups including Keploy, Devbytes and many more, and have been blogging on Hashnode since 2023. So when I asked AI to draft posts "in my style" with a simple prompt, the result was always the same: grammatically perfect, structurally neat, and absolutely not me.</p>
<h2>So, can you actually make AI write in your voice?</h2>
<p>Well, yes. But you have to show it, not describe it.</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/3s98sgz7952omd3ajmg3.png" alt="Minimal sketch of an AI voice system extracting writing mechanics from real blog samples instead of relying on vague tone instructions." /></p>
<p>"Write in a friendly, conversational tone" gives everyone on the internet the same friendly, conversational tone. What you need instead is a system that extracts the mechanics of your writing from real samples, and then enforces them like rules. Mine has three parts.</p>
<h3>Part 1: The voice profile</h3>
<p>I gave the agent seven samples of my writing: two journey blogs, one tutorial, one opinion piece, one comparison, three cold intros, and a small questionnaire about my tastes. And these are not just "any" samples, three of them are my past works that was cherry-picked by the system. And the other four were literally the topics given to me by Fable 5, so that it can understand my writing style better.</p>
<p>But here's the important part, the profile it built isn't a list of adjectives. It's mechanics:</p>
<ul>
<li>My sentences constantly open with And, But, So, and Now (this exact paragraph included).</li>
<li>My posts move forward by asking the reader's next question, and then answering it.</li>
<li>Every big claim needs a personal receipt with a number, not a vague "many developers say".</li>
<li>At most two "!!" per post. Yes, it literally counts them.</li>
</ul>
<p>And one more thing: newer samples always outrank older ones. My 2023 writing had habits I've dropped since, and the system knows my current voice wins every conflict.</p>
<h3>Part 2: The kill list</h3>
<p>The second file is a banned-patterns list. Every AI-ism I hate goes there: "delve", "seamless", "game-changer", rule-of-three sentences, em-dash chains, hedged conclusions that refuse to pick a winner, and emojis (all of them, I don't use emojis in my blogs, period).</p>
<p>The rule is zero tolerance. If a banned pattern shows up in a draft, the agent doesn't just delete it, it rewrites the sentence the way I would say it.</p>
<h3>Part 3: The feedback loop (this is the part that actually matters)</h3>
<p>Now, the first two parts get you maybe 80% of the way. The remaining 20% is where every "write like me" tool I've seen gives up.</p>
<p>Here's my loop: the agent writes a draft, I edit it like I normally would, and then a second skill diffs my final version against the draft. Every meaningful change gets generalized into a rule. If I cut a long intro once, that's a hypothesis. If I do it twice, it gets promoted to a confirmed rule that every future draft must follow.</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/yv9s4xjb0kxh7d4tjhz7.png" alt="Hand-drawn feedback loop showing how human edits become reusable writing rules for future AI-generated drafts." /></p>
<p>And there's a hard cap of 30 active rules. Why? Because this whole system runs on a smaller, cheaper model, and a smaller model follows 30 rules well and drowns in 80. The intelligence lives in the files, not the model.</p>
<h2>But does it learn from every single edit?</h2>
<p>Well, no. And this was a deliberate design decision.</p>
<p>A one-off change (fixing a fact, rephrasing something topic-specific) teaches nothing about my voice, so it gets logged and forgotten. Only patterns become rules. Otherwise the agent would overfit to whatever mood I was in during one editing session.</p>
<p>There's also one rule I consider non-negotiable: the agent can never invent a story about me. All personal facts live in a single profile file, and if a post needs an anecdote that isn't in there, the agent has to stop and ask me. An AI confidently fabricating a personal memory in your published blog is so much worse than a boring paragraph.</p>
<h2>Does it actually work?</h2>
<p>Honest answer: I don't fully know yet, and I won't pretend otherwise.</p>
<p>This post is literally draft number one. The feedback loop has learned exactly zero rules from my edits so far, because there were no edits before this. You are looking at the "before" photo. If you can tell which sentences I touched after the agent wrote them, tell me in the comments, seriously!</p>
<p>And another honest admission: setting this up took me more effort than just writing 2-3 posts by hand (I literally wrote four new blogs as an assignment lol, so that the LLM can infer my writing style better). The payoff only makes sense because it compounds, every post I edit makes the next draft closer to me.</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/pivin0jtpppbxla1ajho.png" alt="Illustration of an AI writing guardrail where only verified profile facts enter the blog, while fake memories are blocked." /></p>
<p>But the direction feels right, and I'm clearly not alone in thinking this way. The dev community has moved past one-shot prompting: Peter Steinberger's viral post ("you shouldn't be prompting coding agents anymore, you should be designing loops that prompt your agents") pulled 6.5 million views in June 2026 and <a href="https://explainx.ai/blog/loop-engineering-coding-agents-claude-code-guide-2026">set the timeline on fire for a week</a>. And the <a href="https://www.developersdigest.tech/blog/what-hacker-news-gets-right-about-ai-coding-agents-2026">Hacker News discourse in 2026</a> has shifted from shiny demos to making agents repeatable and trustworthy. A writing agent with a feedback loop is just that same idea, pointed at a blog.</p>
<h2>What are agent skills, anyway?</h2>
<p>If the term is new to you, let's zoom out for a second.</p>
<p>An agent skill is basically an onboarding document for an AI. It's a markdown file (usually called SKILL.md) with step-by-step instructions, plus supporting files it should read, that a coding agent like Claude Code loads before doing a task. Think of it like the difference between telling a new intern "write a blog" and handing them your company's full writing playbook.</p>
<p>And the beautiful part is that skills are portable and dumb-model-friendly. I have orchestrated multiple agentic workflows, and the lesson from there was the same: agents don't fail because the model is weak, they fail because the instructions are vague.</p>
<h2>FAQ</h2>
<p><strong>How many writing samples do you need to clone your voice?</strong>
Seven worked for me, but coverage beats volume. One sample per content type (tutorial, opinion, comparison, narrative) teaches far more than ten samples of the same type, because your voice changes with the mode.</p>
<p><strong>Can this work with a cheaper model?</strong>
That's the whole point. The voice profile, kill list, and rules carry the intelligence, so a smaller model just has to follow instructions. Save the expensive model for building the system, not running it.</p>
<p><strong>How do you stop the AI from making up facts about you?</strong>
One canonical profile file, and a hard rule: if the fact isn't in the file, ask the human. Never generate a personal claim from thin air. Accepting that AI can't do the entire job for you, and you have to keep yourself in the loop, creates the difference.</p>
<p><strong>Does this replace writing?</strong>
No, and I don't want it to. It replaces the first draft and the SEO chores. The opinions and the final edit are still mine, and honestly, that's the part I enjoy anyway. Even the current sentence that you are reading right now, was actually inserted by me during the edit.</p>
<h2>So, should you build one?</h2>
<p>If you publish regularly, yes. Build the voice profile. Really do. But don't skip the feedback loop, because without it you've just built a fancy prompt that will drift back into AI-slop within three posts.</p>
<p>And start smaller than I did: pick your five most representative pieces, extract the mechanics (not adjectives!), list ten phrases you'd never say, and make reviewing the diffs a habit. If you want a more detailed analysis about the system, just comment down below and I would be happy to help you all!</p>
<p>I'll be sharing more about this system as the feedback loop matures, including the numbers on how many edits it actually takes before drafts start needing none. If you want to follow that experiment, you can find me on <a href="https://x.com/swapnoneel123">X (swapnoneel123)</a> or check out my other works at <a href="https://www.swapnoneel.site">swapnoneel.site</a>.</p>
<p><img src="https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/mnf69thhecu599edac1q.png" alt="Hand-drawn thank-you illustration with a published draft, feedback loop, and voice-print machine for the end of an AI writing blog." /></p>
<p>And that's a wrap! Have you tried making AI write like you? What worked, and what came out sounding like a LinkedIn bot? I would love to hear your experience. Thank you for reading, and have a nice day ahead!!</p>
]]></content:encoded></item><item><title><![CDATA[My Second year in Tech]]></title><description><![CDATA[Discover a tech journey of coding, freelancing, hackathons, and achievements in the second year with insights and milestones!]]></description><link>https://swapnoneel.hashnode.dev/my-second-year-in-tech</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/my-second-year-in-tech</guid><category><![CDATA[technology]]></category><category><![CDATA[coding]]></category><category><![CDATA[journey]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Python]]></category><category><![CDATA[software development]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Fri, 08 Nov 2024 21:33:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729861086308/c152433f-383b-4b26-9f86-87418d53ab86.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Exactly one year back from now, I published a blog where I shared my First year of Tech journey. In that blog, I’ve mentioned about how I got started, and balanced both development and DSA, while maintaining a consistent 9+ CGPA throughout the semesters. Also, I shared how I got my breakthrough in freelancing and how I attended multiple hackathons and won all of them! If you haven’t read that blog, I would request you to <a target="_blank" href="https://swapnoneel.hashnode.dev/my-first-year-in-tech">read it from here</a>.</p>
<p>Now, let’s talk about how much I progressed in the past one year, and see if I was able to meet my own expectations or plans that I had made for this year 👀, previously mentioned at the end of my last tech journey blog!</p>
<h2 id="heading-the-journey">The Journey</h2>
<h3 id="heading-november-2023">November, 2023</h3>
<p>As you have seen in my last tech-journey blog, the month of October was super productive for me, and that streak continued in November too. I managed to cross the 200+ problems mark on Leetcode and started doing Leetcode consistently. My goal was to solve at least one problem a day, and I made a routine for that,- whenever I’m opening my PC for the first time in a day, my target was to solve a single Leetcode problem at first and then move onto some other tasks!</p>
<p>By the end of this month, I started participating in the Weekly Leetcode contests. This was among one of my to-do things from the first year of my journey!</p>
<p>Alongside this, I was working on building a CRUD application called “Toile”, whose major purpose was to showcase my designing skill, alongside a functional backend.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731092158245/7fe5e731-cb6b-460d-ba3c-02720382b475.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-december-2023">December, 2023</h3>
<p>Completed the work on <strong><mark>Toile</mark></strong>! It took around a month to make it fully ready. But it turned out to be pretty good. You can check it out from here: <a target="_blank" href="https://toile.vercel.app">https://toile.vercel.app</a></p>
<p>I started learning Dynamic Programming, because I noticed that there were a lot of questions coming from that during the contests. Also, I continued that habit of solving DSA problems regularly and managed to cross the 300+ mark of solving Leetcode problems. And, as I’ve solved all the Daily Problems of this month, I earned a badge for that.</p>
<p>And most importantly, I got the opportunity at <a target="_blank" href="https://keploy.io">Keploy</a> to work as a Community Evangelist. As a part of that role, I took an online session on “API Testing”, which went really really well, and also this was one of first talks to such a large audience! Additionally, I contributed to Keploy’s website and docs and helped them squash some bugs!</p>
<p>Also, I ended this month with an amazing event DevFest Kolkata ‘24, where I learned about some new topics like Kotlin Multi-Platform, and was able to have a chat with multiple startup founders like Sakeet Thadad, Aloke Majumder from Hoichoi, Lakshya Mittal and got to experience an QnA session from Striver himself!</p>
<p>Additionally, I designed a GitHub stats tracker, and as a part of that, I created a GitHub Wrap for myself!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731092247608/b63799de-6846-4b8b-8d91-3017ec5b280d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-january-2024">January, 2024</h3>
<p>The year started with a bang! In the past few months, my freelancing was running a bit dry. But with the start of this year, I got two big projects from two different clients. One of them was a research-based technical writing and the other one was making the Career, Showcase and some other web pages for a small start-up!</p>
<p>And, I maintained my consistency of solving DSA problems regularly and I was able to get the DPP Badge for this month too!</p>
<h3 id="heading-february-2024">February, 2024</h3>
<p>The month started with a small contractual work for re-designing the UI of a start-up named Wizdom. So, there were a lot of revisions and talking extensively with the teams. As I was alone in the project, it was pretty exhilarating but I was able to deliver the task within two weeks. Although I’ve done UI/UX designing gigs before, but this was a bit different because it was a fully-working start-up rather than stand-alone clients!</p>
<p>Also, me and my friend <a class="user-mention" href="https://hashnode.com/@sammaji">Sam Maji</a> decided to created a small SaaS project called, <strong><mark>InPoster</mark></strong>(<a target="_blank" href="https://inposter.vercel.app">https://inposter.vercel.app</a>) which will generate you viral LinkedIn posts with hashtags and other decorations just by taking some keywords from you about the topic. We challenged ourselves to build the project within one night, and we successfully did that, but it took some more days to improve some of the features and fix the bugs!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731092318237/24a382a5-96bb-4d11-b7aa-108afad301e2.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-march-2024">March, 2024</h3>
<p>I updated my old portfolio site and revamped it completely. I focused a lot on the design this time and added a lot of animations using GSAP. You can check it out from here: <a target="_blank" href="https://swapnoneel.vercel.app">https://swapnoneel.vercel.app</a></p>
<p>Also, this month, I completed solving 500 problems on Leetcode and got really consistent in participating in the contests, and achieved my highest rating of 1662 points!</p>
<p>And one notable thing, I got an offer as a Front-End Engineer from a renowned start-up, but had to reject it because they wanted me as a full-time on-site employee, which was not possible for me because of my college and current scenario!</p>
<h3 id="heading-april-2024">April, 2024</h3>
<p>This was the month of my end-semester exams, so definitely I was invested in that. But, I didn’t stopped practicing and solving DSA problems, and completed learning Graphs during this period of time.</p>
<p>Also, I contributed a lot in <a target="_blank" href="https://github.com/keploy">Keploy</a>’s Open-Source repositories this month, and created a sample app for them using Flask and MongoDB. Not only that, due to my excessive contribution to their projects, I was able to become one of the Top Contributors for the month!</p>
<p><img src="https://pbs.twimg.com/media/GMZozT9b0AE6tAh?format=jpg&amp;name=4096x4096" alt="Top Keploy Contributors of April 24" /></p>
<h3 id="heading-may-2024">May, 2024</h3>
<p>Maybe this was my most favorite month of the year! Started the month with a large freelancing work. It was related to image classification based on the locations from Google Maps (It may sound gibberish, but sadly I can’t elaborate more than this because of strict MoU). I had to get my hands dirty with image optimization, had to find innovative ways to store the images and make it available for my ML model at a steady stream. As I was on post-exam vacation, I was able to invest a lot of time in this and was able to deliver this project way before the deadline!</p>
<p>Also, I worked on improving a old project of mine called <a target="_blank" href="https://makaut-buddy.vercel.app">MAKAUT Buddy</a> which I had mentioned in my last blog. I revamped the Dashboard section completely, and made it more functional and feature-rich.</p>
<p>Additionally, I wanted to create something unique and decided to create some <code>npm</code> packages. So, I created my first package called <code>swapnoneel</code>, which will give a short bio about me and all of my social handles when you run <code>npx swapnoneel</code> from your terminal. This was just the beginning, because I planned to create way more complex projects than this!</p>
<p>And the best part about the month was that I got a remote opportunity to work as an <strong><mark>Intern with Keploy</mark></strong>, because of my extensive contributions to their projects in the recent times 🥳</p>
<h3 id="heading-june-2024">June, 2024</h3>
<p>Started this month while making a <code>npm</code> package called <a target="_blank" href="https://www.npmjs.com/package/get-response"><code>get-response</code></a>. It’s a terminal based application that interacts with the Google's Gemini API to generate content based on the user input. It allows you to ask questions directly or provide context from files, images or directories, and get the response in a simple and easy to understand interface. Also, you can automate some terminal commands by prompting for the task. And additionally, we also have support for responses from Stack Exchange sites like Stack Overflow. It got over thousands of downloads and got extremely positive response. I incrementally updated it throughout the month and kept on adding more and more features to it.</p>
<p>Delivered a python-based ML project for a research scholar, and as a part of it I had to explore Streamlit a bit, and while doing so, I made this app using Gemini’s API, that can convert your provided design into working HTML and CSS code. You can try it for yourself from here: <a target="_blank" href="https://ui-to-code.streamlit.app">https://ui-to-code.streamlit.app</a></p>
<p><img src="https://pbs.twimg.com/media/GQEH-MfaIAAJRVG?format=jpg&amp;name=large" alt="https://ui-to-code.streamlit.app" /></p>
<h3 id="heading-july-2023">July, 2023</h3>
<p>In my previous blog, I mentioned that I attended Eastern India’s biggest hackathon “Hack 4 Bengal 2.0”, but sadly we had to return mid-way because of an unavoidable circumstance. So, it was the time to make it a success in their next iteration, “<a target="_blank" href="https://www.hack4bengal.tech">Hack 4 Bengal 3.0</a>”. So at very end of last month, me along with my other two teammates <a class="user-mention" href="https://hashnode.com/@Tuhin114">Tuhin Poddar</a> and <a class="user-mention" href="https://hashnode.com/@sammaji">Sam Maji</a> attended the hackathon. We created a <mark>cloud-based AI powered terminal</mark> called “<a target="_blank" href="https://term-ai.vercel.app">Term AI</a>”, that let’s you code from anywhere at anytime from whichever device you want, which frees you from the hassle of carrying a laptop or relying on a desktop while travelling. It was really fun to make this project, because at this point we are making something unique that can be used by folks in their day-to-day life!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731093334429/8cc5cee5-a976-4c33-a5dc-563e0ae4d62e.png" alt class="image--center mx-auto" /></p>
<p>And, we ended up <strong><mark>winning the prize of second runner-up</mark></strong> among all of the 300+ participants. It was a really enjoyable moment for us, because from failing to stay throughout the hackathon in last year to winning it in this year, felt like a redemption arc for me! And it genuinely felt extremely good!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731167476958/0c89adf8-a6cf-4c66-844a-e23159b3efa2.png" alt class="image--center mx-auto" /></p>
<p>Also, I organized an open-source bootcamp under the hood of Keploy, called the “<strong><mark>Keploy Rain of Code</mark></strong>”, which led to an massive upsurge of open-source contributors for Keploy, and it was an unique experience for me to guide and manage so many folks all at once, and giving each one of them equal attention! The program was a great success and we were able to get a lot of new quality contributors.</p>
<h3 id="heading-august-2024">August, 2024</h3>
<p>This was again the month of our end-semester exam, and I had to invest the majority amount of time on my college academics. So, it was kind of stale from my tech side. I just delivered a small technical writing project during this month.</p>
<p>But, I kept in touch with DSA and continued solving more and more problems just like I was doing consistently throughout this period.</p>
<h3 id="heading-september-2024">September, 2024</h3>
<p>This month was a bit hectic for me, as I was dealing with some personal problems, and also got two large development projects at the same time. So, I had to work for long hours straight. There were some days in these month where I didn’t even got the time to sleep. But the good thing is, I was able to deliver those projects successfully (and although, I can’t talk about the nature of the project or its tech-stack, but I can say it was unique and was an extremely enriching experience for me).</p>
<h3 id="heading-october-2024">October, 2024</h3>
<p>This month, I created a <mark>RAG-based AI chatbot for Keploy</mark>, which is being trained on the Keploy docs and gives response for each and every Keploy-related question that you ask it!</p>
<p>Other than this, I worked on delivering a couple of articles for a client and worked on creating the code documentation for an early-stage startup. Also, I worked on making a website design as a part of another gig.</p>
<h2 id="heading-bonus">Bonus</h2>
<p>I have tried to mention most of the important stuff here. But I want to mention/clarify some things that weren't mentioned in the timeline or haven’t got reflected enough:</p>
<ul>
<li><p><mark>Solving DSA problems was a integral part of my journey</mark>, and almost everyday I practiced problems on Leetcode, starting from November, last year. And I’ve been highly consistent in doing that!</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1731097936631/9892cf9a-b21c-4b9d-9787-749937c80916.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>I’ve mentioned about only the important or substantial freelancing works that have influenced my journey and have taken quite a few days or weeks to finish. Other than the mentioned ones, I’ve done a lot of other works in the freelancing space, which aren’t that worthwhile to mention.</p>
</li>
<li><p>In few places, I’ve mentioned about what I’ve done while working within Keploy. But please take note that these were just a few things that I really loved working on, or was worthy of mentioning here. <mark>Being a DevRel is a lot more than this</mark>!</p>
</li>
<li><p>I invested majority of my freelancing money in stocks or spent them in buying assets. And also, I gifted myself a Nothing Phone (2a) this year, and also built a completely new work-setup for me in our house! Other than these, I paid the semester fees this year, all by myself; and also have taken care of my closed ones.</p>
</li>
<li><p>In my last year’s blog, I had mentioned that I was <mark>mentoring my juniors and guiding them</mark>, which I did consistently throughout this year too, but I didn’t felt the need to mention it here and elaborating on that front. If you are eager to learn more about it, you can go through our <a target="_blank" href="https://www.linkedin.com/company/the-async-devs/">LinkedIn page</a>.</p>
</li>
<li><p>I was active on Twitter(X) throughout this time, and was able to grow my follower count up to 1800 people. You can checkout my profile from <a target="_blank" href="https://x.com/swapnoneel123">here</a>! And tried to be as active on LinkedIn as possible, you can checkout my LinkedIn profile from <a target="_blank" href="https://www.linkedin.com/in/swapnoneel-saha-14a3161b6/">here</a>.</p>
</li>
</ul>
<h2 id="heading-was-i-able-to-meet-my-expectations">Was I able to meet my expectations?</h2>
<p>Previously, in my first year of tech journey, I mentioned about some of the plans or goals that I want to achieve in my second year. Among them, I targeted to solve over 600+ Leetcode problems by the end of second year, and I was able to go way beyond that, and have solved just about 750 problems!</p>
<p>I wanted to start delving deep into the domain of AI/ML, but sadly enough I was able to scratch only the surface. But I achieved my plan of making some SaaS products with my knowledge of AI/ML and Web Development, through InPoster, TermAI and Get Response.</p>
<p>I planned to attend more hackathons, but I attended only one of them. This was an well thought out decision because rather than focusing on quantity, I had decided to focus on the quality and attended the hackathons that felt worthy of my time, efforts and skills. Although, I was prepared to attend two more hackathons, but due to exams and other schedule issues, I wasn’t able to participate in them.</p>
<p>Also, I planned to delve into the topics of System Design and Operating System, which I did in this year. And, my plan of grabbing an internship and contributing to large-scale open-source projects also got fulfilled through Keploy.</p>
<p>And finally, my plan of guiding my juniors was fruitful and I have been guiding them throughout this whole time, and have expanded our scope in doing so!</p>
<h2 id="heading-my-plans-for-the-third-year">My Plans for the Third Year</h2>
<p>I want to focus on learning AI and ML in-depth this year, which I wasn’t able to fulfill completely in my last year. And this is my highest priority right now. Also, I want to create some innovative projects on the way while learning it.</p>
<p>I want to focus on my college academics a bit more, which I’ve completely neglected throughout my second year. And focus on the core subjects which will come really handy in future.</p>
<p>I’m also looking forward for a full-time developer role or to get an SDE/SWE internship from a renowned organization.</p>
<p>Also, I would like to participate in more and more coding contests, because although I had consistently started attending them this year but failed to do so because of timing issues. So, I would consider switching the platform and attend more and more contests as possible.</p>
<p>Other than these, I want to face more challenges and learn new stuffs that will come across my way. And I plan to continue doing what I’ve been doing throughout these months, and maintain the same level of consistency!</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>And that's a wrap!! But if you have any queries regarding my journey or any suggestions for my future, I would love to hear that from you in the comments. And if you want to stay connected with me, you can follow me here or on my other social handles. Thank You for reading about my journey, have a nice day ahead!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716652301849/8327a90c-373e-4837-9102-e67bb38def0c.png?auto=compress,format&amp;format=webp" alt /></p>
]]></content:encoded></item><item><title><![CDATA[Top 5 Best IDEs to use for Python in 2024]]></title><description><![CDATA[Discover the top 5 Python IDEs for 2024, including PyCharm, VS Code, Spyder, Jupyter, and Thonny, each with unique features]]></description><link>https://swapnoneel.hashnode.dev/best-ides-for-python-in-2024</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/best-ides-for-python-in-2024</guid><category><![CDATA[Python]]></category><category><![CDATA[Developer]]></category><category><![CDATA[development]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Fri, 25 Oct 2024 12:13:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1729858312474/91f843ff-d942-40b3-9f46-b62663b2d2c7.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Python is one of the most popular programming languages and choosing the right Integrated Development Environment (IDE) is essential for an efficient workflow. Whether you are a beginner or an experienced developer, choosing the right and best IDE is important because each developer's needs are unique, whether working on scientific projects, professional applications, or simple scripts.</p>
<p>Now, let’s check out the top 5 best Python IDE as of 2024. But keep in mind, among these none of these IDEs are significantly better or worse than the other. It’s just that, each one of them serves a specific purpose based on the needs and circumstances of the programmers.</p>
<h2 id="heading-pycharm">PyCharm</h2>
<p><strong>Best for:</strong> Professional development and large-scale projects.</p>
<p>Developed by JetBrains, PyCharm is one of the most popular Python IDE, offering a feature-rich experience with an emphasis on productivity. It is designed with professional developers in mind, with features that make it ideal for working on larger projects.</p>
<p><strong>Key Features:</strong></p>
<ul>
<li><p>PyCharm provides an advanced code editor with code completion, real-time error checking, and linting.</p>
</li>
<li><p>It has powerful refactoring and debugging tools.</p>
</li>
<li><p>It has scientific library support, ideal for data science and machine learning.</p>
</li>
<li><p>Contains integrated tools for version control (Git, SVN).</p>
</li>
</ul>
<p><img src="https://textdata.cn/images/blog/pycharm-professional.png" alt="图文| PyCharm专业版下载&amp;安装&amp;激活| 大邓和他的PYTHON" /></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>PyCharm supports smart code navigation and quick fixes.</p>
</li>
<li><p>Easy integration with Python packages and virtual environments.</p>
</li>
<li><p>Professional version supports web development frameworks like Django and Flask.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>PyCharm can be heavy on system resources, especially for older machines.</p>
</li>
<li><p>The Professional edition of PyCharm is paid.</p>
</li>
</ul>
<h2 id="heading-vs-code">VS Code</h2>
<p><strong>Best for:</strong> Developers looking for a flexible, cross-language environment.</p>
<p>Microsoft’s VS Code is one of the most popular go-to option for every developers for its extensive customization and support options. Though not an IDE by default, it offers excellent support for Python with the addition of extensions.</p>
<p><strong>Key Features:</strong></p>
<ul>
<li><p>VS Code supports Python through the Python extension, which includes IntelliSense, debugging, and more.</p>
</li>
<li><p>It has extensive library of extensions for different programming languages, including support for Git, Docker, and Jupyter Notebooks.</p>
</li>
<li><p>Also, it has built-in terminal and Git integration.</p>
</li>
</ul>
<p><img src="https://external-preview.redd.it/Uz0PH-r8nGx8gU9UCHURirqrtXgLhtqJiNDVgT03jtw.jpg?auto=webp&amp;s=580d0dc62b6581d2a8ff8e628d3bea5d53bdf5d2" alt="The VS Code Server : r/javascript" /></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>VS Code is lightweight and open-source, with regular updates.</p>
</li>
<li><p>It’s highly customizable with a wide range of themes and settings.</p>
</li>
<li><p>It’s suitable for multiple languages, making it a great all-rounder.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>VS Code requires extensions to achieve full functionality, which may be overwhelming for beginners.</p>
</li>
<li><p>It lacks some built-in Python-specific features that a dedicated IDE might offer.</p>
</li>
</ul>
<h2 id="heading-spyder">Spyder</h2>
<p><strong>Best for:</strong> Data science and scientific computing.</p>
<p>Spyder is specifically designed for data science and comes pre-packaged with tools that make it easy to work with data analysis and machine learning libraries. Often enough, it is bundled with Anaconda, a popular Python distribution for data science.</p>
<p><img src="https://www.spyder-ide.org/assets/media/website_screenshot.png" alt="Spyder | The Python IDE that scientists and data analysts deserve" /></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>It is free and open-source.</p>
</li>
<li><p>It’s ideal for data scientists, with built-in support for libraries and tools they frequently use.</p>
</li>
<li><p>Additionally, the variable explorer of Spyder is way better than the other counterparts; and it allows you to interactively browse and manage the objects generated running your code.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>Spyder is not suitable for web development or general-purpose programming.</p>
</li>
<li><p>It provides limited features for large-scale software engineering projects.</p>
</li>
</ul>
<h2 id="heading-jupyter-notebook">Jupyter Notebook</h2>
<p><strong>Best for:</strong> Interactive data analysis, machine learning, and research.</p>
<p>Jupyter Notebook has become a staple in the data science community due to its interactive nature. The best thing about Jupyter is, it allows developers to write code, run it, and view the output in the same environment, ideal for experimenting and sharing insights. It is one the best Python IDE used by many developers.</p>
<p><strong>Key Features:</strong></p>
<ul>
<li><p>Code cells allow running small chunks of code independently, which is great for prototyping.</p>
</li>
<li><p>Markdown cells enable easy documentation alongside code.</p>
</li>
<li><p>It has excellent support for data science libraries and data visualization.</p>
<p>  <img src="https://nightingalehq.ai/knowledgebase/glossary/what-is-jupyter/jupyter_hu55e85fab71a39b400081f279496f95b4_62056_1200x675_fill_q75_box_smart1.jpg" alt="What is Jupyter?" /></p>
</li>
</ul>
<p><strong>Pros:</strong></p>
<ul>
<li><p>Jupyter is perfect for exploratory data analysis and visualization.</p>
</li>
<li><p>It’s easy to share and document work, making it suitable for collaborative projects.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>It is not designed for full-scale application development.</p>
</li>
<li><p>Using Jupyter, managing larger projects and multiple files can be challenging.</p>
</li>
</ul>
<h2 id="heading-thonny">Thonny</h2>
<p><strong>Best for:</strong> Beginners learning Python.</p>
<p>Thonny is the best Python IDE tailored for those just starting with Python. IT is simple, beginner-friendly, and also, it comes with an easy-to-use interface and includes debugging tools that make it ideal for students and those who are new to coding.</p>
<p><strong>Key Features:</strong></p>
<ul>
<li><p>Thonny provides easy debugging with visual step-through for each line of code.</p>
</li>
<li><p>It is a simple editor that eliminates distractions for beginners.</p>
</li>
<li><p>It includes Python installation, so users don’t need to worry about setting up Python separately.</p>
</li>
</ul>
<p><img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6k9ie5hy36v36d09lqo.png" alt="Best 6 Python IDEs: Made For Python Only. 😎 - DEV Community" /></p>
<p><strong>Pros:</strong></p>
<ul>
<li><p>It’s user-friendly and free to use.</p>
</li>
<li><p>The step-through debugging that it provides helps beginners learn the basics of Python.</p>
</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li><p>It has very limited functionality for advanced projects.</p>
</li>
<li><p>The extensions and customization options are limited.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>I hope, by now, you all will have clarity over which IDE suits you the best. There isn’t any single best IDE, but based on your requirements and circumstances, you have to make the choice of which IDE to use or not. There are many more IDEs on the market other than these five, which I’ve mentioned here; but these are the most popular ones and loved by many developers and programmers, and provides the best possible experience for its target audience. You may also explore other options too, if you feel that these aren’t perfectly fulfilling your needs.</p>
<p>And finally, thank you for reading the blog! I hope you found it informative and valuable. For more information, follow me on <a target="_blank" href="http://twitter.com/swapnoneel123"><strong>Twitter (swapnoneel123</strong></a><strong>)</strong> where I share more such content through my tweets and threads. And, please consider sharing it with others on <strong>Twitter</strong> and tag me in your post so I can see it too. You can also check my <a target="_blank" href="https://github.com/Swpn0neel"><strong>GitHub (Swpn0neel)</strong></a> to see my projects.</p>
<p>I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716652301849/8327a90c-373e-4837-9102-e67bb38def0c.png?auto=compress,format&amp;format=webp" alt /></p>
]]></content:encoded></item><item><title><![CDATA[Understanding Semantic Versioning]]></title><description><![CDATA[Learn the basics of Semantic Versioning and how it helps developers manage software changes effectively]]></description><link>https://swapnoneel.hashnode.dev/understanding-semantic-versioning</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/understanding-semantic-versioning</guid><category><![CDATA[software development]]></category><category><![CDATA[Software Engineering]]></category><category><![CDATA[version control]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Sat, 01 Jun 2024 19:35:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1717267695984/311dd0f0-d05c-4baf-b5af-d5adf5889e25.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Often enough, we see version numbers like 1.0.2, 2.5.6 or something similar, associated with a software product. But, you may think what do these numbers actually represent, and why do we use them? We could've simply used numbers like 1, 2, 3, etc. for naming each versions!</p>
<p>But, let me tell you, we use them because we’re following a best practice called <strong>Semantic Versioning</strong>. When we use Semantic Versioning, developers can easily predict whether a change will break their code or not. And also, the numbers give a clue to the kind of changes that have occurred.</p>
<p>Now, let's dive deep, and understand each and everything about semantic versioning!</p>
<h2 id="heading-what-is-semantic-versioning">What is Semantic Versioning?</h2>
<p>Semantic Versioning, sometimes abbreviated to SemVer, is a software versioning scheme using a three-part number format MAJOR.MINOR.PATCH, and this versioning scheme helps developers and users understand the nature of changes in the software.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717267689583/94e58a9e-c8c5-4fbc-9a80-29081327b784.png" alt class="image--center mx-auto" /></p>
<p>For the 2.6.8 version, for example:</p>
<ul>
<li><p><strong>2</strong> is its MAJOR version.</p>
</li>
<li><p><strong>6</strong> is the MINOR version.</p>
</li>
<li><p><strong>8</strong> is the PATCH version.</p>
</li>
</ul>
<p>Now, let's break down these 3 components and try to understand them individually:</p>
<h3 id="heading-patch-version">Patch Version</h3>
<p><strong>Patch versions are generally used for bugfixes,</strong> and there are no functionality changes. You have heard about the term "hotfix", it's the patch version update that fixes any breaking changes!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717267567041/f64b3f07-0d5d-4c47-90d6-a5af7e6f262a.png" alt class="image--center mx-auto" /></p>
<p>When you increase a new patch, <strong>you increase the rightmost number by 1.</strong> From 1, you increase it to 2, then to 3, and so on and to keep in mind, there are no limits to these numbers, so once you reach 9, you continue from 10, 11, 12 and so on.</p>
<h3 id="heading-minor-version">Minor Version</h3>
<p>The second number in the middle is called the minor version number. It is <strong>used when you release new functionality</strong> in your project. It could be a completely new feature or some added functionality to an already existing feature.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717267591031/fd410534-b0a2-46f0-abd8-2318835f5031.png" alt class="image--center mx-auto" /></p>
<p>When you increase the minor version, you also increase it by one, and just like patch versions, it doesn't have any limits. <strong>But</strong> <strong>when you increase the minor version, you must reset the patch version to zero.</strong></p>
<h3 id="heading-major-version">Major Version</h3>
<p>The leftmost number is a major version. When you increase the major version, you tell people that there are <strong>backward-incompatible changes</strong>. People may experience breakage if they use the next version. It's often associated with a complete overhaul of the product. But, in some cases, it may also happen that we increment the major version, when a lot of new features along with a lot of improvements to the pre-existing features are launched at once!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717267684973/accc1756-5772-478f-83dc-dcc5d7c7c6fa.png" alt class="image--center mx-auto" /></p>
<p>When you increase the major version number, you have to reset both patch version and minor versions.</p>
<h2 id="heading-additional-version-types">Additional version types</h2>
<p>The above mentioned three version types are well-defined by some systematic rules, but for the upcoming version types or details that we are about to discuss doesn't have any proper rules and regulations and it varies between different products and organizations.</p>
<h3 id="heading-pre-release-version">Pre-release version</h3>
<p>If you want to create a pre-release version (like an alpha or beta version), you can add a hyphen <code>-</code>, followed by the words <code>alpha</code> or <code>beta</code>. There are <strong>no hard and fast rules for pre-releases</strong>, so you can name them anything you want. Usually, we use alpha or beta, followed by a number. For example, version <code>2.0.3-alpha2</code> is the second alpha release built on top of version <code>2.0.3</code> of the actual product.</p>
<p>A pre-release version means the version is unstable and might not meet the intended final quality level. It often contains known and identified bugs, which are desired to be fixed, and even incomplete feature implementation. It's often released for closed/public testing to gather feedback or just to test the current implementation.</p>
<h3 id="heading-build-metadata">Build Metadata</h3>
<p><strong>Build metadata</strong> are specified by appending a plus sign and a series of dot-separated identifiers. For example, version <strong>1.2.0+20130313144700</strong>.</p>
<p>It provides details beyond the core version number, typically used for internal tracking purposes during development and testing.</p>
<p>You can encode full commit id in the build metadata, so it's faster to analyze from what commit this software was actually build on, or you can encode the date/time of the particular build, machine it was build on.</p>
<h2 id="heading-initial-development">Initial Development</h2>
<p>Version <code>0.y.z</code> is for software in the initial development stage. Software using a 0 MAJOR version indicates that it is at an early development phase, and with any version, anything might get changed. During this period, the product is considered to be unfit for public usage, and is purely in the development stage.</p>
<p>During this phase, we generally start our project with version <code>0.1.0</code> and when we reach a stable state and our product is almost feature complete for the launch, we generally test it in the <code>alpha</code> and <code>beta</code> release. After that, we increase the version to <code>1.0.0</code> upon release.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>By now, I think you have realized that by providing clear rules and guidelines for incrementing version numbers, it helps developers communicate changes effectively, manage dependencies, and ensure predictable updates.</p>
<blockquote>
<p>Also, if you want to see an example of how semantic versioning is implemented in a real-world project, you can check out my latest project <a target="_blank" href="https://www.npmjs.com/package/get-response">Get Response</a>, which is a Node.js based command-line interface (CLI) tool that interacts with the Google's Gemini API to generate content based on the user input, and can also automate task for you.</p>
</blockquote>
<p>Hence, that's a wrap for now, and if you want to learn new things like this, you can follow me at <a class="user-mention" href="https://hashnode.com/@Swapn0neel">Swapnoneel Saha</a> and also follow me on <a target="_blank" href="http://twitter.com/swapnoneel123"><strong>Twitter (swapnoneel123</strong></a><strong>)</strong> where I share more such content through my tweets and threads. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1717270387673/d1f38bf2-fa9e-4f38-948e-e6d4173eb571.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Publishing your own NPM Package is too simple!!]]></title><description><![CDATA[Learn how to publish your own NPM package with this simple, step-by-step guide]]></description><link>https://swapnoneel.hashnode.dev/publish-your-own-npm-package</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/publish-your-own-npm-package</guid><category><![CDATA[npm]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Sat, 25 May 2024 15:55:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1716652494165/d4d1de8a-1201-411d-af7d-9b40fa4b6a21.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Isn't it cool if you can run command like <code>npx &lt;your_name&gt;</code> in someone's terminal, and they can read about you, your works, and find details like your social media handles, right at their terminal?</p>
<p>Or maybe you have created some cool React component, wouldn't that be even more cooler if other folks can use them in their projects just by installing an <code>npm</code> package?</p>
<p>I think you have got the drill already... Publishing your own NPM package is really cool and can help a lot of folks globally!! So, before we start about how to publish your own NPM package, I think you should run these two commands first at your terminal <code>npx swapnoneel</code> and <code>npx get-response</code>, to properly understand what I mean by "cool" and "helpful"!!</p>
<h2 id="heading-create-your-npm-account">Create your NPM account</h2>
<p>This is the most obvious step, if you want to publish your own package!!</p>
<p>Just head over to <a target="_blank" href="https://www.npmjs.com">https://www.npmjs.com</a> and create your account.</p>
<p>Also, remember to do two-factor authentication of your account. You can use an Authenticator app like <a target="_blank" href="https://play.google.com/store/apps/details?id=com.authenticator.authservice2&amp;hl=en&amp;gl=US">TOTP Authenticator</a>!!</p>
<p>We will talk later, about how and when to use our account. For now, let's continue to the next step!!</p>
<h2 id="heading-choose-the-name-of-your-npm-package">Choose the name of your NPM package</h2>
<p>The very first thing you need to do before creating your package is to choose a name. This is important because your package needs to have a unique name and you cannot choose a name that has been used already.</p>
<p>After you choose a name, you've to go to the <a target="_blank" href="https://www.npmjs.com/">NPM registry</a> and run a search. Be sure there's no exact match to the name you chose or a match that is too similar. Otherwise, you have to try choosing a different name!!</p>
<h2 id="heading-lets-start-creating-the-npm-package">Let's start creating the NPM package</h2>
<p>As I've stated in the title itself, that creating your own NPM package is extremely simple; now you will understand, why!</p>
<h3 id="heading-install-node-and-npm">Install Node and NPM</h3>
<p>If you don't have Node installed already, you should go and refer to <a target="_blank" href="https://swapnoneel.hashnode.dev/nodejs-npm-nvm">this article</a> and install it. In the article, you will find the step-by-step guide about how to install and maintain the different Node versions!!</p>
<h3 id="heading-initialize-git-repository">Initialize git repository</h3>
<p>Create a new project folder for your package and navigate into the folder. Then, run the following command in your terminal:</p>
<pre><code class="lang-bash">git init
</code></pre>
<p>This will help us track the changes in our package. Also, make sure that it remains hosted on GitHub!!</p>
<h3 id="heading-initialize-npm-in-your-project">Initialize NPM in your project</h3>
<p>To do this, navigate to the root directory of your project and run the following command:</p>
<pre><code class="lang-bash">npm init
</code></pre>
<p>Now, you will prompted to give some answers, I'm mentioning the utility of each one of them:</p>
<ul>
<li><p><code>package-name</code>: It should be the name of your package that you want to publish. Also, remember that it must be lowercase and may only include hyphens.</p>
</li>
<li><p><code>version</code>: The initial value is <code>1.0.0</code>. You may change it to <code>0.1.0</code> and release the full version <code>1.0.0</code> later!! You will be updating the version number each time when you update your package using <a target="_blank" href="https://www.freecodecamp.org/news/semantic-versioning-1fd6f57749f7/">semantic versioning</a>.</p>
</li>
<li><p><code>description</code>: You can provide a description of your package here, explaining about what your package does and how to use it.</p>
</li>
<li><p><code>entry point</code>: The entry file for your code. The default value is <code>index.js</code>.</p>
</li>
<li><p><code>test command</code>: Here, you can add the command you want to run when a user runs <code>npm run test</code>. To keep things simple, you may keep it blank for now!!</p>
</li>
<li><p><code>git repository</code>: The link to your remote repository on GitHub. It's optional, but it's better if you can add the GitHub repository link here!!</p>
</li>
<li><p><code>keywords</code>: Add relevant keywords that will help others find your package on the NPM registry. It's optional too, and you can leave it blank for now!!</p>
</li>
<li><p><code>author</code>: Add your name.</p>
</li>
<li><p><code>license</code>: You can add a license or use the default license, Internet Systems Consortium (ISC) License.</p>
</li>
</ul>
<p>Once you provide all these information, a file will be created called <code>package.json</code> that will kinda look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716639984976/535670bf-65cd-4641-9b48-1be0daef046b.png" alt class="image--center mx-auto" /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong><em>Additionally, you should modify the </em></strong><code>package.json</code><strong><em> file to add </em></strong><code>"type" : "module"</code><strong><em> which will enable you to write the JavaScript code in ECMAScript modules format. This allows for cleaner code organization, code reusability, and better encapsulation.</em></strong></div>
</div>

<h3 id="heading-write-your-code">Write your code</h3>
<p>Now, you can go ahead and write your code for the package.</p>
<p>For this tutorial, I will be writing my code in the <code>index.js</code> file.</p>
<p><strong>💡 Reminder!!</strong></p>
<p><em>Please add the following line at the start of the code because it tells the operating system to use the Node.js interpreter to execute the script. It allows us to run the script by simply typing its filename, without having to specify the full path to the Node.js interpreter.</em></p>
<pre><code class="lang-javascript"><span class="hljs-meta">#!/usr/bin/env node</span>
</code></pre>
<p>Now inside the <code>index.js</code> file, write the code for your package. Here, I will be creating a simple package called <code>test</code>. This package will print the string <code>"Reminder to follow Swapnoneel on Twitter at https://x.com/swapnoneel123"</code> in the terminal.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716648802856/1df1543f-5bb4-43e6-affa-3f4461378f83.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-create-an-executable-script">Create an executable script</h3>
<p>Now, we have to make this <code>index.js</code> file executable and assign it to a command, so that whenever we run that command, we get the result output-ed by <code>index.js</code> . For doing that, we have to add this in out <code>package.json</code> file:</p>
<pre><code class="lang-json"><span class="hljs-string">"bin"</span>: {
  <span class="hljs-attr">"test"</span>: <span class="hljs-string">"./index.js"</span>
},
</code></pre>
<p>So, after all the changes, our <code>package.json</code> file should look somewhat like this:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"name"</span>: <span class="hljs-string">"test"</span>,
  <span class="hljs-attr">"version"</span>: <span class="hljs-string">"1.0.0"</span>,
  <span class="hljs-attr">"description"</span>: <span class="hljs-string">"just to test how to publish npm package"</span>,
  <span class="hljs-attr">"main"</span>: <span class="hljs-string">"./index.js"</span>,
  <span class="hljs-attr">"type"</span>: <span class="hljs-string">"module"</span>,
  <span class="hljs-attr">"bin"</span>: {
    <span class="hljs-attr">"test"</span>: <span class="hljs-string">"./index.js"</span>
  },
  <span class="hljs-attr">"scripts"</span>: {
    <span class="hljs-attr">"test"</span>: <span class="hljs-string">"echo \"Error: no test specified\" &amp;&amp; exit 1"</span>
  },
  <span class="hljs-attr">"repository"</span>: {
    <span class="hljs-attr">"type"</span>: <span class="hljs-string">"git"</span>,
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"git+https://github.com/Swpn0neel/test.git"</span>
  },
  <span class="hljs-attr">"author"</span>: <span class="hljs-string">"Swapnoneel Saha"</span>,
  <span class="hljs-attr">"license"</span>: <span class="hljs-string">"ISC"</span>,
  <span class="hljs-attr">"bugs"</span>: {
    <span class="hljs-attr">"url"</span>: <span class="hljs-string">"https://github.com/Swpn0neel/test/issues"</span>
  },
  <span class="hljs-attr">"homepage"</span>: <span class="hljs-string">"https://github.com/Swpn0neel/test#readme"</span>
}
</code></pre>
<h3 id="heading-make-the-script-executable">Make the script executable</h3>
<p>Now, to make this script executable, so that works perfectly, we have to run this command in our terminals:</p>
<p><strong>Linux</strong></p>
<pre><code class="lang-bash">chmod +x index.js
</code></pre>
<p><strong>Windows</strong></p>
<p><em>Note that, for this to work perfectly, you need to have</em><code>git</code><em>installed on your system!!</em></p>
<pre><code class="lang-bash">git update-index --chmod=+x index.js
</code></pre>
<h2 id="heading-test-your-npm-package">Test your NPM package</h2>
<p>Testing ensures that your NPM package works as expected. To do that, first navigate to the root of your project. Then, run the following command:</p>
<pre><code class="lang-bash">npm link
</code></pre>
<p>This will make your package available globally. And you can require the package in a different project to test it out. For that, you go outside the root directory and try running the following command to add the package you have just created:</p>
<pre><code class="lang-bash">npm link &lt;your_package_name&gt;
</code></pre>
<p>And, you'll see something like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716650345968/b8038b49-3ee6-4ce2-8e78-f61b04b60a84.png" alt class="image--center mx-auto" /></p>
<p>Now you can run your package, and it should work perfectly!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716650425160/b8d12272-5801-4c13-87fa-243a88244d8f.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-publish-your-npm-package"><strong>Publish Your NPM Package</strong></h2>
<p>To publish your package on the NPM registry, you need to have an account. And, I hope you have created that previously!!</p>
<p>So, now it's time to open your terminal and run the following command in the root of your package:</p>
<pre><code class="lang-bash">npm login
</code></pre>
<p>You will get a prompt to enter your <code>username</code> and <code>password</code>. If login is successful, you should see a message like this:</p>
<p><code>Logged in as &lt;your-username&gt; on https://registry.npmjs.org/.</code></p>
<p>You can now run the following command to publish your package on the NPM registry:</p>
<pre><code class="lang-bash">npm publish
</code></pre>
<p>Note that, during these steps you may need to use your authentication app to authenticate the procedure!!</p>
<p>And so if you have been following along, then congratulations! You just published your first NPM package. And, you can visit the <a target="_blank" href="https://www.npmjs.com/">NPM website</a> and run a search for your package. You should see your package show up in the search results.</p>
<h2 id="heading-updating-your-already-published-blog">Updating your already published blog</h2>
<p>If you want to update your already published blog, because you have some bug fixes for the already released version or maybe you are implementing a new feature, you can do so by following these two simple steps:</p>
<ol>
<li><p>You have to update your application version from the <code>package.json</code> file to the version number of the upcoming release. You should follow the rules of Semantic Versioning for that. If you want to know more about that, and how you can name the versions, you can check out <a target="_blank" href="https://swapnoneel.hashnode.dev/understanding-semantic-versioning">this blog</a>!</p>
<pre><code class="lang-json"> {...
 <span class="hljs-attr">"version"</span>: <span class="hljs-string">"1.1.0"</span>,
 ...}
</code></pre>
</li>
<li><p>Once you have updated the version number, you can re-publish your package using the same command <code>npm publish</code> and your package would be updated to the latest version.</p>
</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>And now, you can probably boast about your coolness, because yes, your tool can be accessed anywhere in the world in anybody's terminal!!</p>
<p>If you want to know how wonderful tools you can make through this, head over to <a target="_blank" href="https://www.npmjs.com/package/get-response">Get Response</a>, which is a node.js based command-line interface (CLI) tool that uses the Google's Gemini to generate content based on the user input. This tool allows you to ask questions directly or provide context from files or directories, and get the response in a simple and easy to understand interface.</p>
<p>And finally, thank you for reading the blog! I hope you found it informative and valuable. For more information, follow me on <a target="_blank" href="http://twitter.com/swapnoneel123"><strong>Twitter (swapnoneel123</strong></a><strong>)</strong> where I share more such content through my tweets and threads. And, please consider sharing it with others on <strong>Twitter</strong> and tag me in your post so I can see it too. You can also check my <a target="_blank" href="https://github.com/Swpn0neel"><strong>GitHub (Swpn0neel)</strong></a> to see my projects.</p>
<p>I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716652301849/8327a90c-373e-4837-9102-e67bb38def0c.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Installing Node.js and managing it's versions were this easy?]]></title><description><![CDATA[Guide to installing Node.js, npm, and managing versions using NVM across Windows, macOS, and Linux]]></description><link>https://swapnoneel.hashnode.dev/nodejs-npm-nvm</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/nodejs-npm-nvm</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[npm]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Fri, 24 May 2024 14:42:50 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1716561929669/7be53812-2eb8-4dd7-84a4-3a0f8546086f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>We all know that, <strong>Node.js</strong> is the runtime environment for JavaScript that executes JavaScript code outside the web browser. And, <strong>npm</strong> stands for Node Package Manager and is the default package manager for Node.js and is also a platform for managing JavaScript packages. It provides a command-line interface (CLI) for interacting with the npm registry, which hosts thousands of open-source libraries and modules.</p>
<h2 id="heading-how-to-install-nodejs-and-npm-locally">How to install node.js and npm locally?</h2>
<p>Based on the operating systems, the installation process is different and varied. That's why, I'm classifying them here so that you folks don't get confused between them.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716554172337/62142e92-545a-4b6b-9b5e-b018bcf9d0e8.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-windows">Windows</h3>
<ol>
<li><p><strong>Download the Installer</strong>:</p>
<ul>
<li><p>Go to the official Node.js website: <a target="_blank" href="https://nodejs.org/">nodejs.org</a>.</p>
</li>
<li><p>Download the LTS (Long Term Support) version, because it happens to be the most stable version.</p>
</li>
</ul>
</li>
<li><p><strong>Run the Installer</strong>:</p>
<ul>
<li><p>Open the downloaded <code>.msi</code> file and run the installer.</p>
</li>
<li><p>Follow the installation steps, and please <strong>make sure to check the box that says "Install Node.js and npm."</strong></p>
</li>
</ul>
</li>
</ol>
<h3 id="heading-macos"><strong>macOS</strong></h3>
<ol>
<li><p>You have to install <strong>Homebrew</strong> if you haven't already. To do that, open the terminal and run:</p>
<pre><code class="lang-bash"> /bin/bash -c <span class="hljs-string">"<span class="hljs-subst">$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)</span>"</span>
</code></pre>
</li>
<li><p>Now, we can install <code>node.js</code> and <code>npm</code> with Homebrew:</p>
<pre><code class="lang-bash"> brew install node
</code></pre>
</li>
</ol>
<h3 id="heading-linux"><strong>Linux</strong></h3>
<p>It's extremely easy to install <code>node.js</code> and <code>npm</code> in Linux. Just run these two commands in the terminal:</p>
<pre><code class="lang-bash">sudo apt update
sudo apt install nodejs npm
</code></pre>
<h2 id="heading-verify-your-installation">Verify your installation</h2>
<p>You can verify the installation of <code>node.js</code> and <code>npm</code> by running the following two commands in your terminal:</p>
<pre><code class="lang-bash">node -v
npm -v
</code></pre>
<blockquote>
<p><em>If you are on Windows, Powershell may cause some issues, so try to use Command Prompt in that case. It will work!!</em></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716553688790/eaf89f25-9858-410e-9ebc-082022a6697e.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-managing-node-versions-using-nvm">Managing node versions using NVM</h2>
<p>NVM stands for Node Version Manager and it's a command-line tool that helps us to manage and switch different versions of Node.js with ease and convenience!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716554276508/db2ae459-9cd3-41fe-837f-29c2ea3d8671.png" alt class="image--center mx-auto" /></p>
<ol>
<li><h3 id="heading-check-available-node-versions">Check available node versions</h3>
</li>
</ol>
<p>Before installing any node version, let's first check the available Node versions. To do that, we can simply run the following command in our terminal:</p>
<pre><code class="lang-bash">nvm ls available
</code></pre>
<p>After running this, you get something like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716555882030/1d1e966c-c139-4c92-a68e-a64cbde6b661.png" alt class="image--center mx-auto" /></p>
<ol start="2">
<li><h3 id="heading-installing-the-latest-node-version">Installing the latest node version</h3>
</li>
</ol>
<p>To install the latest version of node.js, you can simply run this command,</p>
<pre><code class="lang-bash">nvm install latest
</code></pre>
<p>But remember, it's always better to install the LTS (long-term support) version of node, because it's less buggy and is overall more stable!!</p>
<p>To install the LTS version of Node, run the command,-</p>
<pre><code class="lang-bash">nvm install lts
</code></pre>
<ol start="3">
<li><h3 id="heading-install-multiple-node-versions">Install multiple Node versions</h3>
</li>
</ol>
<p>One of the most interesting part of NVM is you can install multiple versions of Node at the same time and use any of them based on your convenience!!</p>
<p>For this, nvm has the <code>nvm install</code> command. You can install specific versions by running this command followed by the version you want. For example,</p>
<pre><code class="lang-bash">nvm install 18.17.0
nvm install 20.11.1
nvm install 20.12
</code></pre>
<p>Also, as NVM follows semantic versioning, you can install v18.17 and use any of the following version under 18.17, like 18.17.0, 18.17.1, etc. Here, 18 represents the major version, 17 represents the minor version, and 1 represents the patch version!!</p>
<ol start="4">
<li><h3 id="heading-installing-specific-node-versions">Installing specific Node versions</h3>
</li>
</ol>
<p>You can install any specific node version, by running this command,-</p>
<pre><code class="lang-bash">nvm install &lt;node_version_number&gt;
</code></pre>
<p>Replace the <code>&lt;node_version_number&gt;</code> with your desired Node version.</p>
<p>But, to ensure that your given version is valid, make sure to run <code>nvm ls available</code> and put a correct version from the list!!</p>
<p>Also, once you install a version of Node, the corresponding version of NPM is also installed alongside with it. So you don’t need to install NPM separately!!</p>
<ol start="5">
<li><h3 id="heading-check-installed-node-versions-in-your-system">Check installed Node versions in your system</h3>
</li>
</ol>
<p>To check the list of all node versions that you have installed on your system, you can simply run,-</p>
<pre><code class="lang-bash">nvm list
</code></pre>
<p>And, you will see a response like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716560504142/21e3f56e-e0d9-415f-96e9-816e2ccb40da.png" alt class="image--center mx-auto" /></p>
<ol start="6">
<li><h3 id="heading-switching-node-versions">Switching Node versions</h3>
</li>
</ol>
<p>As you can see in the previous image that I'm currently using <code>20.13.1</code>. Now, if I want to switch my version to another one like <code>18.17.0</code>. I can simply use the following command:</p>
<pre><code class="lang-bash">nvm use 18.17.0
</code></pre>
<p>In your case, you can put your desired version in place of <code>18.17.0</code>, but first make sure it is a valid version number and it is installed on your system!!</p>
<ol start="7">
<li><h3 id="heading-uninstall-a-node-version">Uninstall a Node version</h3>
</li>
</ol>
<p>To uninstall an already installed Node version that you no longer think is useful, you can do that by running the command,-</p>
<pre><code class="lang-bash">nvm uninstall &lt;node_version_number&gt;
</code></pre>
<p>Replace the <code>&lt;node_version_number&gt;</code> with your desired and installed Node version.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<blockquote>
<p>TLDR: This article provides a comprehensive guide on installing Node.js and npm across different operating systems (Windows, macOS, and Linux), verifying installations, and managing Node.js versions using NVM (Node Version Manager). It covers steps to install specific Node.js versions, switch between versions, and uninstall versions when no longer needed. The guide emphasizes the importance of using the LTS (Long Term Support) version for stability and includes detailed commands for each process.</p>
</blockquote>
<p>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716561409967/1916dd93-56c0-4df1-8be1-19b75342aad1.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Software Testing Pyramid]]></title><description><![CDATA[Structured software testing includes unit, integration, and end-to-end layers for efficient defect identification and quality maintenance]]></description><link>https://swapnoneel.hashnode.dev/software-testing-pyramid</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/software-testing-pyramid</guid><category><![CDATA[software development]]></category><category><![CDATA[Testing]]></category><category><![CDATA[webdev]]></category><category><![CDATA[deployment]]></category><category><![CDATA[APIs]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Mon, 29 Apr 2024 12:25:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1714393387059/e6256a10-ce90-4410-9454-7fd5a4e9bf54.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Software Testing is a process that involves evaluating software components to ensure they meet specified requirements and are defect-free. The main goal of software testing is to verify that the actual software matches the expected requirements, enhancing product quality and customer satisfaction.</p>
<p>Now, the Software Testing Pyramid is a conceptual framework that is used in software development to provide a path or guide to the testing process. It consists of different layers of testing, that focuses on specific aspects of the software's functionality, performance and reliability.</p>
<h2 id="heading-understanding-the-layers-of-software-testing-pyramid"><strong>Understanding the Layers of Software Testing Pyramid</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714334533795/f1fd8287-3ef7-40d5-9c49-1f9b585f2235.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-unit-testing">Unit Testing</h3>
<p><strong>Unit testing</strong> is a type of software testing that focuses on individual units or components of a software system. The purpose of unit testing is to validate that each unit of the software works as intended and meets the requirements. Developers typically perform unit testing, and it is performed early in the development process before the code is integrated and tested as a whole system.</p>
<ul>
<li><p>Unit tests form the base of the pyramid and are the most numerous.</p>
</li>
<li><p>They are fast to write and execute, allowing developers to run them frequently as part of the continuous integration process.</p>
</li>
</ul>
<h3 id="heading-integration-testing">Integration Testing</h3>
<p><strong>Integration testing</strong> is the process of testing the interface between two software units or modules. It focuses on determining the correctness of the interface. The purpose of integration testing is to expose faults in the interaction between integrated units. Once all the modules have been unit-tested, integration testing is performed.</p>
<ul>
<li><p>Integration tests make up the middle layer of the pyramid.</p>
</li>
<li><p>Integration tests are fewer in number compared to unit tests, but more complex and slower to execute.</p>
</li>
</ul>
<p>They are run less frequently than unit tests, typically at key points during the development cycle.</p>
<h3 id="heading-end-to-end-e2e-testing">End-to-End (E2E) Testing</h3>
<p><strong>End-to-end testing</strong> evaluates the entire software application from start to finish, simulating a real-world user scenarios. It tests the flow of data and processes across multiple layers and components to validate the overall functionality and performance of the software.</p>
<ul>
<li><p>E2E tests sit at the top of the pyramid and are the least numerous.</p>
</li>
<li><p>E2E tests are the most complex and time-consuming to write and execute.</p>
</li>
</ul>
<p>They are run less frequently, often before major releases, to validate the overall system functionality.</p>
<h2 id="heading-importance-of-software-testing-pyramid">Importance of Software Testing Pyramid</h2>
<p>The pyramid of Software Testing is crucial for maintaining the quality and reliability of any software applications, especially if it has a large user-base and a large scale. By dividing the testing process into different layers, it helps identify and address defects at various stages of the development lifecycle, leading to higher-quality software products with great performance and reliability.</p>
<h2 id="heading-advantages-of-using-software-testing-pyramid">Advantages of using Software Testing Pyramid</h2>
<ul>
<li><p><strong>Efficient Test Coverage</strong>: The pyramid model ensures comprehensive test coverage by addressing different levels of the software architecture.</p>
</li>
<li><p><strong>Early Bug Detection</strong>: By conducting tests at lower levels, such as unit testing, bugs and issues can be identified and resolved early in the development process.</p>
</li>
<li><p><strong>Faster Feedback Loop</strong>: Automated testing at lower levels allows for quicker feedback on code changes, facilitating rapid iteration and deployment.</p>
</li>
</ul>
<h2 id="heading-challenges-in-software-testing">Challenges in Software Testing</h2>
<p>Implementing a software testing pyramid can be hard, especially in those cases where the codebase is already large and huge. Some of the other major issues includes,</p>
<ul>
<li><p><strong>Initial Setup and Infrastructure</strong>: Setting up the automated testing framework and infrastructure requires a lot of time and resources.</p>
</li>
<li><p><strong>Test Maintenance</strong>: Keeping the tests up-to-date and relevant as the software evolves can be a challenge.</p>
</li>
<li><p><strong>Skill and Training</strong>: Teams may require training and expertise in automated testing practices and tools.</p>
</li>
</ul>
<h2 id="heading-best-practices-for-implementing-software-testing-pyramid">Best Practices for Implementing Software Testing Pyramid</h2>
<p>To effectively implement the Software Testing Pyramid, we must consider the following practices, so that it becomes cost-effective, easy to implement and sustainable:</p>
<ul>
<li><p><strong>Start Early</strong>: Begin the testing activities as early as possible during the development phase.</p>
</li>
<li><p><strong>Automate Tests</strong>: Automate the tests wherever possible to streamline the testing process and increase the efficiency.</p>
</li>
<li><p><strong>Prioritize Tests</strong>: Focus on the high-priority tests that cover critical functionalities and scenarios.</p>
</li>
<li><p><strong>Continuous Integration</strong>: Integrate testing into the continuous integration and delivery pipeline for faster feedback and validation.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Multi-national companies like Google, Amazon, and Netflix have successfully implemented Software Testing Pyramid in their development processes. They leverage a combination of automated testing tools, continuous integration practices, and a policy of quality assurance to deliver robust and reliable software products.</p>
<p>In conclusion, the Software Testing Pyramid provides a structured approach to software testing, allowing teams to efficiently identify and address defects throughout the development lifecycle. By dividing testing efforts into different layers and prioritizing automation, organizations can achieve higher-quality software with faster time-to-market.</p>
<blockquote>
<p>TLDR: The Software Testing Pyramid is a framework in software development that divides testing into different layers - unit testing, integration testing, and end-to-end testing. It helps in identifying defects early, ensuring efficient test coverage, and maintaining software quality. Implementing the pyramid can be challenging but following best practices like starting testing early, automating tests, and prioritizing critical functionalities can lead to successful outcomes. Companies like Google, Amazon, and Netflix have successfully implemented the pyramid to deliver robust and reliable software products.</p>
</blockquote>
<p>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1714334190050/d203af69-a3d1-4e93-827b-1ecb696255b9.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[The 3 Most Powerful Functions in JavaScript]]></title><description><![CDATA[A brief description about the map(), filter() and reduce() functions]]></description><link>https://swapnoneel.hashnode.dev/the-3-most-powerful-functions-in-javascript</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/the-3-most-powerful-functions-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[coding]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Sun, 10 Mar 2024 12:14:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1710072792777/b19a2577-a9ac-47e3-b8f0-a7f7821ab6f8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>The map(), filter() and the reduce() are the most powerful and important higher order functions in JavaScript that generally operates on arrays. Being the part of the functional programming paradigm of JavaScript, these functions allow us to write cleaner and concise code.</p>
<p>To master JavaScript, it's a necessity to master them, as you'll be using them almost everywhere while building projects; even if you are using React!!</p>
<p>So let's not waste any more time, and learn these functions quickly!!</p>
<h1 id="heading-the-map-function">The <code>map()</code> function</h1>
<p>Naively speaking, the <code>map()</code> function converts a group of data into another group of data based on some specific conditions. The conditions are defined through the provided callback function. For example, we are taking an array of numbers and converting it to another array where each element from the former array is squared and put in the latter array. Here, we are performing the squaring function.</p>
<h3 id="heading-syntax">Syntax</h3>
<pre><code class="lang-javascript">Arrays.map(<span class="hljs-function">(<span class="hljs-params">element, index, array</span>) =&gt;</span> { ... })
</code></pre>
<p>The map function can take three arguments, but in general we'll be using the <code>element</code> value only in most of the cases!!</p>
<p>Now, let's check with an example, how we can use this in our code!!</p>
<h3 id="heading-example">Example</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> nums = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];

<span class="hljs-keyword">const</span> squaredNums = nums.map(<span class="hljs-function">(<span class="hljs-params">num</span>) =&gt;</span> (num * num));

<span class="hljs-built_in">console</span>.log(squaredNums);
</code></pre>
<p>Here's the result when we run this code in the browser console:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710071277175/f965ca2a-4cbb-4009-900e-22673b31f60f.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-the-filter-function">The <code>filter()</code> function</h1>
<p>As the name clearly suggests, the <code>filter()</code> function is used to extract certain amounts data from a given set of data, based on a specific condition. For example, we have an array of numbers and we want to extract only the positive numbers from that array; we'll be able to do it easily using the <code>filter()</code> function.</p>
<h3 id="heading-syntax-1">Syntax</h3>
<pre><code class="lang-javascript"><span class="hljs-built_in">Array</span>.filter(<span class="hljs-function">(<span class="hljs-params">element, index, array</span>) =&gt;</span> { ... } )
</code></pre>
<p>Just like the <code>map()</code> function, the <code>filter()</code> function also takes the same types of three arguments, but here the return type of the callback function should be <code>boolean</code>. The <code>filter()</code> function returns an array containing the elements for which the callback function returns <code>true</code>.</p>
<h3 id="heading-example-1">Example</h3>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> nums = [<span class="hljs-number">1</span>, <span class="hljs-number">-2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">-6</span>, <span class="hljs-number">-7</span>];

<span class="hljs-keyword">const</span> positiveNums = nums.filter(<span class="hljs-function">(<span class="hljs-params">num</span>) =&gt;</span> num &gt; <span class="hljs-number">0</span>);

<span class="hljs-built_in">console</span>.log(positiveNums);
</code></pre>
<p>Here's the result when we run this code in the browser console:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710071131323/f9ec94cf-bdde-4df3-a116-85267d8b26aa.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-the-reduce-function">The <code>reduce()</code> function</h1>
<p>To explain it simply, the <code>reduce()</code> function reduces/converts all the values of an array into a single value. It iterates through all the elements and calculates the result based on the given condition. It takes a callback function and an initial value as arguments. The callback function receives an accumulator and the current element, and it returns the updated value of the accumulator for the next iteration.</p>
<h3 id="heading-syntax-2">Syntax</h3>
<pre><code class="lang-javascript">reduce(<span class="hljs-function">(<span class="hljs-params">accumulator, currentValue, index, array</span>) =&gt;</span> { ... }, initialValue)
</code></pre>
<p>Now, the syntax may look a bit too complex to you, but no worries, we will understand this better using the help of the example!!</p>
<h3 id="heading-example-2">Example</h3>
<p>Let's consider that we want to find the product of all the elements in an array. So what the <code>reduce()</code> function will do is, take the <code>initialValue</code> (here, it is 1) as the <code>accumulator</code> and will iterate over each and every elements in the array, and will perform the operations as defined by the callback function. And, once all the values has been traversed, it will return the final value of the <code>accumulator</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> nums = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">5</span>];

<span class="hljs-keyword">const</span> product = nums.reduce(
<span class="hljs-function">(<span class="hljs-params">accumulator, currentValue</span>) =&gt;</span> accumulator * currentValue, 
<span class="hljs-number">1</span>);

<span class="hljs-built_in">console</span>.log(product);
</code></pre>
<p>Here's the result when we run this code in the browser console:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710072423789/a7c51e1d-1d4a-4fa9-b9ea-07f90564ecaf.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710072584207/88548bcf-0b8a-42e6-a3e1-b81c1042b7b6.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Objects vs JSON: Are they same?]]></title><description><![CDATA[Unravel the mystery: JavaScript Objects vs. JSON. Are they truly twins, or are there hidden differences? Learn the key distinctions and master your data!]]></description><link>https://swapnoneel.hashnode.dev/javascript-objects-vs-json</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/javascript-objects-vs-json</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[backend]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Sat, 02 Mar 2024 11:23:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1709378357760/447b3ef8-33ad-4fb4-be49-6d3204fb2356.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>While learning JavaScript, you will find about JavaScript objects, which may seem familiar to you if you are coming from other programming languages like Java or Python. But soon enough, you will also find something called JSON or JavaScript Object Notation which is widely used all over web development. You may find a lot of similarities between these two and may think about whether they are the same thing or not!!</p>
<p>So in this blog, I'm here to clear your confusion regarding JS Objects and JSON. So let's dive in!!</p>
<h2 id="heading-what-is-javascript-object">What is JavaScript Object?</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709377619396/b9dfbc39-cee3-4edc-9d95-ccb84b49a6fd.png" alt class="image--center mx-auto" /></p>
<p>JavaScript Objects are the fundamental constructs which are used to store collections of data, entities or some specific values. They are essentially containers for named values, known as properties, and functions, which are termed methods when they are part of an object.</p>
<p>Compare it with a cup, for example, a cup is an object, with properties. It has a color, a design, weight, a material it is made of, etc. The same way, JavaScript objects can have properties, which define their characteristics. We can define an object in JavaScript like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> cup = {
    <span class="hljs-attr">color</span> : <span class="hljs-string">"black"</span>,
    <span class="hljs-attr">design</span> : <span class="hljs-string">"cylindrical"</span>,
    <span class="hljs-attr">weight</span> : <span class="hljs-number">300</span>,
    <span class="hljs-attr">material</span> : <span class="hljs-string">"glass"</span>
}
</code></pre>
<h2 id="heading-what-is-json">What is JSON?</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709377497454/4a07db50-35ce-476a-a183-5c8d82bdb8f1.png" alt class="image--center mx-auto" /></p>
<p>JSON, which stands for JavaScript Object Notation is a light-weight data interchange format that is both easy for humans to read, write and understand, and also convenient for the machines to parse and generate.</p>
<p>It's completely language-independent but uses the conventions/syntax that are similar to that of the C-family of languages, like C, C++, C#, Java, JavaScript, Python, and many others.</p>
<p>And that's why, we use JSON primarily in data transmission between a server and a web application or as a format for storing configuration or the state information. The simplicity and ease of use of JSON have made it a popular choice for web APIs and configuration files. Here's an example of JSON data:</p>
<pre><code class="lang-javascript">{
    <span class="hljs-string">"firstName"</span>: <span class="hljs-string">"John"</span>,
    <span class="hljs-string">"lastName"</span>: <span class="hljs-string">"Doe"</span>,
    <span class="hljs-string">"age"</span>: <span class="hljs-number">30</span>,
    <span class="hljs-string">"isEmployed"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-string">"address"</span>: {
        <span class="hljs-string">"street"</span>: <span class="hljs-string">"123 Main St"</span>,
        <span class="hljs-string">"city"</span>: <span class="hljs-string">"Anytown"</span>,
        <span class="hljs-string">"zipCode"</span>: <span class="hljs-string">"12345"</span>
    },
    <span class="hljs-string">"phoneNumbers"</span>: [
        {<span class="hljs-string">"type"</span>: <span class="hljs-string">"home"</span>, <span class="hljs-string">"number"</span>: <span class="hljs-string">"212 555-1234"</span>},
        {<span class="hljs-string">"type"</span>: <span class="hljs-string">"office"</span>, <span class="hljs-string">"number"</span>: <span class="hljs-string">"646 555-5678"</span>}
    ]
}
</code></pre>
<h2 id="heading-whats-the-difference">What's the difference?</h2>
<p>It might have been already clear to you how JS Objects and JSON have a lot of dissimilarities between them. But to further develop on that, here are some more aspects where they differ from each other:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td></td><td>JavaScript Objects</td><td>JSON</td></tr>
</thead>
<tbody>
<tr>
<td>Flexibility</td><td>It can contain functions and support methods that can manipulate the object's data.</td><td>It is purely a data format and cannot hold functions.</td></tr>
<tr>
<td>Syntax</td><td>Objects can be declared using the object literal syntax, constructor functions, or the <code>class</code> keyword starting from ES6.</td><td>JSON closely resembles JavaScript object literal syntax, but it has stricter rules. For example, property names must be double-quoted, and trailing commas are not allowed.</td></tr>
<tr>
<td>Purpose</td><td>They are used within JavaScript code to organize data and functionality.</td><td>It's a language-independent text format that is used to transmit data between a server and web application or as a file format.</td></tr>
</tbody>
</table>
</div><h2 id="heading-conclusion">Conclusion</h2>
<p>Understanding these differences is crucial for effectively using JavaScript objects within your code and JSON for data interchange between clients and servers or storing the configuration and state. And, I hope you folks have enriched yourself with some known or unknown concepts today, and cleared any misunderstanding regarding these topics. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709377456629/8e775196-cf5e-4e28-bdc1-8bf7d419813f.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Designing Machine Learning Workflows in Python]]></title><description><![CDATA[NumPy, Pandas, Scikit-Learn, TensorFlow, and PyTorch are the most important Machine Learning libraries]]></description><link>https://swapnoneel.hashnode.dev/designing-machine-learning-workflows-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/designing-machine-learning-workflows-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Machine Learning]]></category><category><![CDATA[AI]]></category><category><![CDATA[coding]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Fri, 02 Feb 2024 16:07:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1706889691867/9b2f329b-3ac3-47e5-a748-c9a1eadee06a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In our recent AI-revolutionized world, to design proper machine learning workflows is important for getting insights, making predictions, and also solving complex problems. Python, with its vast collection of libraries and frameworks, is the go-to language for developing machine learning models and workflows. So, that's why, understanding the steps involved in designing machine learning workflows in Python is essential to progress in this field.</p>
<p>In this article, we will explore the fundamental steps and considerations that go into building efficient and robust machine learning pipelines. We will cover all the essential aspects that is needed using some of the extensive support from libraries such as NumPy, Pandas, Scikit-Learn, TensorFlow, and PyTorch.</p>
<p>So, let's dive in and discover the key components of designing machine learning workflows in Python. By the end of this article, you'll have a solid foundation to tackle real-world machine learning challenges and unleash the power of Python in your data-driven endeavors.</p>
<h1 id="heading-whats-the-process">What's the process?</h1>
<p>To design a machine learning workflow, we have to perform and maintain some specific steps which are crucial. They are stated below:</p>
<ol>
<li><h3 id="heading-data-preparation">Data Preparation</h3>
<p> It is a crucial step in designing machine learning workflows. It involves ensuring that the data is in a suitable format and quality for the subsequent stages of the workflow.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Import necessary libraries</span>
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd

<span class="hljs-comment"># Load and explore the dataset</span>
dataset = pd.read_csv(<span class="hljs-string">'data.csv'</span>)
print(dataset.head())

<span class="hljs-comment"># Handle missing data and outliers</span>
dataset = dataset.dropna()
dataset = dataset[dataset[<span class="hljs-string">'column'</span>] &lt; threshold]

<span class="hljs-comment"># Preprocess the data</span>
X = dataset.drop(<span class="hljs-string">'target'</span>, axis=<span class="hljs-number">1</span>)
y = dataset[<span class="hljs-string">'target'</span>]

<span class="hljs-comment"># Split the data into training and testing sets</span>
<span class="hljs-keyword">from</span> sklearn.model_selection <span class="hljs-keyword">import</span> train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=<span class="hljs-number">0.2</span>)
</code></pre>
<ol>
<li><h3 id="heading-feature-engineering">Feature Engineering</h3>
<p> It is the next step that comes after Data Preparation. It involves transforming raw data into a format that can effectively represent the underlying patterns and relationships in them.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Extract relevant features from the data</span>
<span class="hljs-comment"># Feature extraction techniques like PCA, LDA, etc.</span>

<span class="hljs-comment"># Perform dimensionality reduction</span>
<span class="hljs-keyword">from</span> sklearn.decomposition <span class="hljs-keyword">import</span> PCA
pca = PCA(n_components=<span class="hljs-number">2</span>)
X_train_pca = pca.fit_transform(X_train)
X_test_pca = pca.transform(X_test)
</code></pre>
<ol>
<li><h3 id="heading-model-selection">Model Selection</h3>
<p> The model selection section involves choosing an appropriate algorithm or model architecture that best fits the problem at hand. It includes tasks such as determining the type of problem selecting the appropriate model class (e.g., decision trees, neural networks, support vector machines), and tuning hyperparameters to optimize model performance.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Import necessary libraries</span>
<span class="hljs-keyword">from</span> sklearn.model_selection <span class="hljs-keyword">import</span> cross_val_score
<span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> accuracy_score, precision_score, recall_score

<span class="hljs-comment"># Choose appropriate models based on the problem</span>
<span class="hljs-keyword">from</span> sklearn.linear_model <span class="hljs-keyword">import</span> LogisticRegression
<span class="hljs-keyword">from</span> sklearn.ensemble <span class="hljs-keyword">import</span> RandomForestClassifier

<span class="hljs-comment"># Split data into input features (X) and target variable (y)</span>
X = X_train_pca
y = y_train

<span class="hljs-comment"># Define evaluation metrics for model selection</span>
scoring = <span class="hljs-string">'accuracy'</span>

<span class="hljs-comment"># Train and evaluate models using cross-validation</span>
model_lr = LogisticRegression()
scores_lr = cross_val_score(model_lr, X, y, cv=<span class="hljs-number">5</span>, scoring=scoring)
model_rf = RandomForestClassifier()
scores_rf = cross_val_score(model_rf, X, y, cv=<span class="hljs-number">5</span>, scoring=scoring)

<span class="hljs-comment"># Select the best-performing model based on evaluation metrics</span>
best_model = model_rf <span class="hljs-keyword">if</span> np.mean(scores_rf) &gt; np.mean(scores_lr) <span class="hljs-keyword">else</span> model_lr
</code></pre>
<ol>
<li><h3 id="heading-model-training-and-evaluation">Model Training and Evaluation</h3>
<p> The model training process involves feeding the input data and corresponding labels into the model, adjusting the model's internal parameters iteratively using optimization techniques (e.g., gradient descent), and updating the parameters to minimize the specified loss function. Evaluation metrics such as accuracy, precision, recall, or mean squared error are calculated to quantify the model's predictive performance.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Train the selected model on the training set</span>
best_model.fit(X_train_pca, y_train)

<span class="hljs-comment"># Evaluate the model using test set</span>
y_pred = best_model.predict(X_test_pca)

<span class="hljs-comment"># Calculate evaluation metrics</span>
accuracy = accuracy_score(y_test, y_pred)
precision = precision_score(y_test, y_pred)
recall = recall_score(y_test, y_pred)
</code></pre>
<ol>
<li><h3 id="heading-model-deployment">Model Deployment</h3>
<p> The Model Deployment section involves making the trained machine learning model available for use in real-world applications. This process includes preparing the model for deployment, such as converting it into a deployable format or packaging it into a containerized environment.</p>
</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># Save the trained model to a file</span>
<span class="hljs-keyword">import</span> joblib
joblib.dump(best_model, <span class="hljs-string">'model.pkl'</span>)
</code></pre>
<p><strong><em>Now, with all these covered, it may seem overwhelming to you, so let’s check some examples to solidify your concepts.</em></strong></p>
<h1 id="heading-examples">Examples</h1>
<h2 id="heading-machine-learning-workflow-for-image-classification-using-the-fashion-mnist-dataset">Machine Learning workflow for Image Classification using the Fashion MNIST dataset</h2>
<p>Here's an example of a machine learning workflow for image classification using the Fashion MNIST dataset. The workflow includes data loading, preprocessing, model selection, training, evaluation, and saving the trained model. Let’s check the code sample, how we are doing that-</p>
<pre><code class="lang-python"><span class="hljs-comment"># Import necessary libraries</span>
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">from</span> tensorflow <span class="hljs-keyword">import</span> keras
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np

<span class="hljs-comment"># Load the Fashion MNIST dataset</span>
fashion_mnist = keras.datasets.fashion_mnist
(X_train, y_train), (X_test, y_test) = fashion_mnist.load_data()

<span class="hljs-comment"># Preprocess the data</span>
X_train = X_train / <span class="hljs-number">255.0</span>
X_test = X_test / <span class="hljs-number">255.0</span>

<span class="hljs-comment"># Model Selection</span>
model = keras.models.Sequential([
    keras.layers.Flatten(input_shape=(<span class="hljs-number">28</span>, <span class="hljs-number">28</span>)),
    keras.layers.Dense(<span class="hljs-number">128</span>, activation=<span class="hljs-string">'relu'</span>),
    keras.layers.Dense(<span class="hljs-number">10</span>, activation=<span class="hljs-string">'softmax'</span>)
])

<span class="hljs-comment"># Model Training</span>
model.compile(optimizer=<span class="hljs-string">'adam'</span>, loss=<span class="hljs-string">'sparse_categorical_crossentropy'</span>, metrics=[<span class="hljs-string">'accuracy'</span>])
model.fit(X_train, y_train, epochs=<span class="hljs-number">10</span>)

<span class="hljs-comment"># Model Evaluation</span>
test_loss, test_accuracy = model.evaluate(X_test, y_test)
print(<span class="hljs-string">f"Test Loss: <span class="hljs-subst">{test_loss}</span>"</span>)
print(<span class="hljs-string">f"Test Accuracy: <span class="hljs-subst">{test_accuracy}</span>"</span>)

<span class="hljs-comment"># Save the trained model</span>
model.save(<span class="hljs-string">"fashion_mnist_model.h5"</span>)
</code></pre>
<p>Now, let’s see how the workflow works:</p>
<ol>
<li><p>We import the necessary libraries, including TensorFlow and Keras, which provide high-level APIs for building and training deep learning models.</p>
</li>
<li><p>The Fashion MNIST dataset is loaded using the <a target="_blank" href="http://keras.datasets.fashion">keras.datasets.fashion</a>_mnist module and is split into training and testing sets, and the images and labels are stored in variables X_train, y_train, X_test, and y_test, respectively.</p>
</li>
<li><p>Pre-processing the data: The pixel values of the images are scaled to a range of 0 to 1 by dividing them by 255. This normalization step ensures that the input data is in a suitable range for the model.</p>
</li>
<li><p>Model Selection: We create a sequential model using keras.models.Sequential(). In this example, we use a simple architecture with a flattening layer, a dense layer with 128 units and ReLU activation, and a dense output layer with 10 units (corresponding to the number of classes in the dataset) and softmax activation.</p>
</li>
<li><p>Model Training: We compile the model using model.compile() with the Adam optimizer, sparse categorical cross-entropy loss function, and accuracy as the evaluation metric. The model is trained using <a target="_blank" href="http://model.fit">model.fit</a>() with the training data (X_train and y_train) for a specified number of epochs.</p>
</li>
<li><p>Model Evaluation: We evaluate the trained model on the test set using model.evaluate(). The test loss and accuracy are calculated and printed.</p>
</li>
</ol>
<p>Saving the trained model: We save the trained model to a file using <a target="_blank" href="http://model.save">model.save</a>().</p>
<p>When the code is run through the terminal, the model is trained, evaluated and the test loss and accuracy is printed, as shown below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706888496190/80a5fff8-8809-43d7-b8cc-8459949edd5c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-machine-learning-workflow-for-sentiment-analysis-using-the-imdb-movie-review-dataset">Machine Learning workflow for Sentiment Analysis using the IMDb movie review dataset</h2>
<p>Let’s get into the example of a machine learning workflow for sentiment analysis using the IMDb movie review dataset. The workflow includes data preparation, feature engineering, model selection, training, evaluation, and deployment. Let’s dive into the code and check how we are doing that-</p>
<pre><code class="lang-python"><span class="hljs-comment"># Import necessary libraries</span>
<span class="hljs-keyword">import</span> pandas <span class="hljs-keyword">as</span> pd
<span class="hljs-keyword">from</span> sklearn.feature_extraction.text <span class="hljs-keyword">import</span> TfidfVectorizer
<span class="hljs-keyword">from</span> sklearn.model_selection <span class="hljs-keyword">import</span> train_test_split
<span class="hljs-keyword">from</span> sklearn.linear_model <span class="hljs-keyword">import</span> LogisticRegression
<span class="hljs-keyword">from</span> sklearn.metrics <span class="hljs-keyword">import</span> accuracy_score
<span class="hljs-keyword">import</span> joblib

<span class="hljs-comment"># Load the IMDb movie review dataset</span>
df = pd.read_csv(<span class="hljs-string">'imdb_reviews.csv'</span>)

<span class="hljs-comment"># Data Preparation</span>
X = df[<span class="hljs-string">'review'</span>]
y = df[<span class="hljs-string">'sentiment'</span>]

<span class="hljs-comment"># Split the data into training and testing sets</span>
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=<span class="hljs-number">0.2</span>, random_state=<span class="hljs-number">42</span>)

<span class="hljs-comment"># Feature Engineering</span>
vectorizer = TfidfVectorizer()
X_train_vectors = vectorizer.fit_transform(X_train)
X_test_vectors = vectorizer.transform(X_test)

<span class="hljs-comment"># Model Selection</span>
model = LogisticRegression(max_iter=<span class="hljs-number">100000</span>)

<span class="hljs-comment"># Model Training</span>
model.fit(X_train_vectors, y_train)

<span class="hljs-comment"># Model Evaluation</span>
y_pred = model.predict(X_test_vectors)
accuracy = accuracy_score(y_test, y_pred)
print(<span class="hljs-string">f"Accuracy: <span class="hljs-subst">{accuracy}</span>"</span>)

<span class="hljs-comment"># Model Deployment</span>
joblib.dump(model, <span class="hljs-string">'sentiment_analysis_model.pkl'</span>)
joblib.dump(vectorizer, <span class="hljs-string">'vectorizer.pkl'</span>)
</code></pre>
<p>Now, let’s see how the workflow works:</p>
<ol>
<li><p>We start by importing the necessary libraries, including Pandas for data manipulation, scikit-learn for machine learning functionality, and joblib for model serialization.</p>
</li>
<li><p>The IMDb movie review dataset is loaded using <a target="_blank" href="http://pd.read">pd.read</a>_csv() into a Pandas DataFrame called df. The dataset contains two columns: "review" (textual movie reviews) and "sentiment" (positive or negative sentiment).</p>
</li>
<li><p>Data Preparation: We assign the "review" column to X and the "sentiment" column to Y, which prepares the data for training and testing.</p>
</li>
<li><p>Splitting the data: The train_test_split() function is used to split the data into training and testing sets. We assign 80% of the data to training and 20% to testing. The random_state parameter ensures reproducibility of the split.</p>
</li>
<li><p>Feature Engineering: We use the TfidfVectorizer from scikit-learn to convert the textual reviews into numerical features. The fit_transform() function is applied to the training set (X_train), and the transform() function is applied to the testing set (X_test), as you can clearly see in the code.</p>
</li>
<li><p>Model Selection: We choose a logistic regression model for sentiment analysis. In this example, we use scikit-learn's LogisticRegression() class.</p>
</li>
<li><p>Model Training: We fit the logistic regression model to the training data using <a target="_blank" href="http://model.fit">model.fit</a>() with the training vectors (X_train_vectors) and corresponding labels (y_train).</p>
</li>
<li><p>Model Evaluation: We make predictions on the testing set using model.predict() with the testing vectors (X_test_vectors). The accuracy is calculated by comparing the predicted labels (y_pred) with the actual labels (y_test).</p>
</li>
<li><p>Model Deployment: And finally, we save the trained model and vectorizer using joblib.dump() for future use and deployment.</p>
</li>
</ol>
<p>When the code is run through the terminal, the model is trained, evaluated and the accuracy is printed, as shown below:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706889095784/94b6cb10-93a0-4b56-8e9d-0cd704d94764.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Thank you for reading the blog! I hope you found it informative and valuable. For more information, follow me on <a target="_blank" href="http://twitter.com/swapnoneel123"><strong>Twitter (swapnoneel123</strong></a><strong>)</strong> where I share more such content through my tweets and threads. And, please consider sharing it with others on <strong>Twitter</strong> and tag me in your post so I can see it too. You can also check my <a target="_blank" href="https://github.com/Swpn0neel"><strong>GitHub (Swpn0neel)</strong></a> to see my projects.</p>
<p>I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1706889699251/e0331511-ab42-4e0c-997c-5cbe529b3888.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[My First year in Tech]]></title><description><![CDATA[A timeline based journey about what I learnt and achieved so far, which includes my academics, freelancing offers and winning hackathons.]]></description><link>https://swapnoneel.hashnode.dev/my-first-year-in-tech</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/my-first-year-in-tech</guid><category><![CDATA[Python]]></category><category><![CDATA[Freelancing]]></category><category><![CDATA[technology]]></category><category><![CDATA[coding]]></category><category><![CDATA[journey]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Tue, 24 Oct 2023 13:00:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1698152080204/742cb9f7-5d96-4ddf-a22d-e80961f7edad.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Exactly one year back from now, I got into University for my Bachelor's degree in Computer Science and Engineering. And it was then, I actually got introduced to the Tech world. Previously, I had some coding experience in both Java &amp; Python and had a proper knowledge of MySQL.</p>
<p>In this one year, I have learned and experienced quite a few things. So, I thought it would be the perfect time to document my journey with the timelines and also share some of my plans for the next year. This may help the beginners in starting their journey and will definitely motivate me for my upcoming journey. So let's begin…</p>
<h1 id="heading-the-journey">The Journey</h1>
<h3 id="heading-october-2022">October, 2022</h3>
<p>As this was my first month of college, I focused on my academics a bit and attended classes regularly. Besides that, as I had a bit of coding knowledge, I decided to start learning Web Development. I followed the free course from <a target="_blank" href="https://www.youtube.com/@CodeWithHarry">Code with Harry</a>, which is available on YouTube.</p>
<p>And by the end of that month, I was mostly done with HTML. It didn't take me more than two weeks to learn it as it was extremely simple and beginner-friendly.</p>
<h3 id="heading-november-2022">November, 2022</h3>
<p>This was an interesting month for me, because it was when I got introduced to CSS, and the sheer amount of styling that I can do with it amazed me 🤩. I continued with Code with Harry and started creating some small projects including a form page for School admission, a basic site for a fictional shoe brand, etc.</p>
<h3 id="heading-december-2022">December, 2022</h3>
<p>I decided to enhance my skills in HTML and CSS more before moving on to JavaScript, so I took a course from Coursera, which was taught by Meta. Following that, I started and completed learning Bootstrap from there.</p>
<p>And the most interesting and a bit disappointing thing happened during this month:</p>
<blockquote>
<p>The interesting thing is, that I got my first Tech freelancing gig, which consisted of building a few small projects using Bootstrap and the APIs provided by the client, for showcasing the service of their small start-up. And, it was a 15K rupees gig. Now, the disappointing part is, that I couldn't complete the gig because some part of it was extremely out of my league. But they paid me 8K rupees for the work I had done.</p>
</blockquote>
<p><strong>The most important thing I learned was that <mark>real-life development is all about googling, pasting codes from StackOverflow, and learning while doing so</mark>…</strong></p>
<p>Took full advantage of my Winter vacation, to start learning some advanced concepts of Python and finally got started with JavaScript!!</p>
<h3 id="heading-january-2023">January, 2023</h3>
<p>This is that single month where I did a lot of "<strong>first-time</strong>" things and learned &amp; got started with them.</p>
<p>Continued learning JavaScript from both Code with Harry and Coursera. And, I started building some small projects using my newly learned concepts from Python.</p>
<p>Now with the skills I have learned so far, I was thinking of putting them to the test by attending a Hackathon. So, I grabbed one of my classmates and a 2nd-year guy from another college. Our small team had a diverse skill set, and we decided to participate in "<strong>Treasure Hacks 3.0</strong>". Our project was "Lab for All" (Website link: <a target="_blank" href="https://labforall.vercel.app">https://labforall.vercel.app</a>, GitHub link: <a target="_blank" href="https://github.com/Swpn0neel/treasure-hacks-labforall">https://github.com/Swpn0neel/treasure-hacks-labforall</a>)</p>
<blockquote>
<p>We planned to make a project on the Ed-Tech field and the idea was to create a platform where the users can get assistance, particularly in their lab assignments, from video lectures to notes, and viva questions to 3D simulations.</p>
<p>While working on the project, I got to know about how you have to make the site design before starting to code, and that attracted me a lot and planted the seed inside me to start designing in Figma, which I planned to learn in the near future.</p>
<p>Strangely enough, till now I haven't learned about Git and GitHub. But I had to grasp it now for the obvious reason of collaboration in my Hackathon project. And it was a significant bump in my Tech learning journey.</p>
<p>Also, while doing the project I had to learn Firebase as it was needed for data storing and user authentication, and it was my part to complete that job.</p>
</blockquote>
<p>The best part is, we completed the project within the time limit and implemented all the planned features. And to our amazement, <strong><mark>we won the Hackathon being the second runner-up</mark></strong>.</p>
<p>Also, this month, I wrote my first blog at Hashnode on Python and also got active on <a target="_blank" href="https://twitter.com/swapnoneel123">Twitter (now X)</a>, and started posting content on both mediums.</p>
<h3 id="heading-february-2023">February, 2023</h3>
<p>Our first-semester final exam happened this month and was stretched over a period of 20 days. And later, when the results came out, I topped my batch with an <mark>SGPA of 9.33</mark>.</p>
<p>This month, I also focused on my blogging and wrote around 8-9 articles. Also, I started working on my <a target="_blank" href="http://swapnoneel.vercel.app">personal portfolio website</a> and completed it. It took just over two weeks to do that. Learned a bit of React and JavaScript while building my portfolio, and also worked on file handling and its modules in Python.</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://twitter.com/swapnoneel123/status/1630930494840864768">https://twitter.com/swapnoneel123/status/1630930494840864768</a></div>
<p> </p>
<h3 id="heading-march-2023">March, 2023</h3>
<p>After a lot of grinding web development for some months, I decided to switch the gear a bit and decided to start doing DSA. Now for doing that, I rarely used any guide or video tutorials, but relied on solving more and more Leetcode problems (you can check my <a target="_blank" href="https://leetcode.com/Swapnoneel/">Leetcode profile, here</a>) based on my previous knowledge of arrays, strings and recursion. By doing so, I solved just over 30 problems and approached around 100 problems in that venture.</p>
<p>Also, I started learning UI/UX design and gained a huge interest in that. Followed Jesse Showalter, Design Course and Payton Clerk on YouTube to get knowledge about designing. I used Figma for the design purpose!!</p>
<p>Besides these, I completed the "7 days, 7 blogs" challenge on Hashnode and mostly shared my Python knowledge there. And also, explored a lot of Python libraries mainly about text and image analysis.</p>
<h3 id="heading-april-2023">April, 2023</h3>
<p>Continued my DSA journey and solved over 20+ questions based on String Builder, Array List and Arrays.</p>
<p>Also, I decided to go for another Hackathon along with two of my classmates. It was one of the <strong>MLH hacks</strong>, called "<strong>Hack Around the World 2.0</strong>". Our project was "<strong>The Magnificent Seven</strong>" (Website link: <a target="_blank" href="https://magnificent-seven.vercel.app">https://magnificent-seven.vercel.app</a>, GitHub link: <a target="_blank" href="https://github.com/Swpn0neel/TheMagnificentSeven">https://github.com/Swpn0neel/TheMagnificentSeven</a>)We decided to use Three.js, Svelte and Tailwind CSS for the project. That's why, I started learning Svelte and Tailwind CSS. Also, I created the Figma design of the site. This was a much smaller scale project than the previous one but cramped most of our technical skills into it. And again, to our amazement, we managed to be the <strong><mark>Winner of this Hackathon</mark></strong>.</p>
<h3 id="heading-may-2023">May, 2023</h3>
<p>Paused DSA for a bit, but started learning C as it was a part of my college curriculum.</p>
<p>Also, I delved more into designing and started mastering animations and transitions in CSS and decided to build some small-scale projects using that. In that venture, I created around 5-6 projects that focused mainly on uniqueness and smooth animations. Check them out here: <a target="_blank" href="https://github.com/Swpn0neel/Web-Development-Projects">https://github.com/Swpn0neel/Web-Development-Projects</a></p>
<p>And the most important thing that happened at the end of the month. Previously, I mentioned that I wrote a number of blogs regarding Python in the months of February and March. Now, they got noticed by <strong><mark>Tutorials Point</mark></strong>, and I got a part-time job offer from them, whose first contract was to deliver an advanced Python course for their platform. I accepted the offer and started working for them.</p>
<h3 id="heading-june-2023">June, 2023</h3>
<p>This was a really special month, because I only earned, earned and earned in this one. Aside from Tutorials Point, I got some really good freelancing offers too: I created the UI/UX Design and wrote SEO-optimized content for some medium-scale businesses. Delivered some copywriting and technical writing jobs.</p>
<p>Also, this was the month of our second-semester exam. I was extremely loose academically this semester and didn't have high hopes about scoring. But still, some fruitful one-nighters helped me to get an <mark>SGPA of 9.14</mark>.</p>
<h3 id="heading-july-2023">July, 2023</h3>
<p>Took the after-semester break to my advantage and again went for an earning streak with various freelancing job offers.</p>
<p>For some time I hadn't attended any hackathons, so in the middle of the month, our same team from MLH Hacks decided to attend our first offline hackathon and we chose Eastern India's largest Hackathon, Hack 4 Bengal 2.0 for that. Everything was going nicely there, but one of our teammates faced health issues, and that's why we had to return to our home before the Hackathon ended. It was a disappointing failure for us.</p>
<p>But for me personally, it was extremely fruitful from an earning standpoint.</p>
<h3 id="heading-august-2023">August, 2023</h3>
<p>The month started with me hosting an introductory session to Open-Source at my University for my fellow peers, along with two other folks from my batch. It was my first mentoring and public speaking session.</p>
<p>Also, an important thing that caught my eye was that, I haven't learned a lot of things personally (except Python, most of my Freelancing works were dependent on that and I learned a lot of Python libraries during that time), as I was majorly focusing on earning. Also, I haven't touched DSA for some months.</p>
<p>So, I again started Leetcoding at the end of this month. Previously, I had completed 50+ problems, I added 10+ to that number this month.</p>
<h3 id="heading-september-2023">September, 2023</h3>
<p>Rejected all Freelancing offers this month and went hard on Leetcoding. I solved more than 90 problems this month, ranging from Linked List and Prefix Sum to Siding Window and Recursion problems.</p>
<p>Also, I started preparing for the Smart India Hackathon '23. Involved two juniors in our team so that they can have their first Hackathon experience and learn along the way. As part of the national hackathon, we have to qualify for the internal Hackathon of our University, MAKATHON '23. We qualified with flying colors taking the <mark>first position in the Hackathon</mark>.</p>
<h3 id="heading-october-2023">October, 2023</h3>
<p>Decided to make some complex projects related to Web Development and prepared some web designs on Figma for the same, while learning a bit more about UI/UX Designing in general.</p>
<p>Started taking weekly mentorship sessions for my juniors, so that they could learn at a better pace and not get distracted while being focused on the ultimate goal of upskilling themselves.</p>
<h1 id="heading-bonus">Bonus</h1>
<p>I have mentioned almost everything here. But I want to mention some things that weren't mentioned in the timeline.</p>
<ul>
<li><p>Python and its vast library have always been with me throughout my learning journey and earned me the majority of my bucks through freelancing.</p>
</li>
<li><p>I was able to purchase an ASUS TUF A15 laptop all by myself through freelancing ventures, and also manage a lot of my personal expenses besides making a little bit of savings for myself.</p>
</li>
<li><p>Since January, I've been active on Twitter and made a family of over 500 folks.</p>
</li>
<li><p>College academics were never my priority and I tried to ignore it as much as possible and gave the least possible amount of time to it.</p>
</li>
<li><p>Although I started my journey with the help of video tutorials, as time passed I majorly relied on official documentation and blogs because of their simplicity and least time requirement.</p>
</li>
<li><p>Other than the mentioned stuff, I had to learn quite a few other things like API management, handling ML models, and many more for project requirements. It's impossible for me to mention all of them in a single blog 😅.</p>
</li>
</ul>
<h1 id="heading-my-plans-for-the-second-year">My plans for the Second year</h1>
<p>So far, I have completed 170+ Leetcode problems, and my target moving forward is to cover all the DSA concepts in the 2nd year and at least reach the 600+ problems mark on Leetcode. Also, I'll start attending coding contests to put my skills to the test.</p>
<p>I will start delving into AI/ML and would like to get a solid grip on it by October 2024. Along with that, I plan to make some SaaS products with my knowledge of AI/ML and Web Development. Also, I'll attend more and more hackathons, because the learning opportunity from there is just undeniable. And, I would start focusing on subjects like System Design and Operating Systems. Plus, I would be actively looking forward to grabbing any internship opportunities.</p>
<p>And lastly, I would continue mentoring my fellow juniors and would start focusing on making Open-Source contributions to renowned organizations.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>And that's a wrap!! But if you have any queries regarding my journey or any suggestions for my future, I would love to hear that from you in the comments. Also, as a closing note, I would like to share my resume which I have created recently based on my progress so far, you can check it out <a target="_blank" href="https://docs.google.com/document/d/1c931FkeAugaefH0LcY2Irap0UOp4D9cLpyAgwjOt1ao/edit?usp=sharing">here</a>. And if you want to stay connected with me, you can follow me here or on my other social handles. Thank You for reading about my journey, have a nice day ahead!!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1698152151751/048427f8-d108-47e0-9f9d-79b1596fa335.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Best Frameworks to use for Web Development]]></title><description><![CDATA[Unleash the power of Web Development by embracing the finest Frameworks available in the market]]></description><link>https://swapnoneel.hashnode.dev/best-frameworks-to-use-for-web-development</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/best-frameworks-to-use-for-web-development</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[Vue.js]]></category><category><![CDATA[React]]></category><category><![CDATA[Angular]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Fri, 28 Jul 2023 15:04:47 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1688046842016/4af6c288-a81e-45f8-80aa-493eca0da77e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the rapidly evolving and progressive world of web development, front-end frameworks have become essential tools for creating sleek, interactive, and user-friendly websites and web applications. These frameworks provide developers with a solid foundation and a set of pre-defined components, libraries, and tools that streamline the development process, boost productivity, and enhance the overall user experience.</p>
<p>A front-end framework's main goal is to offer a standardized and effective method for creating user interfaces. These frameworks enable web designers to create flexible, mobile-friendly, and cross-browser-compatible websites that function flawlessly on a range of platforms and devices.</p>
<p>For any web development project, picking the appropriate front-end framework is essential. It relies on elements like the complexity of the project, the necessity for scalability, the resources at hand, and performance preferences. In the sections that follow, we'll go into great detail about some of the most well-liked front-end frameworks, going over their features, benefits, drawbacks, and typical use cases. This will give you useful information so you can decide which framework to learn or employ in a given situation.</p>
<h1 id="heading-what-makes-a-framework-good">What makes a framework "good"?</h1>
<p>Building contemporary online apps now requires a great deal of sophistication due to the constantly changing web development ecosystem. Nowadays, websites are dynamic, interactive platforms with complex functionalities, real-time updates, and seamless user experiences. They are no longer static web pages. To effectively address these demands, it is necessary to use reliable tools and frameworks due to the growing complexity of the situation.</p>
<p>A good front-end framework plays a vital role in addressing the challenges faced by developers. Here are some key reasons why utilizing a front-end framework is essential:</p>
<ol>
<li><p><strong>Structure and Organization</strong>: Front-end frameworks give a systematic method of development along with best practices, conventions, and recommendations. They provide a unified architecture, making sure the codebase is well-structured and manageable. The framework's guiding principles allow programmers to create scalable applications with ease.</p>
</li>
<li><p><strong>Productivity and Efficiency</strong>: Frameworks frequently include a collection of ready-made components and libraries that can be used on different projects. This reusability shortens the development process and increases production. Additionally, frameworks include pre-built tools and utilities for typical tasks like routing, state management, and form validation, allowing developers to work more quickly.</p>
</li>
<li><p><strong>Enhanced User Experience</strong>: The development of dynamic, interactive user interfaces is made possible by front-end frameworks. They offer features that improve the user experience, including responsive design, slick animations, and real-time updates. Frameworks allow developers to concentrate on creating user-friendly interfaces and developing compelling interactions.</p>
</li>
<li><p><strong>Cross-Browser Compatibility</strong>: It might be difficult to guarantee that websites and programs function consistently across various browsers and gadgets. Front-end frameworks eliminate this difficulty by incorporating responsiveness and compatibility into their design. Developers are spared from having to create unique code for each browser since they take care of the complexities of rendering across numerous platforms.</p>
</li>
<li><p><strong>Community and Support</strong>: Popular front-end frameworks have sizable and vibrant development communities. This translates into comprehensive documentation, guides, forums, and contributions to open-source projects. Utilizing a solid foundation guarantees access to beneficial materials, knowledge, and fixes for frequent issues.</p>
</li>
</ol>
<p>However, it's crucial to remember that no structure is appropriate in every circumstance. Each framework possesses unique advantages, disadvantages, and trade-offs. While certain frameworks may be better suited for small-scale projects, others thrive at creating complicated, large-scale systems. When choosing a front-end framework, it's important to take into account elements like project requirements, performance demands, learning curve, and community support.</p>
<p>In the following sections, we will delve into several popular front-end frameworks, including React, Vue.js, Angular, Express.js, SolidJS, Next.js, and Svelte. We will explore their features, advantages, disadvantages, and common use cases, providing a comprehensive understanding to help you make informed decisions in your web development journey.</p>
<h1 id="heading-react">React</h1>
<p>Developed by Facebook, React has gained immense popularity and has become one of the ultimate choices for many front-end developers. It is a JavaScript library(not a framework) that follows a component-based architecture, allowing developers to build reusable UI components. React's virtual DOM efficiently updates and renders only the necessary components, resulting in enhanced performance.</p>
<p><img src="https://ms314006.github.io/static/b7a8f321b0bbc07ca9b9d22a7a505ed5/97b31/React.jpg" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-react">Advantages of React</h3>
<ol>
<li><p><strong>Component-Based</strong>: React's component-based approach promotes reusability and modularity, making it easier to manage complex UI structures. Components encapsulate their logic and can be easily composed and reused across different parts of an application.</p>
</li>
<li><p><strong>Virtual DOM</strong>: React's virtual DOM efficiently tracks and updates only the necessary parts of the user interface, resulting in optimized rendering performance. This approach reduces the need for manual DOM manipulation, leading to faster and smoother user experiences.</p>
</li>
<li><p><strong>Large Ecosystem</strong>: React has a vast ecosystem with a wide range of third-party libraries, tools, and community support. This ecosystem offers solutions for state management (e.g., Redux), routing (e.g., React Router), form handling (e.g., Formik), and many other common development needs.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-react">Disadvantages of React</h3>
<ol>
<li><p><strong>Learning Curve</strong>: React has a steeper learning curve compared to some other front-end frameworks due to its unique concepts such as JSX (JavaScript XML) syntax and the use of a virtual DOM. However, once the initial learning phase is overcome, React's productivity and efficiency benefits become apparent.</p>
</li>
<li><p><strong>Configuration Over Convention</strong>: React leaves many decisions to the developers, which can lead to a wide range of implementation patterns and coding styles. This flexibility can be advantageous, but it also requires developers to make architectural decisions and maintain consistency within a team.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-react">Common Use Cases for React</h3>
<ol>
<li><p><strong>Single-Page Applications (SPAs)</strong>: React is well-suited for building SPAs where real-time updates and smooth user experiences are critical, such as social media platforms, interactive dashboards, and collaborative applications.</p>
</li>
<li><p><strong>Component Libraries</strong>: React's component-based architecture makes it an excellent choice for creating reusable UI component libraries. These libraries can be shared across projects and provide consistent design patterns.</p>
</li>
</ol>
<p>React's popularity, performance optimizations, and vast ecosystem make it a powerful framework for building modern, interactive web applications. Its flexibility and scalability make it suitable for both small-scale projects and large-scale applications.</p>
<h1 id="heading-vuejs">Vue.js</h1>
<p>Vue.js has rapidly gained popularity among front-end developers for its simplicity, versatility, and ease of integration. It is a progressive JavaScript framework that can be adopted incrementally, making it ideal for both small projects and large-scale applications.</p>
<p><img src="https://segwitz.com/wp-content/uploads/2021/06/vuejs-development-malaysia.jpeg" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-vuejs">Advantages of Vue.js</h3>
<ol>
<li><p><strong>Gentle Learning Curve</strong>: Vue.js is known for its gentle learning curve, allowing developers to quickly grasp its core concepts and start building applications. Its syntax is intuitive and similar to HTML, which facilitates easy adoption, especially for those new to front-end development.</p>
</li>
<li><p><strong>Flexibility and Integration</strong>: Vue.js can be easily integrated into existing projects or used as a standalone framework for building complete applications. Its adaptability allows developers to progressively enhance parts of their projects without requiring a full rewrite.</p>
</li>
<li><p><strong>Two-Way Data Binding</strong>: Vue.js offers efficient two-way data binding, allowing seamless synchronization between the model and the view. This simplifies the management of data changes and eliminates the need for manual DOM manipulation.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-vuejs">Disadvantages of Vue.js</h3>
<ol>
<li><p><strong>Smaller Ecosystem</strong>: While Vue.js has a growing ecosystem, it may not have the same breadth and depth of libraries and tools as some other frameworks like React or Angular. However, it does provide essential plugins and solutions for common tasks.</p>
</li>
<li><p><strong>Maturity</strong>: As Vue.js is a relatively newer framework compared to React or Angular, some enterprises may hesitate to adopt it for large-scale projects due to concerns about its long-term stability and support. However, Vue.js has been rapidly gaining momentum and has a thriving community behind it.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-vuejs">Common Use Cases for Vue.js</h3>
<ol>
<li><p><strong>Single-Page Applications (SPAs)</strong>: Vue.js is well-suited for building SPAs that require dynamic updates and interactive user interfaces. Its simplicity and flexibility make it an excellent choice for developing lightweight and responsive applications.</p>
</li>
<li><p><strong>Prototyping</strong>: Vue.js's ease of use and quick setup make it a popular choice for prototyping and building minimum viable products (MVPs). It allows developers to rapidly iterate and validate ideas before investing in a more complex architecture.</p>
</li>
</ol>
<p>Vue.js's approachability, versatility, and incremental adoption make it an appealing choice for many developers. Its lightweight nature and straightforward syntax enable developers to build efficient and scalable applications while enjoying a smooth learning curve.</p>
<h1 id="heading-angularjs">Angular.js</h1>
<p>Angular, developed and maintained by Google, is a comprehensive front-end framework for building complex and scalable web applications. It provides a complete solution that covers various aspects of development, including templating, data binding, dependency injection, routing, and more.</p>
<p><img src="https://www.searchenginejournal.com/wp-content/uploads/2019/04/the-seo-guide-to-angular.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-angular">Advantages of Angular</h3>
<ol>
<li><p><strong>Powerful Template System</strong>: Angular's template system allows developers to declaratively define the structure and behavior of their application's UI. It provides features like data binding, event handling, and structural directives, making it easier to create dynamic and interactive interfaces.</p>
</li>
<li><p><strong>Dependency Injection</strong>: Angular's built-in dependency injection system promotes modularity and reusability by managing the dependencies between different parts of an application. It simplifies testing and enables the creation of highly maintainable and scalable codebases.</p>
</li>
<li><p><strong>Two-Way Data Binding</strong>: Angular's two-way data binding simplifies the synchronization between the model and the view, ensuring that changes in one are automatically reflected in the other. This eliminates the need for manual DOM manipulation and reduces boilerplate code.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-angular">Disadvantages of Angular</h3>
<ol>
<li><p><strong>Steeper Learning Curve</strong>: Angular has a steeper learning curve compared to some other front-end frameworks due to its extensive feature set and complex concepts. It requires a thorough understanding of TypeScript, decorators, and the framework's architectural patterns.</p>
</li>
<li><p><strong>Larger Bundle Size</strong>: Due to its comprehensive nature, Angular's bundle size is relatively larger compared to other frameworks. This can impact initial page load times, especially for smaller projects or mobile devices with limited bandwidth.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-angular">Common Use Cases for Angular</h3>
<ol>
<li><p><strong>Enterprise Applications</strong>: Angular's comprehensive nature and built-in features make it an excellent choice for large-scale enterprise applications. Its dependency injection system and powerful template engine simplify the development of complex UIs and manage application-wide state.</p>
</li>
<li><p><strong>Real-Time Dashboards</strong>: Angular's data binding and component-based architecture make it well-suited for creating real-time dashboards and data visualization applications. Its robust ecosystem provides libraries and tools specifically designed for such use cases.</p>
</li>
<li><p><strong>Progressive Web Applications (PWAs)</strong>: Angular has built-in support for building PWAs, allowing developers to create web applications that can function offline, provide native-like experiences, and be installed on users' devices.</p>
</li>
</ol>
<p>Angular's feature-rich nature and strong community support make it an attractive choice for developers working on large-scale, enterprise-level applications. Its robustness and comprehensive toolset empower developers to build complex applications with ease while adhering to best practices and maintainability.</p>
<h1 id="heading-expressjs">Express.js</h1>
<p>While not strictly a front-end framework, Express.js is a popular back-end framework for Node.js that can be effectively used alongside front-end frameworks to handle server-side rendering, API development, and routing.</p>
<p><img src="https://miro.medium.com/v2/resize:fit:805/0*m1VOQP0FtcQufLgw.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-expressjs">Advantages of Express.js</h3>
<ol>
<li><p><strong>Simplicity and Minimalism</strong>: Express.js is known for its simplicity and minimalistic approach. It provides a lightweight foundation for building web applications, allowing developers to have fine-grained control over their server-side logic and middleware.</p>
</li>
<li><p><strong>Flexibility and Customization</strong>: Express.js provides a flexible and unopinionated structure, enabling developers to tailor the application's architecture and design according to their specific requirements. It allows for modular development, making it easy to add or remove functionality as needed.</p>
</li>
<li><p><strong>Large and Active Community</strong>: Express.js has a large and active community of developers, resulting in extensive documentation, tutorials, and community-driven packages. This support network makes it easier to find solutions to common problems and ensures that the framework remains up to date.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-expressjs">Disadvantages of Express.js</h3>
<ol>
<li><p><strong>Lack of Built-in Features</strong>: Express.js is intentionally designed to be minimalistic, which means it lacks certain features out of the box. Developers may need to rely on third-party libraries or write additional code to handle tasks such as database integration, authentication, and form validation.</p>
</li>
<li><p><strong>Learning Curve</strong>: While Express.js is relatively easy to get started with, mastering advanced concepts and effectively utilizing middleware can require additional learning and experience. Developers need to be familiar with JavaScript and understand server-side concepts to leverage Express.js effectively.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-expressjs">Common Use Cases for Express.js</h3>
<ol>
<li><p><strong>Server-Side Rendering (SSR)</strong>: Express.js can be used in conjunction with front-end frameworks like React or Vue.js to perform server-side rendering. This allows applications to deliver pre-rendered HTML content to improve initial page load times and facilitate search engine optimization (SEO).</p>
</li>
<li><p><strong>API Development</strong>: Express.js provides a straightforward way to create robust and scalable APIs. Its lightweight structure and middleware support make it an ideal choice for building RESTful APIs or developing microservices.</p>
</li>
<li><p><strong>Proxy Servers</strong>: Express.js can be used as a proxy server to handle requests, modify headers, and route traffic to different backend servers. This is particularly useful when developing applications that require communication with multiple APIs or when implementing load balancing.</p>
</li>
</ol>
<p>Express.js offers developers the freedom to craft server-side logic and seamlessly integrate it with front-end frameworks. Its simplicity, flexibility, and active community make it a popular choice for building backend services and APIs to complement front-end development efforts.</p>
<h1 id="heading-solidjs">Solid.js</h1>
<p>SolidJS is a lightweight and reactive JavaScript library for building user interfaces. It differentiates itself from other frameworks by focusing on performance, reactivity, and simplicity. SolidJS leverages fine-grained reactivity to efficiently update components, resulting in fast rendering and optimal performance.</p>
<p><img src="https://www.solidjs.com/og.jpg" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-solidjs">Advantages of SolidJS</h3>
<ol>
<li><p><strong>Reactivity and Performance</strong>: SolidJS's reactivity system allows for granular updates, ensuring that only the necessary components are re-rendered when data changes. This fine-grained reactivity leads to excellent performance, making SolidJS well-suited for building high-performance web applications.</p>
</li>
<li><p><strong>Small Bundle Size</strong>: SolidJS boasts an impressively small bundle size compared to other front-end frameworks. Its minimalistic nature allows applications built with SolidJS to load quickly, making it suitable for projects with strict performance requirements.</p>
</li>
<li><p><strong>Simple API</strong>: SolidJS follows a simple and intuitive API design, making it easy to learn and use. Its syntax resembles JavaScript and HTML, reducing the learning curve for developers familiar with these languages.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-solidjs">Disadvantages of SolidJS</h3>
<ol>
<li><p><strong>Smaller Ecosystem</strong>: As SolidJS is a relatively newer framework, its ecosystem is still growing and may not be as extensive as more established frameworks like React or Vue.js. This means there might be fewer ready-to-use libraries and tools available for specific needs.</p>
</li>
<li><p><strong>Limited Community Support</strong>: While SolidJS has an active community, it may not have the same level of community support and resources as larger frameworks. Finding tutorials, documentation, and community-driven solutions may require more effort.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-solidjs">Common Use Cases for SolidJS</h3>
<ol>
<li><p><strong>Single-Page Applications (SPAs)</strong>: SolidJS excels in building SPAs where performance is crucial. Its reactivity system ensures fast updates and renders, making it ideal for real-time dashboards, data-intensive applications, and applications requiring smooth user experiences.</p>
</li>
<li><p><strong>Component-Driven Development</strong>: SolidJS's focus on components and reactivity makes it a suitable choice for projects that heavily rely on reusable and composable UI components. Developers can leverage SolidJS to build modular and maintainable component libraries.</p>
</li>
<li><p><strong>Progressive Web Applications (PWAs)</strong>: SolidJS can be used to build PWAs, leveraging its performance optimizations and small bundle size to create fast and efficient offline-capable web applications.</p>
</li>
</ol>
<p>SolidJS's emphasis on performance, simplicity, and reactivity makes it an intriguing option for developers seeking a lightweight and reactive framework. While it may not have the same level of maturity or ecosystem as some other frameworks, SolidJS offers a solid foundation for building performant and scalable applications.</p>
<h1 id="heading-nextjs">Next.js</h1>
<p>Next.js is a React framework that focuses on server-side rendering (SSR) and static site generation (SSG). It provides a robust development environment and an optimized production build, making it a powerful choice for building fast and scalable web applications.</p>
<p><img src="https://images.ctfassets.net/c63hsprlvlya/IacLLeOBR5WCvdCPqKuff/6860b5cc464c4f54703a2befa3f706b4/nextjs3.webp" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-nextjs">Advantages of Next.js</h3>
<ol>
<li><p><strong>Server-Side Rendering (SSR) and Static Site Generation (SSG)</strong>: Next.js offers built-in support for server-side rendering and static site generation. SSR allows pages to be pre-rendered on the server, resulting in faster initial page loads and improved SEO. SSG generates static HTML files at build time, allowing for fast delivery of content and reducing server load.</p>
</li>
<li><p><strong>Automatic Code Splitting:</strong> Next.js automatically splits JavaScript code into smaller chunks, enabling lazy loading and optimizing the loading performance of the application. This feature improves page load times by loading only the necessary code for each specific page.</p>
</li>
<li><p><strong>Simplified Routing and API Handling</strong>: Next.js provides a straightforward routing system and makes it easy to create API endpoints. Developers can define API routes within the same project, simplifying the development of serverless functions and backend APIs.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-nextjs">Disadvantages of Next.js</h3>
<ol>
<li><p><strong>Learning Curve</strong>: While Next.js builds upon React, it introduces additional concepts and configuration options that may require a learning curve for developers new to the framework. Understanding server-side rendering, static site generation, and the project structure of Next.js is necessary to leverage its full potential.</p>
</li>
<li><p><strong>Complexity for Simple Projects</strong>: Next.js is a powerful framework but might introduce unnecessary complexity for small and simple projects. If a project doesn't require server-side rendering or advanced routing capabilities, using Next.js might be overkill.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-nextjs">Common Use Cases for Next.js</h3>
<ol>
<li><p><strong>Content-Rich Websites and Blogs</strong>: Next.js's support for server-side rendering and static site generation makes it an excellent choice for content-heavy websites, blogs, and documentation platforms. It enables efficient content delivery, improved SEO, and easy content management.</p>
</li>
<li><p><strong>E-commerce Applications</strong>: Next.js provides the ability to render product pages on the server, resulting in faster load times and improved search engine visibility for e-commerce applications. Additionally, Next.js's support for dynamic routing and API handling simplifies the implementation of shopping cart functionality and checkout processes.</p>
</li>
<li><p><strong>Micro-Frontend Architecture</strong>: Next.js can be utilized in a micro-frontend architecture to build independent and scalable front-end modules. It allows each module to be developed and deployed separately while benefiting from the performance optimizations and server-side rendering capabilities of Next.js.</p>
</li>
</ol>
<p>Next.js's focus on server-side rendering, static site generation, and optimized performance makes it a compelling choice for building modern web applications. Its seamless integration with React and simplified routing system provide developers with the tools needed to create efficient and dynamic web experiences.</p>
<h1 id="heading-svelte">Svelte</h1>
<p>Svelte is a radical approach to front-end frameworks that shifts the work traditionally done by the framework from runtime to build time. It compiles components into highly efficient JavaScript code, resulting in fast rendering and smaller bundle size.</p>
<p><img src="https://codemonk.in/blog/content/images/2022/03/Svelte-Feature-Image.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-advantages-of-svelte">Advantages of Svelte</h3>
<ol>
<li><p><strong>Reactive Component Architecture</strong>: Svelte introduces a reactive component architecture that automatically updates the DOM when the underlying state changes. This approach eliminates the need for a virtual DOM, resulting in faster rendering and improved performance.</p>
</li>
<li><p><strong>Smaller Bundle Size</strong>: Svelte compiles components into optimized JavaScript code, resulting in smaller bundle sizes compared to other frameworks. This smaller footprint leads to faster loading times, improved user experiences, and reduced bandwidth consumption.</p>
</li>
<li><p><strong>Easy Learning Curve</strong>: Svelte's simplicity and minimalistic syntax make it easy to learn and use. It leverages familiar HTML, CSS, and JavaScript concepts, allowing developers to quickly grasp the core concepts and start building applications.</p>
</li>
</ol>
<h3 id="heading-disadvantages-of-svelte">Disadvantages of Svelte</h3>
<ol>
<li><p><strong>Smaller Ecosystem</strong>: While Svelte's ecosystem is growing, it may not have the same breadth and depth of libraries, tools, and community support as more established frameworks like React or Angular. However, Svelte's ecosystem is continuously expanding, and popular libraries are being adapted for Svelte.</p>
</li>
<li><p><strong>Less Maturity</strong>: As a relatively newer framework, Svelte may be perceived as having less maturity compared to other frameworks. This can sometimes lead to a smaller pool of experienced developers or limited resources for troubleshooting complex issues.</p>
</li>
</ol>
<h3 id="heading-common-use-cases-for-svelte">Common Use Cases for Svelte</h3>
<ol>
<li><p><strong>Single-Page Applications (SPAs)</strong>: Svelte's efficient rendering and small bundle size make it suitable for building SPAs that require excellent performance. Its reactive component architecture enables the creation of responsive and interactive user interfaces.</p>
</li>
<li><p><strong>Embeddable Widgets</strong>: Svelte's small footprint and easy integration make it ideal for building embeddable widgets or components that can be added to existing websites or applications. These widgets can be easily shared and used across multiple projects.</p>
</li>
<li><p><strong>Prototyping and Proof of Concepts</strong>: Svelte's simplicity and quick setup make it a great choice for prototyping and creating proof of concepts. Its minimal configuration requirements allow developers to focus on building functionality without the overhead of a more complex framework.</p>
</li>
</ol>
<p>Svelte's unique approach to front-end development, focusing on build-time compilation and reactivity, sets it apart from other frameworks. Its small bundle size, fast rendering, and simple syntax make it an attractive option for developers aiming for high performance and efficiency in their web applications.</p>
<h1 id="heading-tldr">TLDR</h1>
<p>Choosing the right front-end framework is a crucial decision for web developers, as it significantly impacts the development process, code maintainability, and overall user experience. In this article, we explored several popular front-end frameworks and their respective advantages and disadvantages.</p>
<ul>
<li><p><strong><em>React, with its component-based architecture and vast ecosystem, remains one of the most widely used frameworks. It excels in building reusable UI components and provides excellent performance and scalability.</em></strong></p>
</li>
<li><p><strong><em>Vue.js, known for its simplicity and ease of integration, offers a progressive framework that caters to developers of all skill levels. It's flexible nature and straightforward syntax make it a popular choice for building interactive and dynamic applications.</em></strong></p>
</li>
<li><p><strong><em>Angular, with its comprehensive feature set and strong dependency injection system, is well-suited for large-scale enterprise applications. Its powerful template system and two-way data binding simplify UI development and state management.</em></strong></p>
</li>
<li><p><strong><em>Express.js, although a back-end framework, complements front-end development by providing a minimalistic and flexible environment for server-side rendering and API development. It's simplicity and extensive community support make it a popular choice for building backend services.</em></strong></p>
</li>
<li><p><strong><em>SolidJS, a lightweight and reactive library, emphasizes performance and simplicity. It's fine-grained reactivity and small bundle size make it ideal for high-performance web applications that require optimal rendering and fast user experiences.</em></strong></p>
</li>
<li><p><strong><em>Next.js, built on top of React, offers powerful server-side rendering and static site generation capabilities. It simplifies routing, enhances performance, and is well-suited for content-rich websites, e-commerce applications, and micro-frontend architectures.</em></strong></p>
</li>
<li><p><strong><em>Svelte takes a unique approach by shifting the heavy lifting to build time, resulting in highly efficient compiled JavaScript code. Its reactive component architecture and small bundle size make it a compelling choice for high-performance SPAs and embeddable widgets.</em></strong></p>
</li>
</ul>
<p>Ultimately, the choice of a front-end framework depends on various factors, such as project requirements, team expertise, and performance considerations. It is essential to weigh the pros and cons of each framework and consider the specific needs of your application.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Thank you for reading the blog! I hope you found it informative and valuable. By understanding the usage, advantages and disadvantages of each framework, I think it will be extremely easy for you to choose the best possible framework for any particular project.</p>
<p>For more information, follow me on <a target="_blank" href="http://twitter.com/swapnoneel123">Twitter @swapnoneel123</a> where I share more such content through my tweets and threads. And, please consider sharing it with others on <strong>Twitter</strong> and tag me in your post so I can see it too. You can also check my <a target="_blank" href="https://github.com/Swpn0neel">GitHub(username: Swpn0neel)</a> to see my projects.</p>
<p>I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://contenthub-static.grammarly.com/blog/wp-content/uploads/2019/02/bmd-4584.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[DevBytes: Short Coding News]]></title><description><![CDATA[DevBytes is a comprehensive and user-friendly programming and technology news mobile application that delivers the latest and most helpful tech news.]]></description><link>https://swapnoneel.hashnode.dev/devbytes-short-coding-news</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/devbytes-short-coding-news</guid><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Tue, 28 Mar 2023 15:12:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1679999476023/496d151a-c10f-4b24-946f-3791d78f6f54.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-what-is-devbytes">What is DevBytes?</h1>
<p>DevBytes is a comprehensive and user-friendly programming and technology news mobile application that is designed to cater to your specific interests. With its advanced algorithms, it sifts through vast amounts of information to bring you the latest and most helpful tech news that is tailored to your domain of interest. Unlike other tech news applications, DevBytes is highly efficient and values your time, delivering the information you need in a concise and precise manner, within a maximum of 64 words.</p>
<h1 id="heading-main-features">Main Features</h1>
<p><strong><em>DevBytes has numerous standout features that distinguish it from other offerings. Let's take a closer look at each one to understand their significance.</em></strong></p>
<h2 id="heading-your-content-your-choices"><em>Your Content, Your Choices</em></h2>
<p>The platform has an innovative design that includes a customizable interface, allowing users to personalize their news feed according to their preferences. Users can receive the latest breaking news, important updates, and innovative highlights through the platform's personalized news feed. Unlike other apps, this platform's approach is streamlined, ensuring that users only receive news that is relevant to them, which saves them time and effort.</p>
<h2 id="heading-everything-within-64-words"><em>Everything within 64 words</em></h2>
<p>DevBytes prides itself on valuing users' time and delivering news in a fast and efficient manner. We stand out by presenting a concise 64-word news story that offers precise, easily understandable information without compromising quality or accuracy. Our focus is on streamlining the news experience by selecting relevant stories and prioritizing brevity and clarity. This means you can stay up-to-date on the latest without having to sift through unnecessary details. Our skilled team of journalists and editors work diligently to craft each news story with care and precision, ensuring that every word counts towards delivering the most essential information. Whether you're interested in the latest tech updates, new product launches, or global events, DevBytes is committed to providing you with the information you need, when you need it, in a format that respects your time and intelligence.</p>
<h2 id="heading-jobs-at-hand"><em>"Jobs" at Hand</em></h2>
<p>Take advantage of amazing opportunities with DevBytes! Keep yourself informed about the newest job vacancies from various global companies that align with your area of expertise, easily accessible in a single feed.</p>
<h1 id="heading-additional-features">Additional Features</h1>
<ul>
<li><p><strong><mark>Code Snippets</mark>:</strong> <em>Easily learn and apply coding tips and tricks by reading and executing the attached code on the go.</em></p>
</li>
<li><p><strong><mark>Crypto Watch</mark></strong>: <em>Stay updated on your preferred cryptocurrencies at all times using the convenient on-the-go feature.</em></p>
</li>
<li><p><strong><mark>Deals and Discounts</mark></strong>: <em>Take advantage of amazing deals and promotions on fantastic products or subscriptions.</em></p>
</li>
<li><p><strong><mark>Product of the Day</mark></strong>: <em>Discover handpicked productivity tools on your feed.</em></p>
</li>
</ul>
<h1 id="heading-conclusion">Conclusion</h1>
<p>DevBytes is an incredible app that I've had the pleasure of using. What makes it stand out is its focus on putting its users first by providing all the amenities they may require. The app features a sleek design and a minimalistic appearance, ensuring users have the best possible experience.</p>
<p>In today's era of rapid technological advancements, apps like DevBytes are the optimal choice. If you've ever wondered how I manage to stay up-to-date with the latest tech trends, let me share a little secret with you - it's all thanks to DevBytes.</p>
<p>If you have enjoyed reading this blog, I recommend checking out the app available on PlayStore. You can find the link to download it here: <a target="_blank" href="https://play.google.com/store/apps/details?id=com.candelalabs.devbytes&amp;utm_source=app">DevBytes</a></p>
<p><img src="https://c0.wallpaperflare.com/preview/726/785/255/blackboard-close-up-frame-gratitude.jpg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Inheritance in Python]]></title><description><![CDATA[Exploring the Concept of Inheritance in Python Programming.]]></description><link>https://swapnoneel.hashnode.dev/inheritance-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/inheritance-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Tue, 07 Mar 2023 15:49:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1678204130081/f9516095-c93b-4255-84f1-3f241e523153.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Inheritance is a key concept in object-oriented programming that allows classes to inherit attributes and methods from other classes. In Python, inheritance is a powerful tool that can help you write more efficient and maintainable code by reusing existing code and building upon it. Python offers several types of inheritance, including single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, and hybrid inheritance. Each type of inheritance has its own syntax and use cases, and understanding them is crucial for building complex and scalable programs in Python. In this article, we will explore the different types of inheritance in Python and provide examples to help you understand how to use them in your own code.</p>
<h1 id="heading-definition">Definition</h1>
<p>When a class derives from another class. The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods, this is called inheritance.</p>
<h2 id="heading-general-syntax-for-inheritance">General Syntax for Inheritance</h2>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BaseClass</span>:</span>
  Body of base <span class="hljs-class"><span class="hljs-keyword">class</span>
<span class="hljs-title">class</span> <span class="hljs-title">DerivedClass</span>(<span class="hljs-params">BaseClass</span>):</span>
  Body of derived <span class="hljs-class"><span class="hljs-keyword">class</span></span>
</code></pre>
<p>The derived class inherits features from the base class where new features can be added to it. This results in the re-usability of code.</p>
<h1 id="heading-types-of-inheritance">Types of Inheritance</h1>
<ol>
<li><p>Single Inheritance</p>
</li>
<li><p>Multiple Inheritance</p>
</li>
<li><p>Multilevel Inheritance</p>
</li>
<li><p>Hierarchical Inheritance</p>
</li>
<li><p>Hybrid Inheritance</p>
</li>
</ol>
<h1 id="heading-single-inheritance">Single Inheritance</h1>
<p>Single inheritance is a type of inheritance where a class inherits properties and behaviors from a single-parent class. This is the simplest and most common form of inheritance.</p>
<p>Single inheritance is a powerful tool in Python that allows you to create new classes based on existing classes. It allows you to reuse code, extend it to fit your needs and make it easier to manage complex systems. Understanding single inheritance is an important step in becoming proficient in object-oriented programming in Python.</p>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/20200108135809/inheritance11.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-syntax">Syntax</h2>
<p>The syntax for single inheritance in Python is straightforward and easy to understand. To create a new class that inherits from a parent class, simply specify the parent class in the class definition, inside the parentheses, like this:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ChildClass</span>(<span class="hljs-params">ParentClass</span>):</span>
    <span class="hljs-comment"># class body</span>
</code></pre>
<h2 id="heading-example">Example</h2>
<p>Let's consider a simple example of single inheritance in Python. Consider a class named "Animal" that contains the attributes and behaviors that are common to all animals.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Animal</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, species</span>):</span>
        self.name = name
        self.species = species

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">make_sound</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Sound made by the animal"</span>)
</code></pre>
<p>If we want to create a new class for a specific type of animal, such as a dog, we can create a new class named "Dog" that inherits from the Animal class.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Dog</span>(<span class="hljs-params">Animal</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, breed</span>):</span>
        Animal.__init__(self, name, species=<span class="hljs-string">"Dog"</span>)
        self.breed = breed

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">make_sound</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Bark!"</span>)
</code></pre>
<p>The Dog class inherits all the attributes and behaviors of the Animal class, including the <code>__init__</code> method and the <code>make_sound</code> method. Additionally, the Dog class has its own <code>__init__</code> method that adds a new attribute for the breed of the dog, and it also overrides the <code>make_sound</code> method to specify the sound that a dog makes.</p>
<h1 id="heading-multiple-inheritance">Multiple Inheritance</h1>
<p>Multiple inheritance is a powerful feature in object-oriented programming that allows a class to inherit attributes and methods from multiple parent classes. This can be useful in situations where a class needs to inherit functionality from multiple sources.</p>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/20200108144424/multiple-inheritance1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-syntax-1">Syntax</h2>
<p>In Python, multiple inheritance is implemented by specifying multiple parent classes in the class definition, separated by commas.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ChildClass</span>(<span class="hljs-params">ParentClass1, ParentClass2, ParentClass3</span>):</span>
    <span class="hljs-comment"># class body</span>
</code></pre>
<p>In this example, the <code>ChildClass</code> inherits attributes and methods from all three parent classes: <code>ParentClass1</code>, <code>ParentClass2</code>, and <code>ParentClass3</code>.</p>
<p>It's important to note that, in the case of multiple inheritance, Python follows a <code>method resolution order (MRO)</code> to resolve conflicts between methods or attributes from different parent classes. The MRO determines the order in which parent classes are searched for attributes and methods.</p>
<h2 id="heading-example-1">Example</h2>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Animal</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, species</span>):</span>
        self.name = name
        self.species = species

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">make_sound</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Sound made by the animal"</span>)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Mammal</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, fur_color</span>):</span>
        self.name = name
        self.fur_color = fur_color

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Dog</span>(<span class="hljs-params">Animal, Mammal</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, breed, fur_color</span>):</span>
        Animal.__init__(self, name, species=<span class="hljs-string">"Dog"</span>)
        Mammal.__init__(self, name, fur_color)
        self.breed = breed

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">make_sound</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Bark!"</span>)
</code></pre>
<p>In this example, the <code>Dog</code> class inherits from both the <code>Animal</code> and <code>Mammal</code> classes, so it can use attributes and methods from both parent classes.</p>
<h1 id="heading-multilevel-inheritance">Multilevel Inheritance</h1>
<p>Multilevel inheritance is a type of inheritance in object-oriented programming where a derived class inherits from another derived class. This type of inheritance allows you to build a hierarchy of classes where one class builds upon another, leading to a more specialized class.</p>
<p>In Python, multilevel inheritance is achieved by using the class hierarchy. The syntax for multilevel inheritance is quite simple and follows the same syntax as single inheritance.</p>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/20200108144705/Multilevel-inheritance1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-syntax-2">Syntax</h2>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BaseClass</span>:</span>
    <span class="hljs-comment"># Base class code</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DerivedClass1</span>(<span class="hljs-params">BaseClass</span>):</span>
    <span class="hljs-comment"># Derived class 1 code</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DerivedClass2</span>(<span class="hljs-params">DerivedClass1</span>):</span>
    <span class="hljs-comment"># Derived class 2 code</span>
</code></pre>
<p>In the above example, we have three classes: <code>BaseClass</code>, <code>DerivedClass1</code>, and <code>DerivedClass2</code>. The <code>DerivedClass1</code> class inherits from the <code>BaseClass</code>, and the <code>DerivedClass2</code> class inherits from the <code>DerivedClass1</code> class. This creates a hierarchy where <code>DerivedClass2</code> has access to all the attributes and methods of both <code>DerivedClass1</code> and <code>BaseClass</code>.</p>
<h2 id="heading-example-2">Example</h2>
<p>Let's take a look at an example to understand how multilevel inheritance works in Python. Consider the following classes:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Animal</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, species</span>):</span>
        self.name = name
        self.species = species

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">f"Name: <span class="hljs-subst">{self.name}</span>"</span>)
        print(<span class="hljs-string">f"Species: <span class="hljs-subst">{self.species}</span>"</span>)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Dog</span>(<span class="hljs-params">Animal</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, breed</span>):</span>
        Animal.__init__(self, name, species=<span class="hljs-string">"Dog"</span>)
        self.breed = breed

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
        Animal.show_details(self)
        print(<span class="hljs-string">f"Breed: <span class="hljs-subst">{self.breed}</span>"</span>)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">GoldenRetriever</span>(<span class="hljs-params">Dog</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, color</span>):</span>
        Dog.__init__(self, name, breed=<span class="hljs-string">"Golden Retriever"</span>)
        self.color = color

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
        Dog.show_details(self)
        print(<span class="hljs-string">f"Color: <span class="hljs-subst">{self.color}</span>"</span>)
</code></pre>
<p>In this example, we have three classes: <code>Animal</code>, <code>Dog</code>, and <code>GoldenRetriever</code>. The <code>Dog</code> class inherits from the <code>Animal</code> class, and the <code>GoldenRetriever</code> class inherits from the <code>Dog</code> class.</p>
<p>Now, when we create an object of the <code>GoldenRetriever</code> class; it has access to all the attributes and methods of the <code>Animal</code> class and the <code>Dog</code> class. We can also see that the <code>GoldenRetriever</code> class has its own attributes and methods that are specific to the class.</p>
<pre><code class="lang-python">dog = GoldenRetriever(<span class="hljs-string">"Max"</span>, <span class="hljs-string">"Golden"</span>)
dog.show_details()
</code></pre>
<h2 id="heading-output">Output</h2>
<pre><code class="lang-python">Name: Max
Species: Dog
Breed: Golden Retriever
Color: Golden
</code></pre>
<p>As we can see from the output, the <code>GoldenRetriever</code> object has access to all the attributes and methods of the <code>Animal</code> and <code>Dog</code> classes, and, it has also added its own unique attributes and methods. This is a powerful feature of multilevel inheritance, as it allows you to create more complex and intricate classes by building upon existing ones.</p>
<p>Another important aspect of multilevel inheritance is that it allows you to reuse code and avoid repeating the same logic multiple times. This can lead to better maintainability and readability of your code, as you can abstract away complex logic into base classes and build upon them.</p>
<p>In conclusion, multilevel inheritance is a powerful feature in object-oriented programming that allows you to create complex and intricate classes by building upon existing ones. It provides the benefits of code reuse, maintainability, and readability, while also requiring careful consideration to avoid potential problems.</p>
<h1 id="heading-hybrid-inheritance">Hybrid Inheritance</h1>
<p>Hybrid inheritance is a combination of multiple inheritance and single inheritance in object-oriented programming. It is a type of inheritance in which multiple inheritance is used to inherit the properties of multiple base classes into a single derived class, and single inheritance is used to inherit the properties of the derived class into a sub-derived class.</p>
<p>In Python, hybrid inheritance can be implemented by creating a class hierarchy, in which a base class is inherited by multiple derived classes, and one of the derived classes is further inherited by a sub-derived class.</p>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/Hybrid-Inheritance.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-syntax-3">Syntax</h2>
<p>The syntax for implementing Hybrid Inheritance in Python is the same as for implementing Single Inheritance, Multiple Inheritance, or Hierarchical Inheritance.</p>
<p>Here's the syntax for defining a hybrid inheritance class hierarchy:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BaseClass1</span>:</span>
  <span class="hljs-comment"># attributes and methods</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">BaseClass2</span>:</span>
  <span class="hljs-comment"># attributes and methods</span>

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DerivedClass</span>(<span class="hljs-params">BaseClass1, BaseClass2</span>):</span>
  <span class="hljs-comment"># attributes and methods</span>
</code></pre>
<h2 id="heading-example-3">Example</h2>
<p>Consider the example of a <code>Student</code> class that inherits from the <code>Person</code> class, which in turn inherits from the <code>Human</code> class. The <code>Student</code> class also has a <code>Program</code> class that it is associated with.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Human</span>:</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, age</span>):</span>
    self.name = name
    self.age = age

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
    print(<span class="hljs-string">"Name:"</span>, self.name)
    print(<span class="hljs-string">"Age:"</span>, self.age)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>(<span class="hljs-params">Human</span>):</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, age, address</span>):</span>
    Human.__init__(self, name, age)
    self.address = address

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
    Human.show_details(self)
    print(<span class="hljs-string">"Address:"</span>, self.address)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Program</span>:</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, program_name, duration</span>):</span>
    self.program_name = program_name
    self.duration = duration

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
    print(<span class="hljs-string">"Program Name:"</span>, self.program_name)
    print(<span class="hljs-string">"Duration:"</span>, self.duration)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Student</span>(<span class="hljs-params">Person</span>):</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, age, address, program</span>):</span>
    Person.__init__(self, name, age, address)
    self.program = program

  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
    Person.show_details(self)
    self.program.show_details()
</code></pre>
<p>In this example, the <code>Student</code> class inherits from the <code>Person</code> class, which in turn inherits from the <code>Human</code> class. The <code>Student</code> class also has an association with the <code>Program</code> class. This is an example of Hybrid Inheritance in action, as it uses both Single Inheritance and Association to achieve the desired inheritance structure.</p>
<p>To create a <code>Student</code> object, we can do the following:</p>
<pre><code class="lang-python">program = Program(<span class="hljs-string">"Computer Science"</span>, <span class="hljs-number">4</span>)
student = Student(<span class="hljs-string">"John Doe"</span>, <span class="hljs-number">25</span>, <span class="hljs-string">"123 Main St."</span>, program)
student.show_details()
</code></pre>
<h2 id="heading-output-1">Output</h2>
<pre><code class="lang-python">Name: John Doe
Age: <span class="hljs-number">25</span>
Address: <span class="hljs-number">123</span> Main St.
Program Name: Computer Science
Duration: <span class="hljs-number">4</span>
</code></pre>
<p>As we can see from the output, the <code>Student</code> object has access to all the attributes and methods of the <code>Person</code> and <code>Human</code> classes, as well as the <code>Program</code> class through association.</p>
<p>In this way, hybrid inheritance allows for a flexible and powerful way to inherit attributes and behaviors from multiple classes in a hierarchy or chain.</p>
<h1 id="heading-hierarchical-inheritance">Hierarchical Inheritance</h1>
<p>Hierarchical Inheritance is a type of inheritance in Object-Oriented Programming where multiple subclasses inherit from a single base class. In other words, a single base class acts as a parent class for multiple subclasses. This is a way of establishing relationships between classes in a hierarchical manner.</p>
<p><img src="https://media.geeksforgeeks.org/wp-content/uploads/20200108144949/Hierarchical-inheritance1.png" alt class="image--center mx-auto" /></p>
<p>Here's an example to illustrate the concept of hierarchical inheritance in Python:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Animal</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name</span>):</span>
        self.name = name

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Name:"</span>, self.name)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Dog</span>(<span class="hljs-params">Animal</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, breed</span>):</span>
        Animal.__init__(self, name)
        self.breed = breed

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
        Animal.show_details(self)
        print(<span class="hljs-string">"Species: Dog"</span>)
        print(<span class="hljs-string">"Breed:"</span>, self.breed)

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Cat</span>(<span class="hljs-params">Animal</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, color</span>):</span>
        Animal.__init__(self, name)
        self.color = color

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show_details</span>(<span class="hljs-params">self</span>):</span>
        Animal.show_details(self)
        print(<span class="hljs-string">"Species: Cat"</span>)
        print(<span class="hljs-string">"Color:"</span>, self.color)
</code></pre>
<p>In the above code, the <code>Animal</code> class acts as the base class for two subclasses, <code>Dog</code> and <code>Cat</code>. The <code>Dog</code> class and the <code>Cat</code> class inherits the attributes and methods of the <code>Animal</code> class. However, they can also add their own unique attributes and methods.</p>
<p>Here's an example of creating objects of the <code>Dog</code> and <code>Cat</code> classes and accessing their attributes and methods:</p>
<pre><code class="lang-python">dog = Dog(<span class="hljs-string">"Max"</span>, <span class="hljs-string">"Golden Retriever"</span>)
dog.show_details()
cat = Cat(<span class="hljs-string">"Luna"</span>, <span class="hljs-string">"Black"</span>)
cat.show_details()
</code></pre>
<h2 id="heading-output-2">Output</h2>
<pre><code class="lang-python">Name: Max
Species: Dog
Breed: Golden Retriever
Name: Luna
Species: Cat
Color: Black
</code></pre>
<p>As we can see from the outputs, the <code>Dog</code> and <code>Cat</code> classes have inherited the attributes and methods of the <code>Animal</code> class, and have also added their own unique attributes and methods.</p>
<p>In conclusion, hierarchical inheritance is a way of establishing relationships between classes in a hierarchical manner. It allows multiple subclasses to inherit from a single base class, which helps in code reuse and organization of code in a more structured manner.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Inheritance is a fundamental concept in object-oriented programming that allows you to create new classes based on existing classes. Python offers a variety of inheritance types, including single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, and hybrid inheritance. Each type of inheritance has its own syntax and use cases. Understanding inheritance is crucial for building complex and scalable programs in Python. By leveraging inheritance, you can reuse code, extend it to fit your needs, and make it easier to manage complex systems. Overall, inheritance is a powerful tool that can help you write more efficient and maintainable code in Python.</p>
<p><strong><em>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</em></strong></p>
<p><img src="https://static.vecteezy.com/system/resources/previews/017/125/080/large_2x/thank-you-design-lettering-free-vector.jpg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Magic Methods in Python]]></title><description><![CDATA[A brief description about the most commonly used Magic/Dunder methods in Python]]></description><link>https://swapnoneel.hashnode.dev/magic-methods-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/magic-methods-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Wed, 22 Feb 2023 14:42:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677076902448/3fd717fb-6d90-43d6-a779-4f9c54fa501a.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Magic Methods are special methods that you can define in your classes, and when invoked, they give you a powerful way to manipulate objects and their behavior.</p>
<p>Magic methods, also known as “dunders” from the double underscores surrounding their names, are powerful tools that allow you to customize the behavior of your classes. They are used to implement special methods such as addition, subtraction and comparison operators, as well as some more advanced techniques like descriptors and properties.</p>
<p>Let’s take a look at some of the most commonly used magic methods in Python.</p>
<h1 id="heading-init-method"><code>__init__</code> method</h1>
<p>The <code>__init__</code> method is a special method that is automatically invoked when you create a new instance of a class. This method is responsible for setting up the object’s initial state, and it is where you would typically define any instance variables that you need. It is also called "constructor", which we have discussed earlier.</p>
<h1 id="heading-str-and-repr-methods"><code>__str__ and __repr__</code> methods</h1>
<p>The <code>__str__</code> and <code>__repr__</code> methods are both used to convert an object to a string representation. The <strong>str</strong> method is used when you want to print out an object, while the <strong>repr</strong> method is used when you want to get a string representation of an object that can be used to recreate the object.</p>
<h1 id="heading-len-method"><code>__len__</code> method</h1>
<p>The <code>__len__</code> method is used to get the length of an object. This is useful when you want to be able to find the size of a data structure, such as a list or dictionary.</p>
<h1 id="heading-call-method"><code>__call__</code> method</h1>
<p>The <code>__call__</code> method is used to make an object callable, meaning that you can pass it as a parameter to a function and it will be executed when the function is called. This is an incredibly powerful tool that allows you to create objects that behave like functions.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>These are just a few of the many magic methods available in Python. They are incredibly powerful tools that allow you to customize the behavior of your objects and can make your code much cleaner and easier to understand. So if you’re looking for a way to take your Python code to the next level, take some time to learn about these magic methods.</p>
<p>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://img.freepik.com/free-vector/painted-thank-you-label-template_23-2148689616.jpg?w=1380&amp;t=st=1677075508~exp=1677076108~hmac=168e84f6c0a2f5c63b505e2ac25f9d6200ecf461d2fea92d9e8526809c011186" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Overriding & Overloading in Python]]></title><description><![CDATA[A complete discussion about Method Overriding and Operator Overloading in Python]]></description><link>https://swapnoneel.hashnode.dev/overriding-overloading-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/overriding-overloading-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Tue, 21 Feb 2023 11:34:18 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676971778786/6f972368-3318-4d70-bfd9-8337b0f97307.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-method-overriding">Method Overriding</h1>
<p>Method overriding is a powerful feature in object-oriented programming that allows you to redefine a method in a derived class. The method in the derived class is said to override the method in the base class. When you create an instance of the derived class and call the overridden method, the version of the method in the derived class is executed, rather than the version in the base class.</p>
<h2 id="heading-how-can-we-do-method-overriding">How can we do Method Overriding?</h2>
<p>In Python, method overriding is a way to customize the behavior of a class based on its specific needs. For example, consider the following base class:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Shape</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">area</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">pass</span>
</code></pre>
<p>In this base class, the area method is defined but does not have any implementation. If you want to create a derived class that represents a circle, you can override the area method and provide an implementation that calculates the area of a circle:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Circle</span>(<span class="hljs-params">Shape</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, radius</span>):</span>
        self.radius = radius

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">area</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">return</span> <span class="hljs-number">3.14</span> * self.radius * self.radius
</code></pre>
<p>In this example, the Circle class inherits from the Shape class and overrides the area method. The new implementation of the area method calculates the area of a circle, based on its radius.</p>
<p>It's important to note that when you override a method, the new implementation must have the same method signature as the original method. This means that the number and type of arguments, as well as the return type, must be the same.</p>
<p>Another way to customize the behavior of a class is to call the base class method from the derived class method. To do this, you can use the super function. The super function allows you to call the base class method from the derived class method and can be useful when you want to extend the behavior of the base class method, rather than replace it.</p>
<p>For example, consider the following base class:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Shape</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">area</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Calculating area..."</span>)
</code></pre>
<p>In this base class, the area method prints a message indicating that the area is being calculated. If you want to create a derived class that represents a circle, and you also want to print a message indicating the type of shape, you can use the super function to call the base class method, and add your own message:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Circle</span>(<span class="hljs-params">Shape</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, radius</span>):</span>
        self.radius = radius

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">area</span>(<span class="hljs-params">self</span>):</span>
        print(<span class="hljs-string">"Calculating area of a circle..."</span>)
        super().area()
        <span class="hljs-keyword">return</span> <span class="hljs-number">3.14</span> * self.radius * self.radius
</code></pre>
<p>In this example, the Circle class overrides the area method and calls the base class method using the super function. This allows you to extend the behavior of the base class method, while still maintaining its original behavior.</p>
<p>In conclusion, method overriding is a powerful feature in Python that allows you to customize the behavior of a class based on its specific needs. By using method overriding, you can create more robust and reliable code, and ensure that your classes behave in the way that you need them to. Additionally, by using the super function, you can extend the behavior of a base class method, rather than replace it, giving you even greater flexibility and control over the behavior of your classes.</p>
<h1 id="heading-operator-overloading">Operator Overloading</h1>
<p>Operator Overloading is a feature in Python that allows developers to redefine the behavior of mathematical and comparison operators for custom data types. This means that you can use the standard mathematical operators (+, -, *, /, etc.) and comparison operators (&gt;, &lt;, ==, etc.) in your own classes, just as you would for built-in data types like <code>int</code>, <code>float</code>, and <code>str</code>.</p>
<h2 id="heading-why-do-we-need-operator-overloading">Why do we need operator overloading?</h2>
<p>Operator overloading allows you to create more readable and intuitive code. For instance, consider a custom class that represents a point in 2D space. You could define a method called 'add' to add two points together, but using the + operator makes the code more concise and readable:</p>
<pre><code class="lang-python">p1 = Point(<span class="hljs-number">1</span>, <span class="hljs-number">2</span>)
p2 = Point(<span class="hljs-number">3</span>, <span class="hljs-number">4</span>)
p3 = p1 + p2
print(p3.x, p3.y) <span class="hljs-comment"># prints 4, 6</span>
</code></pre>
<h2 id="heading-how-to-overload-an-operator-in-python">How to overload an operator in Python?</h2>
<p>You can overload an operator in Python by defining special methods in your class. These methods are identified by their names, which start and end with double underscores <code>__</code>. Here are some of the most commonly overloaded operators and their corresponding special methods:</p>
<pre><code class="lang-python">+ : __add__
- : __sub__
* : __mul__
/ : __truediv__
&lt; : __lt__
&gt; : __gt__
== : __eq__
</code></pre>
<p>For example, if you want to overload the + operator to add two instances of a custom class, you would define the <strong>add</strong> method:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Point</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, x, y</span>):</span>
        self.x = x
        self.y = y

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__add__</span>(<span class="hljs-params">self, other</span>):</span>
        <span class="hljs-keyword">return</span> Point(self.x + other.x, self.y + other.y)
</code></pre>
<p>It's important to note that operator overloading is not limited to the built-in operators, you can overload any user-defined operator as well.</p>
<p>In conclusion, Operator overloading is a powerful feature in Python that allows you to create more readable and intuitive code. By redefining the behavior of mathematical and comparison operators for custom data types, you can write code that is both concise and expressive. However, it's important to use operator overloading wisely, as overloading the wrong operator or using it inappropriately can lead to confusing or unexpected behavior.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://www.incimages.com/uploaded_files/image/1920x1080/getty_469566889_105923.jpg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Class Methods in Python]]></title><description><![CDATA[A detailed discussion about Class Methods in Python and how it can also be used as an Alternative Constructors]]></description><link>https://swapnoneel.hashnode.dev/class-methods-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/class-methods-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Mon, 20 Feb 2023 11:59:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676894320151/386ae518-ea75-4560-b2b6-539f24236741.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In Python, classes are a way to define custom data types that can store data and define functions that can manipulate that data. One type of function that can be defined within a class is called a "method." In this blog post, we will explore what Python class methods are, why they are useful, and how to use them.</p>
<h1 id="heading-what-are-python-class-methods">What are Python Class Methods?</h1>
<p>A class method is a type of method that is bound to the class and not the instance of the class. In other words, it operates on the class as a whole, rather than on a specific instance of the class. Class methods are defined using the <code>@classmethod</code> decorator, followed by a function definition. The first argument of the function is always <code>cls</code>, which represents the class itself.</p>
<h1 id="heading-why-use-python-class-methods">Why Use Python Class Methods?</h1>
<p>Class methods are useful in several situations. For example, you might want to create a factory method that creates instances of your class in a specific way. You could define a class method that creates the instance and returns it to the caller. Another common use case is to provide alternative constructors for your class. This can be useful if you want to create instances of your class in multiple ways, but still have a consistent interface for doing so.</p>
<h2 id="heading-how-to-use-python-class-methods">How to Use Python Class Methods?</h2>
<p>To define a class method, you simply use the <code>@classmethod</code> decorator before the method definition. The first argument of the method should always be <code>cls</code>, which represents the class itself. Here is an example of how to define a class method:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ExampleClass</span>:</span>
<span class="hljs-meta">    @classmethod</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">factory_method</span>(<span class="hljs-params">cls, argument1, argument2</span>):</span>
        <span class="hljs-keyword">return</span> cls(argument1, argument2)
</code></pre>
<p>In this example, the <code>factory_method</code> is a class method that takes two arguments, <code>argument1</code> and <code>argument2</code>. It creates a new instance of the class <code>ExampleClass</code> using the <code>cls</code> keyword, and returns the new instance to the caller.</p>
<p>It's important to note that class methods cannot modify the class in any way. If you need to modify the class, you should use a class-level variable instead.</p>
<h1 id="heading-class-methods-as-alternative-constructors">Class Methods as Alternative Constructors</h1>
<p>In object-oriented programming, the term "constructor" refers to a special type of method that is automatically executed when an object is created from a class. The purpose of a constructor is to initialize the object's attributes, allowing the object to be fully functional and ready to use.</p>
<p>However, there are times when you may want to create an object in a different way, or with different initial values than what is provided by the default constructor. This is where class methods can be used as alternative constructors.</p>
<p>A class method belongs to the class rather than to an instance of the class. One common use case for class methods as alternative constructors is when you want to create an object from data that is stored in a different format, such as a string or a dictionary. For example, consider a class named <code>Person</code> that has two attributes: <code>name</code> and <code>age</code>. The default constructor for the class might look like this:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, age</span>):</span>
        self.name = name
        self.age = age
</code></pre>
<p>But what if you want to create a Person object from a string that contains the person's name and age, separated by a comma? You can define a class method named <code>from_string</code> to do this:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Person</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name, age</span>):</span>
        self.name = name
        self.age = age

<span class="hljs-meta">    @classmethod</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">from_string</span>(<span class="hljs-params">cls, string</span>):</span>
        name, age = string.split(<span class="hljs-string">','</span>)
        <span class="hljs-keyword">return</span> cls(name, int(age))
</code></pre>
<p>Now you can create a Person object from a string like this:</p>
<pre><code class="lang-python">person = Person.from_string(<span class="hljs-string">"John Doe, 30"</span>)
</code></pre>
<p>Another common use case for class methods as alternative constructors is when you want to create an object with a different set of default values than what is provided by the default constructor. For example, consider a class named <code>Rectangle</code> that has two attributes: <code>width</code> and <code>height</code>. The default constructor for the class might look like this:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Rectangle</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, width, height</span>):</span>
        self.width = width
        self.height = height
</code></pre>
<p>But what if you want to create a Rectangle object with a default width of 10 and a default height of 5? You can define a class method named <code>square</code> to do this:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Rectangle</span>:</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, width, height</span>):</span>
    self.width = width
    self.height = height

<span class="hljs-meta">  @classmethod</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">square</span>(<span class="hljs-params">cls, size</span>):</span>
    <span class="hljs-keyword">return</span> cls(size, size)
</code></pre>
<p>Now you can create a square and rectangle like this:</p>
<pre><code class="lang-python">rectangle = Rectangle.square(<span class="hljs-number">10</span>)
</code></pre>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Python class methods are a powerful tool for defining functions that operate on the class as a whole, rather than on a specific instance of the class. They are useful for creating factory methods, alternative constructors, and other types of methods that operate at the class level. With the knowledge of how to define and use class methods, you can start writing more complex and organized code in Python.</p>
<p>Thanks for reading the blog, and I hope you have learned something new today. And until the next one, keep learning and keep exploring.</p>
<p><img src="https://img.freepik.com/free-vector/painted-thank-you-label-template_23-2148689616.jpg?w=1380&amp;t=st=1676893691~exp=1676894291~hmac=9f0960bb4730c2bbfdc9558840a6a8ed356377041f759a66392bdfff8f0612f2" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Class Variables vs Instance Variables]]></title><description><![CDATA[Understanding the difference between these types of variables is crucial for writing efficient and maintainable code.]]></description><link>https://swapnoneel.hashnode.dev/class-variables-vs-instance-variables</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/class-variables-vs-instance-variables</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Sun, 19 Feb 2023 11:38:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676806629235/603848c6-5953-41a6-8b09-83d47af93a38.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>In Python, variables can be defined at the class level or at the instance level. Understanding the difference between these types of variables is crucial for writing efficient and maintainable code. So, let's just dive into it !!</p>
<h1 id="heading-class-variables">Class Variables</h1>
<p>Class variables are defined at the class level and are shared among all instances of the class. They are defined outside of any method and are usually used to store information that is common to all instances of the class. For example, a class variable can be used to store the number of instances of a class that have been created.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClass</span>:</span>
    class_variable = <span class="hljs-number">0</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self</span>):</span>
        MyClass.class_variable += <span class="hljs-number">1</span>

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_class_variable</span>(<span class="hljs-params">self</span>):</span>
        print(MyClass.class_variable)


obj1 = MyClass()
obj2 = MyClass()

obj1.print_class_variable() <span class="hljs-comment"># Output: 2</span>
obj2.print_class_variable() <span class="hljs-comment"># Output: 2</span>
</code></pre>
<p>In the example above, the <code>class_variable</code> is shared among all instances of the class <code>MyClass</code>. When we create new instances of <code>MyClass</code>, the value of <code>class_variable</code> is incremented. When we call the <code>print_class_variable</code> method on <code>obj1</code> and <code>obj2</code>, we get the same value of <code>class_variable</code>.</p>
<h1 id="heading-instance-variables">Instance Variables</h1>
<p>Instance variables are defined at the instance level and are unique to each instance of the class. They are defined inside the <strong>init</strong> method and are usually used to store information that is specific to each instance of the class. For example, an instance variable can be used to store the name of an employee in a class that represents an employee.</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClass</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, name</span>):</span>
        self.name = name

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">print_name</span>(<span class="hljs-params">self</span>):</span>
        print(self.name)

obj1 = MyClass(<span class="hljs-string">"John"</span>)
obj2 = MyClass(<span class="hljs-string">"Jane"</span>)

obj1.print_name() <span class="hljs-comment"># Output: John</span>
obj2.print_name() <span class="hljs-comment"># Output: Jane</span>
</code></pre>
<p>In the example above, each instance of the class <code>MyClass</code> has its own value for the name variable. When we call the <code>print_name</code> method on <code>obj1</code> and <code>obj2</code>, we get different values for the name.</p>
<h1 id="heading-summary">Summary</h1>
<p>In summary, class variables are shared among all instances of a class and are used to store information that is common to all instances. Instance variables are unique to each instance of a class and are used to store information that is specific to each instance. Understanding the difference between class variables and instance variables is crucial for writing efficient and maintainable code in Python.</p>
<p>It's also worth noting that, in python, class variables are defined outside of any methods and don't need to be explicitly declared as class variables. They are defined at the class level and can be accessed via <code>class_name.varibale_name</code> or <code>self.class.variable_name</code>. But instance variables are defined inside the methods and need to be explicitly declared as instance variables by using <code>self.variable_name</code>.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Well, that's a wrap for now!! Hope you folks have enriched yourself today with lots of known or unknown concepts. I wish you a great day ahead and till then keep learning and keep exploring!!</p>
<p><img src="https://images.unsplash.com/photo-1487712010531-65e9aa8b4b1a?ixlib=rb-4.0.3&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=1074&amp;q=80" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Getters and Setters in Python]]></title><description><![CDATA[Understanding the Importance and Implementation of Getters and Setters in Python: Simplifying Data Access and Control]]></description><link>https://swapnoneel.hashnode.dev/getters-and-setters-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/getters-and-setters-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Sat, 18 Feb 2023 13:32:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676665665165/8033c554-7504-47ed-b876-0f5648b29a53.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Python is a versatile programming language that allows developers to create powerful applications with minimal code. When it comes to data management in Python, using getters and setters is a popular approach. Getters and setters are functions that enable controlled access to an object's attributes, ensuring that data is validated and processed before being accessed or modified.</p>
<p>In this blog, we'll explore the significance of getters and setters in Python and how they can help you better manage data in your applications. We'll take a look at the syntax and implementation of these functions, as well as some best practices to keep in mind when using them. By the end of this blog, you'll have a clear understanding of how getters and setters can simplify your code and improve your application's performance.</p>
<h1 id="heading-getters">Getters</h1>
<p>Getters in Python are methods that are used to access the values of an object's properties. They are used to return the value of a specific property and are typically defined using the <code>@property</code> decorator. Here is an example of a simple class with a getter method:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClass</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, value</span>):</span>
        self._value = value

<span class="hljs-meta">    @property</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">value</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">return</span> self._value
</code></pre>
<p>In this example, the MyClass class has a single property, <code>value</code>, which is initialized in the <code>__init__</code> method. The value method is defined as a <strong>getter</strong> using the <code>@property</code> decorator and is used to return the value of the value property.</p>
<p>To use the getter, we can create an instance of the MyClass class, and then access the value property as if it were an attribute:</p>
<pre><code class="lang-python"><span class="hljs-meta">&gt;&gt;&gt; </span>obj = MyClass(<span class="hljs-number">10</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>obj.value
<span class="hljs-number">10</span>
</code></pre>
<h1 id="heading-setters">Setters</h1>
<p>It is important to note that the getters do not take any parameters and we cannot set the value through the getter method. For that, we need a setter method which can be added by decorating the method with <code>@property_name.setter</code></p>
<p>Here is an example of a class with both a getter and a setter:</p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClass</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, value</span>):</span>
        self._value = value

<span class="hljs-meta">    @property</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">value</span>(<span class="hljs-params">self</span>):</span>
        <span class="hljs-keyword">return</span> self._value

<span class="hljs-meta">    @value.setter</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">value</span>(<span class="hljs-params">self, new_value</span>):</span>
        self._value = new_value
</code></pre>
<p>We can use the method like this:</p>
<pre><code class="lang-python"><span class="hljs-meta">&gt;&gt;&gt; </span>obj = MyClass(<span class="hljs-number">10</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>obj.value = <span class="hljs-number">20</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>obj.value
<span class="hljs-number">20</span>
</code></pre>
<p>Getters are a convenient way to access the values of an object's properties while keeping the internal representation of the property hidden. This can be useful for encapsulation and data validation.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>In conclusion, getters and setters are an essential part of Python programming that can help you maintain data integrity, prevent bugs, and improve your code's readability. By using these functions, you can ensure that your application's data is accessed and modified only as intended, making it more secure and reliable.</p>
<p>While the concept of getters and setters may seem complicated at first, they are relatively easy to implement in Python, and once you've mastered them, you'll wonder how you ever managed without them. Whether you're working on a small project or a large-scale application, getters and setters can simplify your code and make it easier to maintain.</p>
<p>So, if you want to take your Python programming skills to the next level, take the time to learn about getters and setters and how they can help you manage your data more effectively. With the right knowledge and tools, you'll be able to create robust and reliable applications that meet your users' needs and exceed their expectations.</p>
<p><img src="https://etiquettejulie.com/wp-content/uploads/2017/01/thank-you-from-christian-vision-alliance.jpg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Constructors and Decorators in Python]]></title><description><![CDATA[Exploring the Fundamentals of Object Initialization and Code Modification in Python with Constructors and Decorators]]></description><link>https://swapnoneel.hashnode.dev/constructors-and-decorators-in-python</link><guid isPermaLink="true">https://swapnoneel.hashnode.dev/constructors-and-decorators-in-python</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Swapnoneel Saha]]></dc:creator><pubDate>Fri, 17 Feb 2023 15:16:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1676646734444/c65718b0-af2c-4992-ac77-ba015fdf9c20.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Python is a versatile programming language that provides a wide range of features and tools to developers for building robust and efficient software applications. Among the most important aspects of Python are constructors and decorators, which allow programmers to create and modify objects and functions in powerful ways.</p>
<p>In this blog post, we'll dive into the world of Python constructors and decorators, exploring their fundamental concepts, syntax, and use cases. We'll cover how constructors work in Python classes to initialize object properties and states, and how decorators can modify functions and methods to add functionality, behavior, or metadata. Understanding constructors and decorators are crucial to writing clean, maintainable, and extensible code. So let's get started and learn how to leverage these powerful tools in your Python development journey.</p>
<h1 id="heading-constructors">Constructors</h1>
<p>A constructor is a special method in a class used to create and initialize an object of a class. There are different types of constructors. Constructor is invoked automatically when an object of a class is created.</p>
<p>A constructor is a unique function that gets called automatically when an object is created of a class. The main purpose of a constructor is to initialize or assign values to the data members of that class. It cannot return any value other than None.</p>
<h2 id="heading-syntax-of-python-constructor">Syntax of Python Constructor</h2>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self</span>):</span>
    <span class="hljs-comment"># initializations</span>
</code></pre>
<p><code>__init__</code> is one of the reserved functions(<mark>dunder methods*</mark>) in Python. In Object Oriented Programming, it is known as a constructor.</p>
<p><em>\</em>We will be covering Dunder Methods in Python in complete detail in the upcoming blogs, so make sure to follow me on Hashnode to get notified.*</p>
<h2 id="heading-types-of-constructors">Types of Constructors</h2>
<p>In Python, there are two types of Constructors; namely,</p>
<ol>
<li><p>Parameterizedd Constructor</p>
</li>
<li><p>Default Constructor</p>
</li>
</ol>
<h3 id="heading-parameterized-constructor">Parameterized Constructor</h3>
<p>When the constructor accepts arguments along with self, it is known as parameterized constructor.</p>
<p>These arguments can be used inside the class to assign the values to the data members.</p>
<p><strong><mark>Example:</mark></strong></p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Details</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self, animal, group</span>):</span>
        self.animal = animal
        self.group = group

obj1 = Details(<span class="hljs-string">"Crab"</span>, <span class="hljs-string">"Crustaceans"</span>)
print(obj1.animal, <span class="hljs-string">"belongs to the"</span>, obj1.group, <span class="hljs-string">"group."</span>)
</code></pre>
<p><strong><mark>Output:</mark></strong></p>
<pre><code class="lang-python">Crab belongs to the Crustaceans group.
</code></pre>
<h3 id="heading-default-constructor">Default Constructor</h3>
<p>When the constructor doesn't accept any arguments from the object and has only one argument, self, in the constructor, it is known as a Default constructor.</p>
<p><strong><mark>Example:</mark></strong></p>
<pre><code class="lang-python"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Details</span>:</span>
  <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span>(<span class="hljs-params">self</span>):</span>
    print(<span class="hljs-string">"animal Crab belongs to Crustaceans group"</span>)
obj1=Details()
</code></pre>
<p><strong><mark>Output:</mark></strong></p>
<pre><code class="lang-python">animal Crab belongs to Crustaceans group
</code></pre>
<h1 id="heading-decorators">Decorators</h1>
<p>Python decorators are a powerful and versatile tool that allows you to modify the behavior of functions and methods. They are a way to extend the functionality of a function or method without modifying its source code.</p>
<p>A decorator is a function that takes another function as an argument and returns a new function that modifies the behavior of the original function. The new function is often referred to as a "decorated" function. The basic syntax for using a decorator is the following:</p>
<pre><code class="lang-python"><span class="hljs-meta">@decorator_function</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">my_function</span>():</span>
    <span class="hljs-keyword">pass</span>
</code></pre>
<p>The <code>@decorator_function</code> notation is just a shorthand for the following code:</p>
<pre><code class="lang-python"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">my_function</span>():</span>
    <span class="hljs-keyword">pass</span>
my_function = decorator_function(my_function)
</code></pre>
<p>Decorators are often used to add functionality to functions and methods, such as logging, memoization, and access control.</p>
<h2 id="heading-use-case-scenario">Use-Case Scenario</h2>
<p>One common use of decorators is to add logging to a function. For example, you could use a decorator to log the arguments and return value of a function each time it is called:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> logging

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">log_function_call</span>(<span class="hljs-params">func</span>):</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">decorated</span>(<span class="hljs-params">*args, **kwargs</span>):</span>
        logging.info(<span class="hljs-string">f"Calling <span class="hljs-subst">{func.__name__}</span> with args=<span class="hljs-subst">{args}</span>, kwargs=<span class="hljs-subst">{kwargs}</span>"</span>)
        result = func(*args, **kwargs)
        logging.info(<span class="hljs-string">f"<span class="hljs-subst">{func.__name__}</span> returned <span class="hljs-subst">{result}</span>"</span>)
        <span class="hljs-keyword">return</span> result
    <span class="hljs-keyword">return</span> decorated

<span class="hljs-meta">@log_function_call</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">my_function</span>(<span class="hljs-params">a, b</span>):</span>
    <span class="hljs-keyword">return</span> a + b
</code></pre>
<p>In this example, the <code>log_function_call</code> decorator takes a function as an argument and returns a new function that logs the function call before and after the original function is called.</p>
<p>Decorators are a powerful and flexible feature in Python that can be used to add functionality to functions and methods without modifying their source code. They are a great tool for separating concerns, reducing code duplication, and making your code more readable and maintainable. Python decorators are a way to extend the functionality of functions and methods, by modifying their behavior without modifying the source code. They are used for a variety of purposes, such as logging, memoization, access control, and more. It is a powerful tool that can be used to make your code more readable, maintainable, and extendable.</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>In this blog post, we've explored the key concepts and applications of constructors and decorators in Python. We've seen how constructors provide a way to initialize object properties and states, and how decorators can flexibly modify functions and methods.</p>
<p>By using constructors and decorators effectively in your Python projects, you can write more efficient, maintainable, and scalable code. Whether you're working on web development, data science, or any other field that uses Python, understanding constructors and decorators is a crucial part of your skill set.</p>
<p>So, as you continue your Python development journey, remember to experiment with constructors and decorators to take your code to the next level. With practice and experience, you'll be able to leverage these tools to build more complex, sophisticated, and impactful software applications.</p>
<p>Thank you for reading, and happy coding!</p>
<p><img src="https://cdn.pizap.com/pizapfiles/images/thank_you_card_maker_app01.jpg" alt class="image--center mx-auto" /></p>
]]></content:encoded></item></channel></rss>