<?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[Damian Demasi's Blog]]></title><description><![CDATA[Web Developer - I switched careers in my 40s - Writer of web development blog posts - I love to share Notion templates

# [Buy me a coffee!](https://www.buymeac]]></description><link>https://blog.damiandemasi.com</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 20:48:55 GMT</lastBuildDate><atom:link href="https://blog.damiandemasi.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Claude Code Crash Course]]></title><description><![CDATA[The first time you look at Claude Code closely, it can feel like a box full of parts that all seem important, but not obviously related.
You see CLAUDE.md. Then rules. Then skills. Then hooks. Then su]]></description><link>https://blog.damiandemasi.com/claude-code-crash-course</link><guid isPermaLink="true">https://blog.damiandemasi.com/claude-code-crash-course</guid><category><![CDATA[claude-code]]></category><category><![CDATA[ClaudeCode]]></category><category><![CDATA[claude.ai]]></category><category><![CDATA[AI]]></category><category><![CDATA[ai agents]]></category><category><![CDATA[#ai-tools]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Sun, 29 Mar 2026 06:13:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/f5271d17-dd1b-4ad5-9b69-9278e04cafa9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The first time you look at Claude Code closely, it can feel like a box full of parts that all seem important, but not obviously related.</p>
<p>You see <code>CLAUDE.md</code>. Then rules. Then skills. Then hooks. Then subagents. Then MCP servers. Then… the list goes on. Then context management, planning before coding, verifying outputs, and avoiding letting the session turn into a mess. At first glance, it is easy to think: <em>why are there so many pieces just to get an AI coding workflow working well?</em></p>
<p>But after spending some time with these concepts, I think the answer is actually pretty simple.</p>
<p>Claude Code is not one thing. It is a small operating system for AI-assisted development.</p>
<p>And like any good system, different parts exist for different jobs.</p>
<h2><strong>Start here. Claude Code needs memory, structure, and reach</strong></h2>
<p>A good mental model is this:</p>
<ol>
<li><p><code>CLAUDE.md</code> and rules shape behavior.</p>
</li>
<li><p>Skills package reusable know how.</p>
</li>
<li><p>Hooks enforce automatic actions.</p>
</li>
<li><p>Subagents isolate work.</p>
</li>
<li><p>MCP servers connect Claude to the outside world.</p>
</li>
</ol>
<p>That is the big picture (mainly, because there is more to it, but this is enough to get us started).</p>
<img src="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/0a954c65-cb66-44e4-b480-f079c2caadd6.jpg" alt="Photo by Alain Pham on Unsplash" style="display:block;margin:0 auto" />

<p>Once you see it that way, the moving parts stop feeling random. They start feeling like layers. The interesting part is not learning each feature in isolation, but understanding <strong>what problem each one solves, and what happens when you try to use the wrong one for that problem</strong>. <a href="https://code.claude.com/docs/en/overview">Anthropic’s docs</a> make that distinction pretty clear. <code>CLAUDE.md</code> gives persistent instructions, rules can scope those instructions more precisely, skills extend Claude with reusable playbooks, hooks provide deterministic automation, subagents work in separate contexts with their own tools and prompts, and MCP is the bridge to external tools, data sources, and APIs.</p>
<h2><code>CLAUDE.md</code> <strong>and rules. The behavioural layer</strong></h2>
<p>If I had to pick the first thing to set up in Claude Code, it would be this.</p>
<p><code>CLAUDE.md</code> is where you put persistent instructions that Claude should carry into every session for a project, for your personal workflow, or even across an organisation. <a href="https://code.claude.com/docs/en/memory#claude-md-files">The docs</a> describe it as plain markdown that Claude reads at the start of every session. They also make an important point that is easy to miss: these instructions are context, not hard enforcement. So if the file is vague, bloated, or contradictory, performance drops. Anthropic recommends keeping it specific, concise, and well-structured, with a rough target of under <code>200</code> lines per file.</p>
<p>That last bit matters more than it seems.</p>
<p>A lot of people treat instruction files like a dumping ground. They keep adding preferences, workflows, architecture notes, testing conventions, edge cases, and random reminders until the thing becomes unreadable. Then they wonder why the agent follows it inconsistently. The problem is not that the model is “bad at instructions.” The problem is that the instruction layer is carrying too much weight.</p>
<p>That is where <strong>rules</strong> come in.</p>
<p>For larger projects, Anthropic recommends organising instructions inside <code>.claude/rules/</code>, and those rules can even be path-specific so they only load when Claude is working in matching areas of the codebase. That means you do not need every frontend rule, testing rule, security note, and data migration convention loaded all the time. You can scope them. In other words, <code>CLAUDE.md</code> should define the broad operating principles of the project, while <strong>rules</strong> help keep that guidance modular and targeted.</p>
<p>So, if you want one simple distinction:</p>
<blockquote>
<p><strong>Use</strong> <code>CLAUDE.md</code> <strong>for shared default behavior. Use rules when the project is getting too big for one instruction file to stay sharp.</strong></p>
</blockquote>
<h2><strong>Skills. The reusable playbook layer</strong></h2>
<p>This is where Claude Code starts getting interesting.</p>
<p>A skill is not just “more instructions.” A skill is a packaged capability. <a href="https://code.claude.com/docs/en/skills#extend-claude-with-skills">Anthropic defines skills</a> around a <code>SKILL.md</code> file. Claude can load a skill automatically when it is relevant, or you can invoke it directly with a slash command (<code>/</code>) based on the skill name (<code>/my_skill</code>). Skills can also include frontmatter, supporting files, argument handling, restricted tool access, and even subagent execution.</p>
<p>That changes the way you should think about them.</p>
<p>A rule says, “here is how we do things around here.”</p>
<p>A skill says, “when this kind of task appears, here is the exact playbook to follow.”</p>
<p>That is a huge difference.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/c9f358f4-192e-44d5-9d3e-48b6a7aa0b90.jpg" alt="" style="display:block;margin:0 auto" />

<p>For example, suppose your team has a repeatable workflow for debugging flaky tests, preparing release notes, reviewing API design, or migrating components from one pattern to another. You <em>could</em> try to cram that into <code>CLAUDE.md</code>, but then every session pays the context cost whether that workflow is relevant or not. Skills solve that by staying optional and task-focused. Anthropic explicitly positions them that way <a href="https://code.claude.com/docs/en/skills#extend-claude-with-skills">in the docs</a> and even notes that for task-specific instructions that do not need to live in context all the time, skills are the better fit.</p>
<p>This is one of those places where the abstraction really clicks.</p>
<p>A good Claude Code setup is not just about telling the model how your codebase works, but about identifying <strong>which workflows deserve to become first-class tools</strong>.</p>
<p>That is what skills are.</p>
<h2><strong>Hooks. The enforcement layer</strong></h2>
<p>If <code>CLAUDE.md</code> and skills are about guidance, <strong>hooks</strong> are about guarantees.</p>
<p>Anthropic <a href="https://code.claude.com/docs/en/hooks-guide#automate-workflows-with-hooks">describes hooks</a> as user-defined shell commands that run at specific points in Claude Code’s lifecycle. Their wording is important here: hooks provide <strong>deterministic control</strong>. In other words, they are for the things that <strong>must happen, every time, without relying on the model to remember or choose correctly</strong>. The best practices guide reinforces the same distinction: unlike <code>CLAUDE.md</code>, which is advisory, hooks are deterministic and guarantee the action happens.</p>
<p>That makes hooks the right tool for a very specific category of problems:</p>
<ul>
<li><p>Run formatting after edits.</p>
</li>
<li><p>Block writes to protected files.</p>
</li>
<li><p>Send a notification when Claude needs input.</p>
</li>
<li><p>Reinject context after compaction.</p>
</li>
<li><p>Audit configuration changes.</p>
</li>
</ul>
<p>Hooks are workflow mechanics. If you try to solve these mechanics with prompts alone, you are basically <strong>hoping</strong> the model behaves. Hooks exist so you do not need hope.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/64db0aba-fb71-4e25-9326-8e1c5351aba8.jpg" alt="" style="display:block;margin:0 auto" />

<p>This is also where a lot of AI workflows quietly become trustworthy. Not because the model got smarter, but because some parts of the workflow stopped depending on the model entirely.</p>
<p>That is a pattern worth paying attention to.</p>
<p><strong>The more a task sounds like “always do X when Y happens,” the more likely it belongs in a hook, not in a prompt.</strong></p>
<h2><strong>Subagents. The isolation layer</strong></h2>
<p>Subagents are one of the clearest signs that Claude Code is built for agentic work, not just chat.</p>
<p>Anthropic <a href="https://code.claude.com/docs/en/sub-agents#create-custom-subagents">describes subagents</a> as specialised AI assistants that run in their own context window, with their own system prompt, tool access, and permissions. Claude can delegate work to them when a task matches the subagent’s description, and the subagent works independently before returning the result. The docs also point out why this matters: subagents preserve context, enforce constraints, specialise behaviour, and can route work to different models.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/e3e30cf6-f8fe-4ca2-8e19-bbaf00d68f40.jpg" alt="" style="display:block;margin:0 auto" />

<p>In long coding sessions, context gets polluted fast. Research, false starts, logs, file reads, debugging dead ends, and exploratory thoughts all pile into the same conversation. Anthropic’s <a href="https://code.claude.com/docs/en/best-practices">best practices page</a> repeatedly emphasizes that context is the most important resource to manage, because performance degrades as the context window fills.</p>
<p>Subagents are how you stop every task from becoming everyone’s problem:</p>
<ul>
<li><p>Need a security pass across many files? Use a security reviewer subagent.</p>
</li>
<li><p>Need research on a subsystem before implementation? Delegate it.</p>
</li>
<li><p>Need a focused investigation that should not clutter the main thread? Subagent.</p>
</li>
</ul>
<p>I think this is one of the most underrated shifts in AI coding workflows. The question is no longer just “what should the model do?” It is also “<strong>which context should do it?</strong>”</p>
<p>That is a different level of workflow design.</p>
<h2><strong>MCP servers. The reach layer</strong></h2>
<p>Without MCP, Claude Code is mostly limited to the local environment and whatever tools it already has access to. With MCP, it can reach out.</p>
<p>Anthropic <a href="https://code.claude.com/docs/en/mcp#connect-claude-code-to-tools-via-mcp">describes MCP,</a> the Model Context Protocol, as an open standard that lets Claude Code connect to external tools and data sources through MCP servers. Their examples include issue trackers, monitoring platforms, databases, design tools, and workflow automation systems. They also note an important security warning: third-party MCP servers are not universally verified, and untrusted servers can introduce prompt injection or other risks.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/2ccda820-7f47-4dd0-a44a-7156a6014bcf.jpg" alt="" style="display:block;margin:0 auto" />

<p>This is where Claude Code stops being “an assistant in my repo” and starts becoming “an agent in my workflow.” That sounds exciting, and it is. But it also changes the stakes.</p>
<p>Once Claude can read tickets, inspect production signals, query a database, read Figma, or draft emails, the design problem becomes larger than coding. You are now designing an operational system. Permissions matter. Trust boundaries matter. Server choice matters. Tool access matters.</p>
<p>So while MCP is easily the most expansive capability in the stack, it is also the one that benefits most from restraint.</p>
<p>Just because Claude <em>can</em> connect to everything does not mean it should.</p>
<h2><strong>How these parts fit together in practice</strong></h2>
<p>Here is the cleanest way I can describe the whole stack:</p>
<ul>
<li><p><code>CLAUDE.md</code> tells Claude how to behave by default.</p>
</li>
<li><p>Rules narrow that guidance by topic or path.</p>
</li>
<li><p>Skills package repeatable expertise or workflows.</p>
</li>
<li><p>Hooks automate mandatory actions.</p>
</li>
<li><p>Subagents keep big or noisy tasks isolated.</p>
</li>
<li><p>MCP servers connect Claude to outside systems.</p>
</li>
</ul>
<p>A practical workflow might look like this:</p>
<p>Your <code>CLAUDE.md</code> defines coding standards, project conventions, and preferred commands. A rule file adds stricter guidance for the <code>/api</code> directory. A skill gives Claude your internal release checklist. A hook runs linting after edits and blocks writes to a protected migration folder. A subagent handles security review in its own context. MCP connects Claude to GitHub, Jira, Sentry, and your database.</p>
<p>At that point, Claude Code is no longer just reacting to prompts, but operating inside a designed environment. And I think that is the real lesson here.</p>
<blockquote>
<p>The quality of the workflow does not come from one magical feature. It comes from <strong>putting the right responsibility in the right layer</strong>.</p>
</blockquote>
<h2><strong>Best practices that actually matter</strong></h2>
<p>Anthropic’s <a href="https://code.claude.com/docs/en/best-practices">best practices page</a> covers a lot, but a few ideas stand out because they connect directly to all the moving parts above.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60c925b680c5541363dd2901/92f87cb0-5dc3-4614-a89c-f981c354c782.jpg" alt="" style="display:block;margin:0 auto" />

<p>First, give Claude <strong>a way to verify its work</strong>. Tests, screenshots, and expected outputs dramatically improve results because Claude can check itself instead of making you the only feedback loop.</p>
<p>Second, <strong>explore first, then plan, then code</strong>. Anthropic recommends separating research and planning from implementation, especially for tasks that touch multiple files or unfamiliar areas. That maps nicely to <a href="https://code.claude.com/docs/en/permission-modes#start-and-use-plan-mode"><strong>plan mode</strong></a>, but also to skills and subagents when you want a more structured workflow.</p>
<p>Third, provide <strong>specific context</strong>. Reference files, constraints, patterns, and symptoms. Claude can infer a lot, but it cannot read your mind (yet 😅).</p>
<p>And finally, <strong>manage context aggressively</strong>. Use <code>/clear</code> between unrelated tasks and avoid stuffing persistent instructions with everything under the sun.</p>
<blockquote>
<p>Most of Claude Code’s “moving parts” are really context management tools in disguise.</p>
</blockquote>
<h2><strong>Closing thoughts</strong></h2>
<p>When people first look at Claude Code, they often ask which feature matters most. I think that is the wrong question.</p>
<p>The better question is: <strong>what kind of problem am I trying to solve?</strong></p>
<ul>
<li><p>If the problem is persistent guidance, reach for <code>CLAUDE.md</code> and rules.</p>
</li>
<li><p>If the problem is reusable know-how, reach for skills.</p>
</li>
<li><p>If the problem is guaranteed automation, reach for hooks.</p>
</li>
<li><p>If the problem is isolation and focus, reach for subagents.</p>
</li>
<li><p>If the problem is external connectivity, reach for MCP.</p>
</li>
</ul>
<p>That is when the system starts making sense.</p>
<p>Claude Code does not become powerful because it has many parts. It becomes powerful when each part has a clear job. And honestly, that is probably the deeper pattern behind good AI workflows in general. Not more prompts. Not more cleverness. Better boundaries.</p>
<p><strong>Practical takeaway:</strong></p>
<ul>
<li><p>Start with a small, sharp <code>CLAUDE.md</code></p>
</li>
<li><p>Add rules only when the project needs more structure</p>
</li>
<li><p>Turn repeated workflows into skills</p>
</li>
<li><p>Use hooks for anything that must happen every time</p>
</li>
<li><p>Use subagents to protect context</p>
</li>
<li><p>Add MCP carefully, with trust and permissions in mind</p>
</li>
</ul>
<p>Which part of Claude Code feels most useful to you right now: rules, skills, hooks, subagents, or MCP servers, and why?</p>
<p><em>Photos by Alain Pham, Calle Macarone, Tatiana Rodriguez, Yuriy Vertikov, Toa Heftiba, Jason Leung on Unsplash</em></p>
]]></content:encoded></item><item><title><![CDATA[The Power of Microtools: How AI and "Vibe Coding" Are Changing the Way We Build]]></title><description><![CDATA[TL;DR: We’re no longer limited to using generic productivity tools. With the rise of AI-assisted coding and platforms like v0, Bolt, Cursor, and Windsurf, it’s now possible to build simple, custom tools (microtools) that fit the way you think and wor...]]></description><link>https://blog.damiandemasi.com/the-power-of-microtools-how-ai-and-vibe-coding-are-changing-the-way-we-build</link><guid isPermaLink="true">https://blog.damiandemasi.com/the-power-of-microtools-how-ai-and-vibe-coding-are-changing-the-way-we-build</guid><category><![CDATA[AI]]></category><category><![CDATA[vibe coding]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 18 Jun 2025 12:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1750247566857/1f66c498-493f-4e3d-8b7d-723761d7b872.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><strong>TL;DR:</strong> We’re no longer limited to using generic productivity tools. With the rise of AI-assisted coding and platforms like v0, Bolt, Cursor, and Windsurf, it’s now possible to build simple, custom tools (microtools) that fit the way you think and work. This shift is not just about convenience; it marks a deeper change in how we relate to software. We’re moving from using tools to making them. These tools aren’t always clean or scalable, but they let you solve your own problems without waiting for someone else to build the solution. That said, real programming knowledge still matters, especially when you're building something meant to last. AI gives us speed and leverage, but it’s skilled developers who make things work.</p>
</blockquote>
<p>Organizing your ideas, tasks, or notes often means using a general-purpose app like Notion, Evernote, or Trello. These tools are sleek and flexible, but they come with an unspoken rule: you have to adjust your workflow to match how the tool wants you to think. They are powerful, but often lack the flexibility to fully adapt to your specific needs or preferences.</p>
<p>Now, something is shifting. AI has made it easier than ever to experiment, automate, and create lightweight custom tools on your own. With AI copilots, natural language interfaces, and frictionless development environments, you can quickly build <strong>microtools</strong>, which are small, purpose-built scripts or apps tailored to your personal workflows.</p>
<p>These tools aren’t designed for scale or mass appeal. They’re meant for you. That specificity is powerful, but it also comes with limits. They might break easily, lack polish, or be hard to maintain. Still, for solving niche or personal problems, they might do the job far better than a bloated all-in-one platform.</p>
<p>Instead of changing your habits to fit someone else's design, now you can create simple tools that match the way you already think and get things done. This shift is not just about replacing the tools you already use. It's about gaining control over how those tools work for you.</p>
<h2 id="heading-what-is-vibe-coding">What is "Vibe Coding"?</h2>
<p>This new ability to quickly shape tools around your own thinking wouldn’t be possible without a shift in how we write code. That shift is best captured by the term "vibe coding.”</p>
<p>If you're not familiar with the term "vibe coding," here's a quick overview. The phrase was coined by computer scientist Andrej Karpathy, co-founder of OpenAI and former head of AI at Tesla, in early 2025. Vibe coding refers to a conversational, hands-off approach to programming that uses large language models to do the heavy lifting. Instead of writing code line by line, Karpathy explained it as: "I just see things, say things, run things, and copy-paste things, and it mostly works.”</p>
<p>Vibe coding is about getting quick, functional results from natural language prompts, with the AI generating most of the code. It's a fast, expressive, and surprisingly productive way to build, especially for throwaway weekend projects or exploratory ideas. That said, Karpathy himself noted its limitations. AI tools don’t always understand or fix bugs, and sometimes you're left experimenting until something works.</p>
<p>Vibe coding is not so much about writing perfectly structured code. It's more about moving quickly, trying things out, and learning through doing. You give up a bit of accuracy and detailed control so that you can experiment and make progress faster. For many people who build things, that trade-off feels worth it. It’s the perfect bridge between idea and execution.</p>
<h2 id="heading-why-now">Why Now?</h2>
<p>The ecosystem of AI-powered tools has exploded, making the idea-to-app pipeline smoother than ever. What once took days now happens in hours, thanks to new platforms designed with builders, not just developers, in mind.</p>
<p>Take <strong>v0 by Vercel</strong>, for example (or Bolt, Lovable, and many others). It lets you generate not just UI components or full pages, but entire full-stack apps using natural language prompts. Want a dashboard with a few charts, a login screen, and a backend to store user data? Just describe it. v0 responds with React and Tailwind CSS code, and good business logic structured around a Next.js app. Once you're done, you can deploy straight to Vercel, with all the scalability and performance it provides.</p>
<p>For those who prefer to work closer to the code, tools like <strong>Cursor</strong> and <strong>Windsurf</strong> are redefining the developer experience. Both are forks of Visual Studio Code with built-in AI enhancements. They offer features like smart code generation, contextual refactoring, and natural language queries over your codebase.</p>
<p>You don’t need to start from scratch anymore. You can describe your app, vibe-code your way to a working version, and refine it with professional-grade tools.</p>
<p>This is why now is different. The boundary between idea and implementation is dissolving, and the time it takes to go from concept to working prototype has never been shorter.</p>
<h2 id="heading-the-shift-from-platforms-to-personal-systems">The Shift: From Platforms to Personal Systems</h2>
<p>Here’s the real unlock:</p>
<blockquote>
<p>We’re moving from using tools to making them.</p>
</blockquote>
<p>Instead of changing our behavior to fit the structure of existing apps, we now have the chance to design tools that match our individual needs. This may seem like a small shift, but it represents a big change in how we use and relate to technology.</p>
<p>For example, I used to track the progress on a personal programming project using Notion. I spent time trying to configure it to reflect the exact structure I needed to track the progress effectively, but it always felt like I was bending my process to fit someone else’s system. Now, I have a custom-built app I made in about half a weekend. It tracks and measures progress exactly how I want, lives online with its own database, and best of all, it’s shareable and open source. That means anyone can use it, and if they want, they can fork it and adapt it to suit their own workflow.</p>
<p>Even better, someone who doesn’t know how to tweak the code can still build their own version. With tools like v0 or Bolt, all they need is a clear idea and a few natural language prompts. Whether they want to replicate my app or build something entirely new, the entry point has never been more accessible.</p>
<p>In short, the tools are no longer the limit. Our creativity is.</p>
<h2 id="heading-how-i-replaced-notion-with-a-custom-tool-built-using-v0"><strong>How I Replaced Notion with a Custom Tool Built Using v0</strong></h2>
<p>Let me give you a concrete example. As I mentioned before, one of the microtools I built was designed to help me track progress on a side project more intuitively. It’s a dynamic task management app that runs on Next.js that lets you create projects with distinct areas and specific work items under each one.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1750246379914/535208f4-bdf6-41e2-8c73-fa12d7a689e2.png" alt class="image--center mx-auto" /></p>
<p>Each project has a central dashboard featuring a progress bar that updates in real time as you mark items complete. This makes it easy to get a visual snapshot of how far along you are and estimate how much work still remains. You can add tasks, assign them to areas, sort them, and even import or export your data.</p>
<p>Everything is backed by Supabase, which handles both user authentication and database storage.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1750246395574/f954fb4d-0260-406b-a952-3d0dda8fc456.png" alt class="image--center mx-auto" /></p>
<p>And here’s the part that still surprises me: I built it all using <strong>v0 by Vercel</strong> over half a weekend. What would have taken days of boilerplate setup and manual UI coding came together almost effortlessly with the help of AI.</p>
<p>This tool is now part of my daily workflow. It fits how I think, helps me stay on track, and reminds me that solving a personal pain point can be both useful and satisfying.</p>
<p>The best part? It’s not trying to be a full SaaS app. It doesn’t need to be. It’s just what I needed, and that’s the beauty of microtools.</p>
<blockquote>
<p>You can try out this app, called Project Pulse, by visiting <a target="_blank" href="https://www.projectpulse.tools/">https://www.projectpulse.tools/</a> and creating an account. If you're interested in exploring or modifying the code, the full source is available at <a target="_blank" href="https://github.com/Colo-Codes/micro-app-project-progress-tracker">https://github.com/Colo-Codes/micro-app-project-progress-tracker</a>.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1750246407260/96ec7b04-aded-4ea2-86f6-aeaef82cdd73.png" alt class="image--center mx-auto" /></p>
<p>I’d love to hear your thoughts: how would you use it, and what changes or improvements would you make?</p>
<h2 id="heading-but-dont-get-it-twisted-knowledge-still-matters">But Don’t Get It Twisted: Knowledge Still Matters</h2>
<p>Vibe coding is fun. It’s powerful. And it’s a great entry point. But there’s a ceiling.</p>
<p>Sooner or later, you’ll want to tweak that AI-generated component beyond what the prompt allows. Or you’ll hit a bug the copilot can’t fix. Or maybe you’ll want to optimize performance or build complex logic that requires actual software understanding.</p>
<p>That’s when real programming knowledge makes all the difference.</p>
<p>Despite all the AI hype, <strong>manual coding is far from dead</strong>. If anything, it’s more relevant than ever.</p>
<p>Being able to read and tweak code turns you from a passive user into an active true creator. It’s what lets you move from “good enough” to “exactly right.”</p>
<p>If you combine a builder’s mindset with foundational coding skills, you become incredibly effective.</p>
<p>And if you find yourself enjoying this kind of tinkering and building, that might be a sign it’s time to dive deeper. You could build a real career doing this.</p>
<h2 id="heading-dont-ship-vibes-to-production">Don’t Ship Vibes to Production</h2>
<p>Vibe coding is excellent for small projects, weekend experiments, or solving specific personal problems. But it’s not a replacement for the structured practices required in professional software development.</p>
<p>If you're building something for yourself or validating an idea, vibe coding is a superpower. But when you’re working on production-grade software, especially if it will be used by real users, integrated into workflows, or scaled across teams, you need more than vibes. You need engineering discipline.</p>
<p>Professional projects demand:</p>
<ul>
<li><p>Scalable architecture and maintainable code</p>
</li>
<li><p>Version control, testing, and CI/CD pipelines</p>
</li>
<li><p>Code reviews, documentation, and shared conventions</p>
</li>
<li><p>Performance considerations, security, and edge case handling</p>
</li>
</ul>
<p>This is why vibe coding alone won’t cut it. You can use it to get started, but sustainable software requires real skills and best practices.</p>
<p>Companies don’t hire developers just to write AI prompts. They hire developers who understand the tools deeply and can apply them intelligently. When the software you build needs to be reliable, secure, and scalable, that depth matters.</p>
<p>AI is powerful. But experienced developers are what make it valuable.</p>
<p>So by all means, vibe-code your next side project or internal tool. But when it’s time to go pro, put on your engineering hat.</p>
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>You don’t need to ship polished products. You don’t need to think in SaaS terms. You just need to <strong>solve your own problems</strong>, in your own way.</p>
<p>That’s the heart of microtools and vibe coding.</p>
<p>And with AI now helping us bridge the gap between idea and implementation, the only real limit is your curiosity.</p>
<hr />
<p>📬 Subscribe to my <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">newsletter</a> for more insights on learning, coding, and making cool stuff.</p>
<p>💬 Or drop by <a target="_blank" href="https://twitter.com/DamianDemasi">X</a> and say hi.</p>
]]></content:encoded></item><item><title><![CDATA[TypeScript in React: Elevating Your Frontend Development Skills]]></title><description><![CDATA[What is TypeScript?
TypeScript is a statically typed superset of JavaScript, developed and maintained by Microsoft. It’s called a "superset" of JavaScript because it extends the capabilities of JavaScript by adding additional features while maintaini...]]></description><link>https://blog.damiandemasi.com/typescript-in-react-elevating-your-frontend-development-skills</link><guid isPermaLink="true">https://blog.damiandemasi.com/typescript-in-react-elevating-your-frontend-development-skills</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[React]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Sun, 25 Aug 2024 02:51:29 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1724554206699/7d2b8a9e-e429-48ec-a707-9d4d1bbe8858.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-what-is-typescript">What is TypeScript?</h1>
<p><strong>TypeScript</strong> is a statically typed superset of JavaScript, developed and maintained by Microsoft. It’s called a "superset" of JavaScript because it extends the capabilities of JavaScript by adding additional features while maintaining compatibility with existing JavaScript code. This means that any valid JavaScript code is also valid TypeScript code.</p>
<p>TypeScript extends JavaScript by adding type annotations, which provide static type checking at <strong>compile time</strong>. TypeScript code is written in <code>.ts</code> files and, before it can be run in the browser or on a server, it’s transpiled into standard JavaScript using tools like the TypeScript compiler (<code>tsc</code>).</p>
<p>There are some key features of TypeScript that are worth highlighting.</p>
<h2 id="heading-key-features-of-typescript">Key Features of TypeScript</h2>
<ol>
<li><p><strong>Static Typing:</strong> TypeScript allows us to define the types of variables, function parameters, return values, and object properties. This helps catch type-related errors <strong>during development</strong>, rather than at <strong>runtime</strong>.</p>
</li>
<li><p><strong>Type Inference:</strong> TypeScript can infer types based on the values you assign, so we don’t always need to explicitly declare types.</p>
</li>
<li><p><strong>Modern JavaScript Features:</strong> TypeScript supports all modern JavaScript features, including ES6+ features, and compiles them down to JavaScript versions that are compatible with older environments if needed.</p>
</li>
<li><p><strong>Interfaces and Generics:</strong> TypeScript introduces interfaces and generics, which allow for more flexible and reusable code by enabling complex type definitions and contracts.</p>
</li>
<li><p><strong>Tooling and IDE Support:</strong> TypeScript provides excellent tooling support. Most modern IDEs, like Visual Studio Code, provide features like autocompletion, type checking, and inline documentation, which make development more efficient.</p>
</li>
<li><p><strong>Optional Static Typing:</strong> While TypeScript encourages static typing, it’s optional. We can gradually introduce types into a JavaScript codebase, making the transition to TypeScript more manageable.</p>
</li>
</ol>
<p>All these features sound good, but why should we use TypeScript? There are several compelling reasons why TypeScript has become increasingly popular among developers and why it can be a valuable addition to our development toolkit.</p>
<h2 id="heading-why-should-we-use-typescript">Why Should We Use TypeScript?</h2>
<ol>
<li><p><strong>Improved Code Quality:</strong></p>
<ul>
<li><p><strong>Early Error Detection:</strong> By catching errors at compile time rather than at runtime, TypeScript helps prevent common bugs, such as typos, type mismatches, and incorrect function signatures.</p>
</li>
<li><p><strong>Better Documentation:</strong> Type annotations serve as self-documenting code, making it easier for developers to understand what a function or variable is expected to do without needing to refer to external documentation.</p>
</li>
</ul>
</li>
<li><p><strong>Enhanced Developer Experience:</strong></p>
<ul>
<li><p><strong>Intelligent Code Completion:</strong> TypeScript provides better autocompletion and IntelliSense in IDEs, which can speed up development and reduce errors.</p>
</li>
<li><p><strong>Refactoring Support:</strong> TypeScript’s static type system makes it easier and safer to refactor code. The TypeScript compiler can highlight potential issues when renaming variables, moving functions, or restructuring your codebase.</p>
</li>
</ul>
</li>
<li><p><strong>Scalability:</strong></p>
<ul>
<li><p><strong>Large-Scale Applications:</strong> For large projects, TypeScript’s type system can help manage and understand complex codebases, making it easier to maintain and scale applications.</p>
</li>
<li><p><strong>Collaboration:</strong> In teams, TypeScript can enforce consistency and clarity, making it easier for multiple developers to work on the same codebase.</p>
</li>
</ul>
</li>
<li><p><strong>Compatibility with JavaScript:</strong></p>
<ul>
<li><p><strong>Gradual Adoption:</strong> We can start using TypeScript incrementally in existing JavaScript projects. TypeScript files can coexist with JavaScript files, allowing teams to adopt it at their own pace.</p>
</li>
<li><p><strong>Interoperability:</strong> TypeScript is fully compatible with existing JavaScript libraries and frameworks. We can use JavaScript libraries in TypeScript projects and even write TypeScript declarations for them.</p>
</li>
</ul>
</li>
<li><p><strong>Popular Framework Support:</strong></p>
<ul>
<li><strong>React, Angular, Vue:</strong> TypeScript is widely used in modern frontend frameworks and libraries. Angular, for instance, is built with TypeScript, and React and Vue have strong TypeScript support, making it easier to use TypeScript in our frontend projects.</li>
</ul>
</li>
</ol>
<p>Now that we now a little bit abut TypeScript features and the reasons why we should use it in our projects, lets take a look at how TypeScript code actually looks like.</p>
<h2 id="heading-basic-typescript-example">Basic TypeScript Example</h2>
<p>Let's say we have a function that takes two numbers as input, adds them together, and returns the result. In JavaScript, this might look like:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a, b</span>) </span>{
  <span class="hljs-keyword">return</span> a + b;
}

<span class="hljs-keyword">const</span> result = add(<span class="hljs-number">5</span>, <span class="hljs-number">10</span>);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// 15</span>
</code></pre>
<p>This works, but there's no type checking. We could accidentally pass non-number values, leading to unexpected results.</p>
<p>Now let’s take a look how this example looks like when using TypeScript.</p>
<h3 id="heading-the-same-example-in-typescript">The Same Example in TypeScript</h3>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a: number, b: number</span>): <span class="hljs-title">number</span> </span>{
  <span class="hljs-keyword">return</span> a + b;
}

<span class="hljs-keyword">const</span> result = add(<span class="hljs-number">5</span>, <span class="hljs-number">10</span>);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// 15</span>

<span class="hljs-comment">// TypeScript will catch this error if we try to pass non-number arguments:</span>
<span class="hljs-comment">// const wrongResult = add(5, "10"); // Error: Argument of type 'string' is not assignable to parameter of type 'number'.</span>
</code></pre>
<p>In the previous code snippet we can see TypeScript in action:</p>
<ul>
<li><p><strong>Type Annotations:</strong></p>
<ul>
<li><p>The <code>a: number</code> and <code>b: number</code> annotations specify that <code>a</code> and <code>b</code> must be numbers.</p>
</li>
<li><p>The <code>: number</code> after the function parameters indicates that the function returns a number.</p>
</li>
</ul>
</li>
<li><p><strong>Error Prevention:</strong></p>
<ul>
<li>If we try to call <code>add(5, "10")</code> with a string instead of a number, TypeScript will throw an error during development, preventing potential bugs.</li>
</ul>
</li>
</ul>
<p>In this example we can see a couple of benefits introduced by TypeScript:</p>
<ol>
<li><p><strong>Type Safety:</strong> The function guarantees that it only works with numbers, reducing the chance of runtime errors.</p>
</li>
<li><p><strong>Documentation:</strong> The type annotations act as a form of documentation, making it clear what types of arguments the function expects and what it returns.</p>
</li>
<li><p><strong>Better Tooling:</strong> When using an IDE like Visual Studio Code, TypeScript provides autocompletion and inline type checking, which helps prevent mistakes.</p>
</li>
</ol>
<h1 id="heading-install-and-run-typescript">Install and Run TypeScript</h1>
<p>Enough with the theory. Let’s get our hands dirty.</p>
<p>In order to install TypeScript, we could follow the indications in the <a target="_blank" href="https://www.typescriptlang.org/download/">official documentation</a>, and run:</p>
<pre><code class="lang-bash">npm install typescript --save-dev
</code></pre>
<p>If we are using VSCode, these extensions will improve the overall use of TypeScript in our development environment:</p>
<ul>
<li><p>Name: <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-next">JavaScript and TypeScript Nightly</a> Description: Enables typescript@next to power VS Code's built-in JavaScript and TypeScript support</p>
</li>
<li><p>Name: <a target="_blank" href="https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors">Pretty TypeScript Errors</a> Description: Make TypeScript errors prettier and more human-readable in VSCode</p>
</li>
</ul>
<h2 id="heading-running-the-typescript-compiler">Running the TypeScript Compiler</h2>
<p>In order to compile our TypeScript files into JavaScript files that the browser can understand, we need to run:</p>
<pre><code class="lang-bash">npx tsc --init <span class="hljs-comment"># &lt;- run this the first time to generate a tsconfig.json file</span>

npx tsc <span class="hljs-comment"># &lt;- run this to compile the project</span>

<span class="hljs-comment"># or</span>

npx tsc &lt;file_name&gt;
</code></pre>
<p>Here’s an example of errors in our code being picked up by TypeScript:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1724553063722/296966f0-0f9d-48f7-993d-28c4679d71b2.png" alt class="image--center mx-auto" /></p>
<p>After running the <code>npx tsc</code> command, a JavaScript file will be generated as a result of the compilation process.</p>
<h1 id="heading-fundamental-types">Fundamental Types</h1>
<p>Now let’s go back to the theory so we can learn TypeScript fundamental types.</p>
<h2 id="heading-1-the-any-type">1. The <code>any</code> Type</h2>
<p>The <code>any</code> type can represent any JavaScript value. It's a "catch-all" type that disables type checking for that variable and the default type when we don’t specify a type explicitly.</p>
<p>It's recommended to avoid <code>any</code> because it defeats the purpose of using TypeScript for type safety.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> myVar: any; <span class="hljs-comment">// &lt;- the 'any' keyword can be ommited</span>
myVar = <span class="hljs-number">42</span>;
myVar = <span class="hljs-string">"text"</span>;
</code></pre>
<h2 id="heading-2-primitive-types">2. <strong>Primitive Types</strong></h2>
<p><code>string</code>: Represents textual data.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> userName: string = <span class="hljs-string">"Damian"</span>;
</code></pre>
<p><code>number</code>: Represents numeric data, including integers and floating-point numbers.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> age: number = <span class="hljs-number">30</span>;
</code></pre>
<p><code>boolean</code>: Represents <code>true</code> or <code>false</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> isActive: boolean = <span class="hljs-literal">true</span>;
</code></pre>
<p><code>null</code> and <code>undefined</code>: Represent the absence of a value.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> emptyValue: <span class="hljs-literal">null</span> = <span class="hljs-literal">null</span>;
<span class="hljs-keyword">let</span> notAssigned: <span class="hljs-literal">undefined</span> = <span class="hljs-literal">undefined</span>;
</code></pre>
<h2 id="heading-3-array-types">3. <strong>Array Types</strong></h2>
<p>Arrays can be defined with a specific type for their elements.</p>
<p>The type is defined as <code>type[]</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> hobbies: string[] = [<span class="hljs-string">"photography"</span>, <span class="hljs-string">"hiking"</span>];
<span class="hljs-keyword">let</span> lottoNumbers: number[] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];
</code></pre>
<h2 id="heading-4-object-types">4. <strong>Object Types</strong></h2>
<p>Objects can be typed by specifying the types of their properties.</p>
<p>Define object types using <code>{ property: type; }</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> person: {
  <span class="hljs-attr">name</span>: string;
  age: number;
} = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"Damian"</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">21</span> <span class="hljs-comment">// I wish...</span>
};
</code></pre>
<h2 id="heading-5-union-types">5. <strong>Union Types</strong></h2>
<p>Union types allow a variable to hold multiple types.</p>
<p>Use the pipe (<code>|</code>) to combine types.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> id: number | string;
id = <span class="hljs-number">42</span>; <span class="hljs-comment">// valid</span>
id = <span class="hljs-string">"42"</span>; <span class="hljs-comment">// also valid</span>
</code></pre>
<h2 id="heading-6-tuple-types">6. <strong>Tuple Types</strong></h2>
<p>Tuples allow you to express an array with a fixed number of elements, each with a specific type.</p>
<p>Define using <code>[type1, type2, ...]</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> address: [string, number];
address = [<span class="hljs-string">"Main Street"</span>, <span class="hljs-number">123</span>];
</code></pre>
<h2 id="heading-7-enum-types">7. <strong>Enum Types</strong></h2>
<p>Enums allow us to define a set of named constants.</p>
<p>Useful for representing a fixed set of related values.</p>
<pre><code class="lang-javascript">enum Color {
  Red,
  Green,
  Blue
}
<span class="hljs-keyword">let</span> favoriteColor: Color = Color.Green;
</code></pre>
<h2 id="heading-8-function-types">8. <strong>Function Types</strong></h2>
<p>You can define the types for the parameters and return value of a function.</p>
<p>This helps ensure functions are called with the correct arguments.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Regular function definition</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a: number, b: number</span>): <span class="hljs-title">number</span> </span>{
  <span class="hljs-keyword">return</span> a + b;
}
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-comment">// Arrow function definition</span>
<span class="hljs-keyword">const</span> add: <span class="hljs-function">(<span class="hljs-params">a: number, b: number</span>) =&gt;</span> number = <span class="hljs-function">(<span class="hljs-params">a, b</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> a + b;
}
</code></pre>
<h2 id="heading-9-void-type">9. <strong>Void Type</strong></h2>
<p>Used when a function does not return a value.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">logMessage</span>(<span class="hljs-params">message: string</span>): <span class="hljs-title">void</span> </span>{
  <span class="hljs-built_in">console</span>.log(message);
}
</code></pre>
<h2 id="heading-10-type-aliases">10. <strong>Type Aliases</strong></h2>
<p>Allows us to create custom types using the <code>type</code> keyword. By convention, type aliases names start with a capital letter.</p>
<p>This simplifies complex type definitions.</p>
<pre><code class="lang-javascript">type Person = {
  <span class="hljs-attr">name</span>: string;
  age: number;
};

<span class="hljs-keyword">let</span> person1: Person = { <span class="hljs-attr">name</span>: <span class="hljs-string">"Harry"</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">35</span> };
<span class="hljs-keyword">let</span> person2: Person = { <span class="hljs-attr">name</span>: <span class="hljs-string">"Ron"</span>, <span class="hljs-attr">age</span>: <span class="hljs-number">34</span> };
</code></pre>
<h1 id="heading-type-inference">Type Inference</h1>
<p>Let’s now move on to a TypeScript characteristic that could make our lives easier when working with types.</p>
<p>Type inference in TypeScript is a feature where the compiler <strong>automatically infers</strong> the types of variables, functions, and other expressions based on the values or context in which they are used, without the need for explicit type annotations.</p>
<p>If we initialize a variable when we declare it, TypeScript infers its type based on the assigned value.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> age = <span class="hljs-number">30</span>; <span class="hljs-comment">// TypeScript infers that 'age' is of type 'number'</span>
age = <span class="hljs-string">"thirty"</span>; <span class="hljs-comment">// Error: Type '"thirty"' is not assignable to type 'number'</span>
</code></pre>
<p>For functions, TypeScript infers the return type based on the function's return statements.</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">add</span>(<span class="hljs-params">a: number, b: number</span>) </span>{
  <span class="hljs-keyword">return</span> a + b; <span class="hljs-comment">// TypeScript infers the return type as 'number'</span>
}

<span class="hljs-keyword">const</span> result = add(<span class="hljs-number">5</span>, <span class="hljs-number">10</span>); <span class="hljs-comment">// 'result' is inferred to be of type 'number'</span>
</code></pre>
<p>If we create an array and initialize it with values, TypeScript infers the type of the array elements.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> names = [<span class="hljs-string">"Alice"</span>, <span class="hljs-string">"Bob"</span>, <span class="hljs-string">"Charlie"</span>]; <span class="hljs-comment">// TypeScript infers 'string[]' as the type</span>
names.push(<span class="hljs-number">42</span>); <span class="hljs-comment">// Error: Argument of type 'number' is not assignable to parameter of type 'string'</span>
</code></pre>
<h2 id="heading-benefits-of-type-inference">Benefits of Type Inference</h2>
<p>Type inference has some nice benefits:</p>
<ul>
<li><p><strong>Less Boilerplate:</strong> We can write less code because we don't have to explicitly annotate types in many cases.</p>
</li>
<li><p><strong>Readability:</strong> It makes the code cleaner and easier to read since the types are automatically inferred from the context.</p>
</li>
<li><p><strong>Type Safety:</strong> Even though types aren't explicitly annotated, we still get the benefits of TypeScript's type checking.</p>
</li>
</ul>
<h2 id="heading-when-to-rely-on-inference">When to Rely on Inference</h2>
<p>We shouldn’t always rely on type inference, but there are some situations when depending on type inference can be a good idea: simple cases like variables, function return types, and straightforward data structures.</p>
<p>For more complex scenarios or when the inferred type might be unclear, it's better to use explicit annotations to make the code's intention clear.</p>
<h2 id="heading-type-inference-example">Type Inference Example</h2>
<p>Here's a practical example of type inference:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> greeting = <span class="hljs-string">"Hello, world!"</span>; <span class="hljs-comment">// TypeScript infers the type as 'string'</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">multiply</span>(<span class="hljs-params">a: number, b: number</span>) </span>{
  <span class="hljs-keyword">return</span> a * b; <span class="hljs-comment">// TypeScript infers the return type as 'number'</span>
}

<span class="hljs-keyword">const</span> result = multiply(<span class="hljs-number">5</span>, <span class="hljs-number">10</span>); <span class="hljs-comment">// 'result' is inferred to be of type 'number'</span>

<span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]; <span class="hljs-comment">// TypeScript infers the type as 'number[]'</span>
numbers.push(<span class="hljs-number">4</span>); <span class="hljs-comment">// This is fine</span>
<span class="hljs-comment">// numbers.push("five"); // Error: Argument of type 'string' is not assignable to parameter of type 'number'</span>
</code></pre>
<p>In this example, even though we didn't explicitly define the types for <code>greeting</code>, <code>result</code>, and <code>numbers</code>, TypeScript automatically inferred the correct types based on the context.</p>
<h1 id="heading-interfaces-and-type-aliases">Interfaces and Type Aliases</h1>
<p>In TypeScript, <strong>interfaces</strong> and <strong>type aliases</strong> are both tools that allow us to define custom types. They help us describe the shape of objects, specify the types of data structures, and enforce a consistent structure across our code. Although they have similar purposes, there are some differences in their syntax, capabilities, and best-use scenarios. Let's break down what each one is and how to use them effectively.</p>
<h2 id="heading-interfaces"><strong>Interfaces</strong></h2>
<p>An <strong>interface</strong> is a way to define a contract for the shape of an object. Interfaces are primarily used to <strong>describe the structure of objects</strong>, including their properties and methods. They can also be extended or implemented, which makes them very useful for object-oriented programming and large-scale applications.</p>
<p>Here's a basic example of how to define and use an interface in TypeScript:</p>
<pre><code class="lang-javascript">interface User {
  <span class="hljs-attr">name</span>: string;
  age: number;
  isAdmin: boolean;
}

<span class="hljs-keyword">const</span> user: User = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"Alice"</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">30</span>,
  <span class="hljs-attr">isAdmin</span>: <span class="hljs-literal">true</span>,
};
</code></pre>
<p>In this example <code>User</code> is an interface that describes an object with three properties: <code>name</code>, <code>age</code>, and <code>isAdmin</code>. The <code>user</code> variable is then defined to adhere to the <code>User</code> interface, ensuring it has all the required properties with the correct types.</p>
<h3 id="heading-extending-interfaces"><strong>Extending Interfaces</strong></h3>
<p>One powerful feature of interfaces is that they can be extended, allowing us to build upon existing types:</p>
<pre><code class="lang-javascript">interface Person {
  <span class="hljs-attr">name</span>: string;
  age: number;
}

interface Employee <span class="hljs-keyword">extends</span> Person {
  <span class="hljs-attr">employeeId</span>: number;
}

<span class="hljs-keyword">const</span> employee: Employee = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">"Bob"</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">25</span>,
  <span class="hljs-attr">employeeId</span>: <span class="hljs-number">12345</span>,
};
</code></pre>
<p>Here, <code>Employee</code> extends <code>Person</code>, meaning it inherits the properties of <code>Person</code> and adds its own (<code>employeeId</code>).</p>
<h3 id="heading-optional-properties-and-read-only-properties"><strong>Optional Properties and Read-Only Properties</strong></h3>
<p>Interfaces can define optional properties and read-only properties:</p>
<pre><code class="lang-javascript">interface Car {
  <span class="hljs-attr">brand</span>: string;
  model: string;
  year?: number; <span class="hljs-comment">// Optional property</span>
  readonly vin: string; <span class="hljs-comment">// Read-only property</span>
}

<span class="hljs-keyword">const</span> myCar: Car = {
  <span class="hljs-attr">brand</span>: <span class="hljs-string">"Toyota"</span>,
  <span class="hljs-attr">model</span>: <span class="hljs-string">"Corolla"</span>,
  <span class="hljs-attr">vin</span>: <span class="hljs-string">"1234567890"</span>,
};

<span class="hljs-comment">// myCar.vin = "0987654321"; // Error: Cannot assign to 'vin' because it is a read-only property.</span>
</code></pre>
<p>In this example, <code>year?</code> indicates that <code>year</code> is an optional property and <code>readonly vin</code> means that the <code>vin</code> property cannot be modified once it is set.</p>
<h2 id="heading-type-aliases"><strong>Type Aliases</strong></h2>
<p>A <strong>type alias</strong> is another way to define a type in TypeScript. It can describe objects, primitive types, union types, intersections, and even function signatures. Type aliases are more flexible than interfaces because they can represent more than just the shape of an object.</p>
<h3 id="heading-defining-a-type-alias"><strong>Defining a Type Alias</strong></h3>
<p>Here's how to define a type alias:</p>
<pre><code class="lang-javascript">type Point = {
  <span class="hljs-attr">x</span>: number;
  y: number;
};

<span class="hljs-keyword">const</span> point: Point = {
  <span class="hljs-attr">x</span>: <span class="hljs-number">10</span>,
  <span class="hljs-attr">y</span>: <span class="hljs-number">20</span>,
};
</code></pre>
<p>In this example, <code>Point</code> is a type alias that defines an object with two properties: <code>x</code> and <code>y</code>.</p>
<h3 id="heading-type-aliases-for-primitive-types-and-unions"><strong>Type Aliases for Primitive Types and Unions</strong></h3>
<p>Type aliases <strong>are not limited to objects</strong>; they can also be used to create unions, intersections, and custom types:</p>
<pre><code class="lang-javascript">type ID = string | number;

<span class="hljs-keyword">let</span> userId: ID;
userId = <span class="hljs-string">"abc123"</span>;
userId = <span class="hljs-number">456</span>;

type Result = <span class="hljs-string">"success"</span> | <span class="hljs-string">"failure"</span> | <span class="hljs-string">"pending"</span>;

<span class="hljs-keyword">const</span> taskStatus: Result = <span class="hljs-string">"success"</span>;
</code></pre>
<p>In the above example, <code>ID</code> is a type alias that can be either a <code>string</code> or a <code>number</code>. <code>Result</code> is a type alias that can only be one of the three specified string literals.</p>
<h3 id="heading-type-aliases-for-function-types"><strong>Type Aliases for Function Types</strong></h3>
<p>We can also use type aliases to define function signatures:</p>
<pre><code class="lang-javascript">type Greet = <span class="hljs-function">(<span class="hljs-params">name: string</span>) =&gt;</span> string;

<span class="hljs-keyword">const</span> greetUser: Greet = <span class="hljs-function">(<span class="hljs-params">name</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> <span class="hljs-string">`Hello, <span class="hljs-subst">${name}</span>!`</span>;
};

<span class="hljs-built_in">console</span>.log(greetUser(<span class="hljs-string">"Alice"</span>)); <span class="hljs-comment">// Output: Hello, Alice!</span>
</code></pre>
<p>This feature will become one of the most used ones when working with TypeScript in a React project.</p>
<h2 id="heading-interfaces-vs-type-aliases"><strong>Interfaces vs. Type Aliases</strong></h2>
<p>While both interfaces and type aliases can be used to describe the shape of objects, there are some key differences:</p>
<ul>
<li><p><strong>Use Cases</strong>:</p>
<ul>
<li><p><strong>Interfaces</strong> are generally preferred for defining the structure of objects, especially when those objects are meant to be extended or implemented by classes.</p>
</li>
<li><p><strong>Type aliases</strong> are more versatile, as they can describe objects, unions, intersections, and primitives. They are often used for complex types or when using union and intersection types.</p>
</li>
</ul>
</li>
<li><p><strong>Extensibility</strong>:</p>
<ul>
<li><p><strong>Interfaces</strong> can be extended using the <code>extends</code> keyword, which is useful in many object-oriented programming scenarios.</p>
</li>
<li><p><strong>Type aliases</strong> cannot be extended in the same way, but they can combine types using intersections (<code>&amp;</code>).</p>
</li>
</ul>
</li>
<li><p><strong>Merging</strong>:</p>
<ul>
<li><p><strong>Interfaces</strong> can be merged across multiple declarations. This is particularly useful when working with third-party libraries where you might want to extend existing interfaces.</p>
</li>
<li><p><strong>Type aliases</strong> cannot be merged.</p>
</li>
</ul>
</li>
<li><p><strong>Syntax</strong>:</p>
<ul>
<li>The syntax for interfaces is more concise when defining object shapes, while type aliases offer more flexibility in representing different kinds of types.</li>
</ul>
</li>
<li><p><strong>Open vs Close:</strong></p>
<ul>
<li><p>One major difference between type aliases vs interfaces are that interfaces are open and type aliases are closed. This means we can extend an interface by declaring it a second time:</p>
<pre><code class="lang-javascript">  interface Kitten {
    <span class="hljs-attr">purrs</span>: boolean;
  }

  interface Kitten {
    <span class="hljs-attr">colour</span>: string;
  }
</code></pre>
<p>  But we can’t extend type aliases in the same way:</p>
<pre><code class="lang-javascript">  type Puppy = {
    <span class="hljs-attr">color</span>: string;
  };

  type Puppy = { <span class="hljs-comment">// it throws an error</span>
    <span class="hljs-attr">toys</span>: number;
  };
</code></pre>
</li>
</ul>
</li>
</ul>
<h2 id="heading-when-to-use-which"><strong>When to Use Which?</strong></h2>
<p>We should use <strong>interfaces</strong> when defining the shape of objects and when we expect to use inheritance or class-based implementations.</p>
<p>We should use <strong>type aliases</strong> when we need to define more complex types like unions, intersections, or when you need the flexibility to define different kinds of types beyond just objects.</p>
<h1 id="heading-generics">Generics</h1>
<p>Generics in TypeScript are a powerful feature that allows us to create reusable and flexible components, functions, or types that can work with a variety of data types while maintaining type safety. They enable us to write code that is more abstract and can handle different types without losing the benefits of TypeScript's type-checking.</p>
<p>Generics is one of the key TypeScript features we’ll be using in our React projects.</p>
<p>Without generics, we might have to write multiple versions of the same function or component for different data types. Generics let us write a single version that works for any type, which makes our code more reusable and maintainable.</p>
<h2 id="heading-basic-syntax-of-generics">Basic Syntax of Generics</h2>
<p>A generic type is defined using a type parameter, which is usually denoted by a single capital letter like <code>T</code> (short for "Type"). The type parameter is specified in angle brackets (<code>&lt;T&gt;</code>) and can be used in the function, class, or type alias.</p>
<h2 id="heading-example-generic-function-1">Example: Generic Function 1</h2>
<p>Let’s take a look at an example of a generic:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">identity</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">value: T</span>): <span class="hljs-title">T</span> </span>{
  <span class="hljs-keyword">return</span> value;
}

<span class="hljs-keyword">const</span> result1 = identity&lt;string&gt;(<span class="hljs-string">"Hello, world!"</span>); <span class="hljs-comment">// result1 is of type 'string'</span>
<span class="hljs-keyword">const</span> result2 = identity&lt;number&gt;(<span class="hljs-number">42</span>); <span class="hljs-comment">// result2 is of type 'number'</span>
</code></pre>
<p>In this example, the <code>identity</code> function takes a type parameter <code>T</code>. When you call the function, you can specify the type explicitly (e.g., <code>identity&lt;string&gt;("Hello, world!")</code>), or TypeScript can infer it automatically.</p>
<h2 id="heading-example-generic-function-2">Example: Generic Function 2</h2>
<p>Here's another simple example of a generic function:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">insertAtBeginning</span>&lt;<span class="hljs-title">T</span>&gt;(<span class="hljs-params">array: T[], value: T</span>) </span>{
  <span class="hljs-keyword">const</span> newArray = [value, ...array];
  <span class="hljs-keyword">return</span> newArray;
}

<span class="hljs-keyword">const</span> demoArray = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>];

<span class="hljs-keyword">const</span> numberArray = insertAtBeginning(demoArray, <span class="hljs-number">-1</span>);
<span class="hljs-comment">// Equivalent to: function insertAtBeginning&lt;number&gt;(array: number[], value: number): number[]</span>

<span class="hljs-keyword">const</span> stringArray = insertAtBeginning([<span class="hljs-string">"a"</span>, <span class="hljs-string">"b"</span>, <span class="hljs-string">"c"</span>], <span class="hljs-string">"z"</span>);
<span class="hljs-comment">// Equivalent to: function insertAtBeginning&lt;string&gt;(array: string[], value: string): string[]</span>

<span class="hljs-keyword">const</span> wrongStringArray = insertAtBeginning([<span class="hljs-string">"a"</span>, <span class="hljs-string">"b"</span>, <span class="hljs-string">"c"</span>], <span class="hljs-number">42</span>);
<span class="hljs-comment">// Error: Argument of type 'number' is not assignable to parameter of type 'string'.typescript(2345)</span>
</code></pre>
<p>In this example, the <code>insertAtBeginning</code> function takes a type parameter <code>T</code> and two function parameters: the first one will be an array containing all the elements of the same type <code>T</code>, and the second one will be a single value of the same type <code>T</code>. When we call the function, TypeScript can infer all the types automatically.</p>
<p>If we try to pass two different types to the function, as in the <code>wrongStringArray</code> case, it will fail.</p>
<h2 id="heading-example-generic-classes">Example: Generic Classes</h2>
<p>Generics can also be used with classes:</p>
<pre><code class="lang-javascript"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Box</span>&lt;<span class="hljs-title">T</span>&gt; </span>{
  <span class="hljs-attr">content</span>: T;

  <span class="hljs-keyword">constructor</span>(content: T) {
    <span class="hljs-built_in">this</span>.content = content;
  }

  getContent(): T {
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">this</span>.content;
  }
}

<span class="hljs-keyword">const</span> stringBox = <span class="hljs-keyword">new</span> Box&lt;string&gt;(<span class="hljs-string">"A string"</span>);
<span class="hljs-built_in">console</span>.log(stringBox.getContent()); <span class="hljs-comment">// "A string"</span>

<span class="hljs-keyword">const</span> numberBox = <span class="hljs-keyword">new</span> Box&lt;number&gt;(<span class="hljs-number">123</span>);
<span class="hljs-built_in">console</span>.log(numberBox.getContent()); <span class="hljs-comment">// 123</span>
</code></pre>
<p>The <code>Box</code> class is generic, meaning it can hold any type of content. The type parameter <code>T</code> is used in the property <code>content</code>, the constructor parameter, and the return type of the <code>getContent</code> method. We can create instances of <code>Box</code> with different types, such as <code>string</code> or <code>number</code>.</p>
<p><strong><em>💡 Note:</em></strong> <em>When we define an array type, we normally do this:</em></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbersArray: number[] = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
</code></pre>
<p><em>But the</em> <code>number[]</code> <em>notation is syntactic sugar. What we are actually using is:</em></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbersArray: <span class="hljs-built_in">Array</span>&lt;number&gt; = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>]
</code></pre>
<p><em>So, we are actually using generics here. There’s an</em> <code>Array</code> <em>generic class that receives a parameter of type</em> <code>number</code> <em>and returns an array of numbers.</em></p>
<h2 id="heading-example-generic-interfaces">Example: Generic Interfaces</h2>
<p>Generics can also be used with interfaces:</p>
<pre><code class="lang-javascript">interface Pair&lt;T, U&gt; {
  <span class="hljs-attr">first</span>: T;
  second: U;
}

<span class="hljs-keyword">const</span> stringNumberPair: Pair&lt;string, number&gt; = {
  <span class="hljs-attr">first</span>: <span class="hljs-string">"one"</span>,
  <span class="hljs-attr">second</span>: <span class="hljs-number">1</span>,
};

<span class="hljs-keyword">const</span> booleanArrayPair: Pair&lt;boolean, boolean[]&gt; = {
  <span class="hljs-attr">first</span>: <span class="hljs-literal">true</span>,
  <span class="hljs-attr">second</span>: [<span class="hljs-literal">true</span>, <span class="hljs-literal">false</span>, <span class="hljs-literal">true</span>],
};
</code></pre>
<p>The <code>Pair</code> interface takes two type parameters, <code>T</code> and <code>U</code>, which represent the types of the <code>first</code> and <code>second</code> properties, respectively. This allows us to create pairs of different types, like <code>string</code> and <code>number</code> or <code>boolean</code> and <code>boolean[]</code>.</p>
<h2 id="heading-example-generic-constraints">Example: Generic Constraints</h2>
<p>We can also add constraints to generics to ensure that the types used meet certain requirements. For example:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getLength</span>&lt;<span class="hljs-title">T</span> <span class="hljs-title">extends</span> </span>{ length: number }&gt;(item: T): number {
  <span class="hljs-keyword">return</span> item.length;
}

<span class="hljs-built_in">console</span>.log(getLength(<span class="hljs-string">"Hello"</span>)); <span class="hljs-comment">// 5</span>
<span class="hljs-built_in">console</span>.log(getLength([<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-comment">// 4</span>
<span class="hljs-comment">// console.log(getLength(42)); // Error: Argument of type 'number' is not assignable to parameter of type '{ length: number; }'</span>
</code></pre>
<p>The <code>getLength</code> function is generic, but it requires that the type <code>T</code> has a <code>length</code> property. This constraint is defined using <code>T extends { length: number }</code>. This ensures that we can only call <code>getLength</code> with types that have a <code>length</code> property, such as strings or arrays.</p>
<h1 id="heading-setting-up-a-react-project-with-typescript">Setting Up a React Project with TypeScript</h1>
<p>Let’s now finally start applying what we have learned about TypeScript in a React project.</p>
<p>In order to work with TypeScript in a React project, we need to configure our building tool (Vite, Create React App, etc.) to support TypeScript.</p>
<p>If we are working with Vite, we can implement TypeScript in our React project like so:</p>
<pre><code class="lang-bash">❯ npm create vite@latest  

Need to install the following packages:
create-vite@5.5.1
Ok to proceed? (y) 
✔ Project name: … react-ts
✔ Select a framework: › React
✔ Select a variant: › TypeScript

Scaffolding project <span class="hljs-keyword">in</span> /Users/damian/Programming/Workspaces/react-the-complete-guide-course-code/30-typescript-foundations/react-ts...

Done. Now run:

  <span class="hljs-built_in">cd</span> react-ts
  npm install
  npm run dev

❯ <span class="hljs-built_in">cd</span> react-ts

❯ npm install

added 195 packages, and audited 196 packages <span class="hljs-keyword">in</span> 39s

42 packages are looking <span class="hljs-keyword">for</span> funding
  run `npm fund` <span class="hljs-keyword">for</span> details

found 0 vulnerabilities

❯ npm run dev

&gt; react-ts@0.0.0 dev
&gt; vite

  VITE v5.4.0  ready <span class="hljs-keyword">in</span> 1738 ms

  ➜  Local:   &lt;http://localhost:5173/&gt;
  ➜  Network: use --host to expose
  ➜  press h + enter to show <span class="hljs-built_in">help</span>
</code></pre>
<p>By selecting the <code>Select a variant: › TypeScript</code> our project will now have files with <code>tsx</code> extension instead of <code>jsx</code>, indicating those are TypeScript files. Vite will take care of transpiling TypeScript into JavaScript during the build process.</p>
<h1 id="heading-function-components-with-typescript">Function Components with TypeScript</h1>
<p>In React, a <strong>function component</strong> is a JavaScript function that returns JSX (a syntax extension that looks like HTML, used to describe the UI structure).</p>
<p>Let’s take a look at an example without TypeScript:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">Todos</span>(<span class="hljs-params">props</span>) </span>{
  <span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>{
    props.items.map(
      item =&gt; <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{item}</span>&gt;</span>{item}<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    )
  }<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span></span>;
}
</code></pre>
<p>When working with React function components, we can explicitly define the types for the props that our component will receive.</p>
<p>TypeScript enhances this function component by adding static type checking. This allows us to catch errors at compile-time rather than at runtime, making our code safer and easier to maintain.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">const</span> Todos: React.FC&lt;{ <span class="hljs-attr">items</span>: string[] }&gt; = <span class="hljs-function">(<span class="hljs-params">props</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
      {props.items.map((item) =&gt; (
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span> <span class="hljs-attr">key</span>=<span class="hljs-string">{item}</span>&gt;</span>{item}<span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
      ))}
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Todos;
</code></pre>
<p>Let’s try to understand what’s going on here.</p>
<ol>
<li><p><code>React.FC</code> (or <code>React.FunctionComponent</code>):</p>
<ul>
<li><p><code>React.FC</code> is a <strong>generic type</strong> provided by React that stands for "Function Component."</p>
</li>
<li><p>It is a type definition that ensures our function component adheres to the standard React function component structure.</p>
</li>
<li><p>By using <code>React.FC</code>, we automatically get the <code>children</code> prop included, which is often useful when we want to allow other components or elements to be nested inside our component.</p>
</li>
</ul>
</li>
<li><p><strong>Defining Props:</strong></p>
<ul>
<li><p>In the example, <code>{ items: string[] }</code> is the type definition for the props that the <code>Todos</code> component will receive.</p>
</li>
<li><p>This definition means that the <code>items</code> prop is required and must be an array of strings.</p>
</li>
<li><p>If we want to make a prop optional, we can add a question mark (<code>?</code>) after the prop name, like <code>{ items?: string[] }</code>.</p>
</li>
</ul>
</li>
<li><p><strong>Using Props:</strong></p>
<ul>
<li><p>Inside the function component, we can access the props via the <code>props</code> object.</p>
</li>
<li><p>In this case, <code>props.items</code> is used to map over the array and render each item as a list item (<code>&lt;li&gt;</code>).</p>
</li>
<li><p>The <code>key</code> attribute in the list item is important for React's reconciliation process when rendering lists. This has nothing to do with TypeScript.</p>
</li>
</ul>
</li>
<li><p><strong>Exporting the Component:</strong></p>
<ul>
<li>Finally, the component is exported using <code>export default Todos;</code>, making it available for import and use in other parts of our application.</li>
</ul>
</li>
</ol>
<h2 id="heading-key-benefits-of-using-typescript-with-react-function-components">Key Benefits of Using TypeScript with React Function Components</h2>
<p>These are the key benefits we get when using TypeScript in a function component (<code>React.FC</code>):</p>
<ul>
<li><p><strong>Type Safety:</strong> By defining the types of props, we ensure that our component only receives the expected types, reducing runtime errors.</p>
</li>
<li><p><strong>Documentation:</strong> The types serve as self-documentation, making it easier to understand what a component expects.</p>
</li>
<li><p><strong>Code Completion:</strong> TypeScript provides better code completion and IDE support, helping us write code more efficiently.</p>
</li>
<li><p><strong>Optional Props:</strong> TypeScript makes it easy to handle optional props and provide default values if needed.</p>
</li>
</ul>
<h1 id="heading-working-with-forms-and-refs">Working with Forms and Refs</h1>
<p>Let’s now discuss how wee can work with forms and refs in a TypeScript-based React component with this ecample:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> { useRef } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">const</span> NewTodo = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> todoTextInput = useRef&lt;HTMLInputElement&gt;(<span class="hljs-literal">null</span>);

  <span class="hljs-keyword">const</span> submitHandler = <span class="hljs-function">(<span class="hljs-params">event: React.FormEvent</span>) =&gt;</span> {
    event.preventDefault();

    <span class="hljs-comment">// const enteredText = todoTextInput.current?.value</span>
    <span class="hljs-keyword">const</span> enteredText = todoTextInput.current!.value;

    <span class="hljs-keyword">if</span> (enteredText.trim().length === <span class="hljs-number">0</span>) {
      <span class="hljs-comment">// Throw error</span>
      <span class="hljs-keyword">return</span>;
    }
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">onSubmit</span>=<span class="hljs-string">{submitHandler}</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">htmlFor</span>=<span class="hljs-string">"todo"</span>&gt;</span>Todo text<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">""</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"todo"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">{todoTextInput}</span> /&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span>Add ToDo<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> NewTodo;
</code></pre>
<p><strong><em>💡 Note:</em></strong> <em>Some of the code used in this article has been created as part of my notes wilst taking the Udemy course React - The Complete Guide 2024 (incl. Next.js, Redux), so expect certain similarities with the code shown in that course.</em></p>
<p>This code is a TypeScript-based React component that demonstrates several important TypeScript and React concepts. Let's break down and explain each of these concepts:</p>
<ul>
<li><p><code>const todoTextInput = useRef&lt;HTMLInputElement&gt;(null);</code></p>
<ul>
<li><p><code>useRef</code> with TypeScript:</p>
<ul>
<li><p>Here, <code>useRef</code> is used to create a reference to an HTML input element. The type parameter <code>&lt;HTMLInputElement&gt;</code> is passed to specify the type of DOM element that <code>todoTextInput</code> will reference.</p>
</li>
<li><p><strong>Type Parameter</strong> <code>&lt;HTMLInputElement&gt;</code>:</p>
<ul>
<li><p>TypeScript uses this to enforce that the ref object will be tied to an <code>HTMLInputElement</code>, ensuring type safety. For example, <code>todoTextInput.current</code> will be inferred to be of type <code>HTMLInputElement | null</code>.</p>
</li>
<li><p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1724553406817/d83d8c4f-21f0-4d50-9c03-4573353c21aa.png" alt class="image--center mx-auto" /></p>
</li>
</ul>
</li>
<li><p><strong>Initial Value</strong> <code>null</code>:</p>
<ul>
<li>The initial value of <code>todoTextInput</code> is <code>null</code>, indicating that the ref is not yet pointing to any DOM element when the component first renders. This is common when using refs to access elements that will be rendered later.</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p><code>const submitHandler = (event: React.FormEvent) =&gt; {}</code></p>
<ul>
<li><p><strong>Event Handling in TypeScript:</strong></p>
<ul>
<li><p>This line defines a <code>submitHandler</code> function that is triggered when the form is submitted.</p>
</li>
<li><p><strong>Type Annotation</strong> <code>React.FormEvent</code>:</p>
<ul>
<li>The <code>event</code> parameter is explicitly typed as <code>React.FormEvent</code>, which is a type provided by React for form events. This ensures that <code>event</code> has the properties and methods available for form events, such as <code>preventDefault()</code>.</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><p><code>const enteredText = todoTextInput.current!.value;</code></p>
<ul>
<li><p><strong>Non-Null Assertion Operator (</strong><code>!</code>):</p>
<ul>
<li><p><code>todoTextInput.current!</code> is using the <strong>non-null assertion operator</strong> (<code>!</code>), which tells TypeScript that we are certain <code>current</code> is not <code>null</code> at this point in the code.</p>
</li>
<li><p>This operator is useful when we are sure that a value is non-null or non-undefined, but TypeScript’s type system isn't aware of it. However, it should be used with caution as it can bypass TypeScript’s safety checks.</p>
</li>
<li><p>If we don’t know if the element is going to be <code>null</code> or have a value, we can use the <strong>optional chaining operator</strong> <code>?</code> operator instead.</p>
</li>
</ul>
</li>
<li><p><strong>Accessing DOM Element Value:</strong></p>
<ul>
<li><code>todoTextInput.current!.value</code> accesses the <code>value</code> property of the input element, which contains the text entered by the user.</li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="heading-working-with-functions-as-props">Working with Functions as Props</h1>
<p>When working with functions as props in React TypeScript, it’s important to define the types of the props, including the functions.</p>
<p>When passing a function as a prop, we need to define its type signature in the props interface. This includes specifying the function's parameters and return type.</p>
<p>For example, if we have a function (<code>onClick</code>) that takes a string as a parameter (<code>message</code>) and returns nothing (<code>void</code>), we can define it like this:</p>
<pre><code class="lang-javascript">type MyComponentProps = {
  <span class="hljs-attr">onClick</span>: <span class="hljs-function">(<span class="hljs-params">message: string</span>) =&gt;</span> <span class="hljs-keyword">void</span>;
};
</code></pre>
<p>Remember that, if the function returns a value, we specify the return type instead of <code>void</code>.</p>
<p>Let’s say we now have a <code>Button</code> component that accepts a click handler function:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

type ButtonProps = {
  <span class="hljs-attr">onClick</span>: <span class="hljs-function">(<span class="hljs-params">message: string</span>) =&gt;</span> <span class="hljs-keyword">void</span>;
};

<span class="hljs-keyword">const</span> Button: React.FC&lt;ButtonProps&gt; = <span class="hljs-function">(<span class="hljs-params">{ onClick }</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> onClick('Button clicked!')}&gt;
      Click Me
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Button;
</code></pre>
<p>In this example, the <code>onClick</code> <strong>function prop</strong> takes a <code>string</code> argument and returns <code>void</code>. When the button is clicked, the <code>onClick</code> function is invoked with the message "Button clicked!".</p>
<p>When we use this <code>Button</code> component, we need to pass a function that matches the expected signature:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">import</span> Button <span class="hljs-keyword">from</span> <span class="hljs-string">'./Button'</span>;

<span class="hljs-keyword">const</span> App: React.FC = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">const</span> handleClick = <span class="hljs-function">(<span class="hljs-params">message: string</span>) =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(message);
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{handleClick}</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>Here, <code>handleClick</code> is passed as a prop to the <code>Button</code> component. Since <code>handleClick</code> matches the expected function signature, TypeScript ensures type safety.</p>
<h2 id="heading-handling-optional-function-props">Handling Optional Function Props</h2>
<p>If a <strong>function prop is optional</strong>, we can add a question mark (<code>?</code>) to make it optional in the type definition:</p>
<pre><code class="lang-javascript">type ButtonProps = {
  onClick?: <span class="hljs-function">(<span class="hljs-params">message: string</span>) =&gt;</span> <span class="hljs-keyword">void</span>;
};
</code></pre>
<p>In the component, you would then check if the function exists before calling it:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> Button: React.FC&lt;ButtonProps&gt; = <span class="hljs-function">(<span class="hljs-params">{ onClick }</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> onClick?.('Button clicked!')}&gt;
      Click Me
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  );
};
</code></pre>
<p>This ensures that <code>onClick</code> is only invoked if it has been provided.</p>
<h2 id="heading-example-with-multiple-function-props">Example with Multiple Function Props</h2>
<p>If our component requires multiple functions as props, we can define them all in the props type:</p>
<pre><code class="lang-javascript">type ModalProps = {
  <span class="hljs-attr">onClose</span>: <span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">void</span>;
  onConfirm: <span class="hljs-function">(<span class="hljs-params">confirmed: boolean</span>) =&gt;</span> <span class="hljs-keyword">void</span>;
};

<span class="hljs-keyword">const</span> Modal: React.FC&lt;ModalProps&gt; = <span class="hljs-function">(<span class="hljs-params">{ onClose, onConfirm }</span>) =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> onConfirm(true)}&gt;Confirm<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{onClose}</span>&gt;</span>Close<span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
};
</code></pre>
<p>In this example, <code>Modal</code> accepts two functions: <code>onClose</code>, which takes no parameters and returns <code>void</code>, and <code>onConfirm</code>, which takes a <code>boolean</code> and returns <code>void</code>.</p>
<p>By carefully typing function props, we enhance the maintainability and reliability of our React components, catching potential errors early during development.</p>
<h1 id="heading-working-with-state">Working with State</h1>
<p>When working with state in React using TypeScript, we can leverage TypeScript's type system to ensure that our state is well-defined and type-safe.</p>
<h2 id="heading-defining-the-state-type"><strong>Defining the State Type</strong></h2>
<p>First, we need to define the type of data that our state will hold. Depending on the complexity of our state, this could be a primitive type (like a string or number), an array, an object, or even a more complex structure like a union type.</p>
<p>For example, if our state is a simple string:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> [todo, setTodo] = useState&lt;string&gt;(<span class="hljs-string">""</span>);
</code></pre>
<p>If our state is an array of objects:</p>
<pre><code class="lang-javascript">type Todo = {
  <span class="hljs-attr">id</span>: string;
  text: string;
  completed: boolean;
};

<span class="hljs-keyword">const</span> [todos, setTodos] = useState&lt;Todo[]&gt;([]);
</code></pre>
<h2 id="heading-using-usestate-with-type-inference"><strong>Using</strong> <code>useState</code> with Type Inference</h2>
<p>TypeScript often infers the type based on the initial state value. For instance:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> [count, setCount] = useState(<span class="hljs-number">0</span>); <span class="hljs-comment">// TypeScript infers count is a number</span>
</code></pre>
<p>However, if our state starts with <code>null</code> or an empty array, TypeScript may infer it as <code>null</code> or <code>never[]</code>, which isn't always what we want. In such cases, we should explicitly provide the type.</p>
<h2 id="heading-handling-complex-state"><strong>Handling Complex State</strong></h2>
<p>For more complex state shapes, like objects or arrays, we might want to define a specific type for the state:</p>
<pre><code class="lang-javascript">type FormState = {
  <span class="hljs-attr">name</span>: string;
  email: string;
  age: number;
};

<span class="hljs-keyword">const</span> [formState, setFormState] = useState&lt;FormState&gt;({
  <span class="hljs-attr">name</span>: <span class="hljs-string">""</span>,
  <span class="hljs-attr">email</span>: <span class="hljs-string">""</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">0</span>,
});
</code></pre>
<p>In this example, we ensure that <code>formState</code> has a well-defined shape, and any updates to it must conform to this structure.</p>
<h2 id="heading-optional-state-and-union-types"><strong>Optional State and Union Types</strong></h2>
<p>Sometimes our state might be optional or can hold different types. We can use union types or <code>null</code> to represent such cases:</p>
<pre><code class="lang-javascript">type User = {
  <span class="hljs-attr">id</span>: string;
  name: string;
};

<span class="hljs-keyword">const</span> [user, setUser] = useState&lt;User | <span class="hljs-literal">null</span>&gt;(<span class="hljs-literal">null</span>);
</code></pre>
<p>In this example, <code>user</code> can either be a <code>User</code> object or <code>null</code>. This is useful when dealing with data that might not be immediately available, like user data fetched from an API.</p>
<h2 id="heading-handling-state-changes-with-type-safety"><strong>Handling State Changes with Type Safety</strong></h2>
<p>Using TypeScript, we can ensure that our state updates are type-safe. This prevents common mistakes like trying to update the state with an incompatible type.</p>
<p>For example, trying to update the <code>formState</code> with an incompatible type would result in a TypeScript error:</p>
<pre><code class="lang-javascript">type FormState = {
  <span class="hljs-attr">name</span>: string;
  email: string;
  age: number;
};

<span class="hljs-keyword">const</span> [formState, setFormState] = useState&lt;FormState&gt;({
  <span class="hljs-attr">name</span>: <span class="hljs-string">""</span>,
  <span class="hljs-attr">email</span>: <span class="hljs-string">""</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">0</span>,
});

setFormState({ <span class="hljs-attr">name</span>: <span class="hljs-string">"New Name"</span>, <span class="hljs-attr">email</span>: <span class="hljs-string">"new@example.com"</span> }); <span class="hljs-comment">// Error: age is missing</span>
</code></pre>
<h1 id="heading-working-with-context">Working with Context</h1>
<p>Using React's Context API with TypeScript allows us to define the types of data that the context will hold and ensures type safety across our components. Let’s see next how we can effectively use Context in React with TypeScript.</p>
<h2 id="heading-creating-a-context-with-typescript"><strong>Creating a Context with TypeScript</strong></h2>
<p>When creating a context, we first define the type for the context value. For example, let's say we are working with a theme context:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Step 1: Define the type for the context value</span>
type ThemeContextType = {
  <span class="hljs-attr">theme</span>: string;
  toggleTheme: <span class="hljs-function">() =&gt;</span> <span class="hljs-keyword">void</span>;
};

<span class="hljs-comment">// Step 2: Create the context with a default value</span>
<span class="hljs-keyword">const</span> ThemeContext = React.createContext&lt;ThemeContextType | <span class="hljs-literal">undefined</span>&gt;(<span class="hljs-literal">undefined</span>);
</code></pre>
<h2 id="heading-providing-the-context"><strong>Providing the Context</strong></h2>
<p>Next, we create a provider component that will supply the context value to its child components:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Step 3: Create the provider component</span>
<span class="hljs-keyword">const</span> ThemeProvider: React.FC&lt;{ <span class="hljs-attr">children</span>: React.ReactNode }&gt; = <span class="hljs-function">(<span class="hljs-params">{ children }</span>) =&gt;</span> {
  <span class="hljs-keyword">const</span> [theme, setTheme] = React.useState(<span class="hljs-string">"light"</span>);

  <span class="hljs-keyword">const</span> toggleTheme = <span class="hljs-function">() =&gt;</span> {
    setTheme(<span class="hljs-function">(<span class="hljs-params">prevTheme</span>) =&gt;</span> (prevTheme === <span class="hljs-string">"light"</span> ? <span class="hljs-string">"dark"</span> : <span class="hljs-string">"light"</span>));
  };

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ThemeContext.Provider</span> <span class="hljs-attr">value</span>=<span class="hljs-string">{{</span> <span class="hljs-attr">theme</span>, <span class="hljs-attr">toggleTheme</span> }}&gt;</span>
      {children}
    <span class="hljs-tag">&lt;/<span class="hljs-name">ThemeContext.Provider</span>&gt;</span></span>
  );
};
</code></pre>
<h2 id="heading-consuming-the-context"><strong>Consuming the Context</strong></h2>
<p>To use the context value in a component, we can use the <code>useContext</code> hook. TypeScript will automatically infer the type of the context value:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React, { useContext } <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;

<span class="hljs-keyword">const</span> ThemeToggleButton: React.FC = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// Step 4: Consume the context value</span>
  <span class="hljs-keyword">const</span> themeContext = useContext(ThemeContext);

  <span class="hljs-comment">// TypeScript ensures that themeContext is not undefined</span>
  <span class="hljs-keyword">if</span> (!themeContext) {
    <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Error</span>(<span class="hljs-string">"ThemeToggleButton must be used within a ThemeProvider"</span>);
  }

  <span class="hljs-keyword">const</span> { theme, toggleTheme } = themeContext;

  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{toggleTheme}</span>&gt;</span>
      Current Theme: {theme}
    <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span></span>
  );
};
</code></pre>
<h2 id="heading-handling-undefined-context"><strong>Handling Undefined Context</strong></h2>
<p>In the example above, we handle the case where the context might be <code>undefined</code>. This can happen if a component tries to consume the context without being wrapped by the provider. TypeScript's strict null checks will help catch these potential issues.</p>
<p>Alternatively, we can provide a default context value instead of <code>undefined</code> to avoid this check:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> defaultContextValue: ThemeContextType = {
  <span class="hljs-attr">theme</span>: <span class="hljs-string">"light"</span>,
  <span class="hljs-attr">toggleTheme</span>: <span class="hljs-function">() =&gt;</span> {},
};

<span class="hljs-keyword">const</span> ThemeContext = React.createContext&lt;ThemeContextType&gt;(defaultContextValue);
</code></pre>
<h2 id="heading-using-context-in-a-larger-application"><strong>Using Context in a Larger Application</strong></h2>
<p>To integrate this into a larger application, we would wrap our application (or a portion of it) with the <code>ThemeProvider</code>, as we normally do when working with the Context API:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">"react"</span>;
<span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">"react-dom"</span>;
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">"./App"</span>;

ReactDOM.render(
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">ThemeProvider</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">ThemeProvider</span>&gt;</span></span>,
  <span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">"root"</span>)
);
</code></pre>
<p>Inside <code>App</code>, any component that needs access to the theme can use the <code>useContext</code> hook as shown above.</p>
<h1 id="heading-configuring-typescript-tsconfigjson">Configuring TypeScript: <code>tsconfig.json</code></h1>
<p>Let’s now finish by discussing the <code>tsconfig.json</code> configuration file.</p>
<p>The <code>tsconfig.json</code> file is a configuration file for the TypeScript <strong>compiler</strong>. It specifies the root files and the compiler options required to compile a TypeScript project. Let's break down the following <code>tsconfig.json</code> example:</p>
<pre><code class="lang-json">{
  <span class="hljs-attr">"compilerOptions"</span>: {
    <span class="hljs-attr">"target"</span>: <span class="hljs-string">"ES2020"</span>,
    <span class="hljs-attr">"useDefineForClassFields"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"lib"</span>: [<span class="hljs-string">"ES2020"</span>, <span class="hljs-string">"DOM"</span>, <span class="hljs-string">"DOM.Iterable"</span>],
    <span class="hljs-attr">"module"</span>: <span class="hljs-string">"ESNext"</span>,
    <span class="hljs-attr">"skipLibCheck"</span>: <span class="hljs-literal">true</span>,

    <span class="hljs-comment">/* Bundler mode */</span>
    <span class="hljs-attr">"moduleResolution"</span>: <span class="hljs-string">"bundler"</span>,
    <span class="hljs-attr">"allowImportingTsExtensions"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"isolatedModules"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"moduleDetection"</span>: <span class="hljs-string">"force"</span>,
    <span class="hljs-attr">"noEmit"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"jsx"</span>: <span class="hljs-string">"react-jsx"</span>,

    <span class="hljs-comment">/* Linting */</span>
    <span class="hljs-attr">"strict"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"noUnusedLocals"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"noUnusedParameters"</span>: <span class="hljs-literal">true</span>,
    <span class="hljs-attr">"noFallthroughCasesInSwitch"</span>: <span class="hljs-literal">true</span>
  },
  <span class="hljs-attr">"include"</span>: [<span class="hljs-string">"src"</span>]
}
</code></pre>
<h2 id="heading-general-settings"><strong>General Settings</strong></h2>
<ol>
<li><p><code>compilerOptions</code>:</p>
<ul>
<li>This section contains various options that control how the TypeScript compiler (tsc) behaves.</li>
</ul>
</li>
<li><p><code>target</code>:</p>
<ul>
<li><code>"target": "ES2020"</code> specifies the target JavaScript version for the compiled output. Here, <code>ES2020</code> is used, meaning the TypeScript code will be compiled to be compatible with ES2020 features.</li>
</ul>
</li>
<li><p><code>useDefineForClassFields</code>:</p>
<ul>
<li><code>"useDefineForClassFields": true</code> instructs the compiler to use the <code>define</code> behavior for class fields, which aligns with the latest ECMAScript standard for how class fields are initialized.</li>
</ul>
</li>
<li><p><code>lib</code>:</p>
<ul>
<li><p><code>"lib": ["ES2020", "DOM", "DOM.Iterable"]</code> defines the libraries to be included in the compilation.</p>
<ul>
<li><p><code>ES2020</code> provides the ES2020 standard library.</p>
</li>
<li><p><code>DOM</code> includes the standard DOM types, which are necessary for web development.</p>
</li>
<li><p><code>DOM.Iterable</code> adds support for DOM types that are iterable, like <code>NodeList</code>.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><code>module</code>:</p>
<ul>
<li><code>"module": "ESNext"</code> sets the module system for the output to <code>ESNext</code>, which supports the latest ECMAScript module syntax. This is often used with modern JavaScript bundlers that can handle ES modules.</li>
</ul>
</li>
<li><p><code>skipLibCheck</code>:</p>
<ul>
<li><code>"skipLibCheck": true</code> disables type checking for all declaration files (<code>.d.ts</code> files). This can speed up the compilation process but might hide some potential type issues.</li>
</ul>
</li>
</ol>
<h2 id="heading-bundler-mode-settings"><strong>Bundler Mode Settings</strong></h2>
<ol>
<li><p><code>moduleResolution</code>:</p>
<ul>
<li><code>"moduleResolution": "bundler"</code> adjusts how modules are resolved. This is optimized for bundlers like Webpack or Vite that manage module imports differently than Node.js or TypeScript’s default resolution strategy.</li>
</ul>
</li>
<li><p><code>allowImportingTsExtensions</code>:</p>
<ul>
<li><code>"allowImportingTsExtensions": true</code> allows importing TypeScript files (<code>.ts</code> and <code>.tsx</code>) with their extensions in the import statements, which is often necessary when working with bundlers.</li>
</ul>
</li>
<li><p><code>isolatedModules</code>:</p>
<ul>
<li><code>"isolatedModules": true</code> ensures that each file is treated as a separate module. This is essential when using a bundler or tools like Babel to transpile TypeScript.</li>
</ul>
</li>
<li><p><code>moduleDetection</code>:</p>
<ul>
<li><code>"moduleDetection": "force"</code> forces the detection of modules even in files that don’t have explicit imports or exports, ensuring that all files are treated as modules.</li>
</ul>
</li>
<li><p><code>noEmit</code>:</p>
<ul>
<li><code>"noEmit": true</code> prevents TypeScript from emitting any output files. This is useful in scenarios where TypeScript is used solely for type checking, and the actual JavaScript code is handled by a bundler.</li>
</ul>
</li>
<li><p><code>jsx</code>:</p>
<ul>
<li><code>"jsx": "react-jsx"</code> specifies how JSX syntax should be transformed. <code>react-jsx</code> refers to the modern JSX runtime introduced in React 17, which does not require <code>import React from 'react'</code> at the top of files that use JSX.</li>
</ul>
</li>
</ol>
<h2 id="heading-linting-options"><strong>Linting Options</strong></h2>
<ol>
<li><p><code>strict</code>:</p>
<ul>
<li><code>"strict": true</code> enables strict type-checking options, which includes several flags that make TypeScript's type system more robust and error-prone. This is the recommended setting for most projects to catch potential issues early.</li>
</ul>
</li>
<li><p><code>noUnusedLocals</code>:</p>
<ul>
<li><code>"noUnusedLocals": true</code> raises an error when local variables are declared but never used, helping to keep the codebase clean and free of unnecessary variables.</li>
</ul>
</li>
<li><p><code>noUnusedParameters</code>:</p>
<ul>
<li><code>"noUnusedParameters": true</code> raises an error if a function parameter is declared but never used. This can help identify unused or unnecessary parameters in functions.</li>
</ul>
</li>
<li><p><code>noFallthroughCasesInSwitch</code>:</p>
<ul>
<li><code>"noFallthroughCasesInSwitch": true</code> prevents unintentional fall-through in <code>switch</code> statements, where the execution moves to the next case if a <code>break</code> statement is missing. This reduces potential bugs in <code>switch</code> statements.</li>
</ul>
</li>
</ol>
<h2 id="heading-the-include-options"><strong>The</strong> <code>include</code> Options</h2>
<ol>
<li><p><code>include</code>:</p>
<ul>
<li><code>"include": ["src"]</code> specifies the files or directories that should be included in the TypeScript compilation. Here, it’s set to include all files within the <code>src</code> directory.</li>
</ul>
</li>
</ol>
<h1 id="heading-final-words">Final Words</h1>
<p>Integrating TypeScript with React offers a powerful combination that enhances code quality, reduces runtime errors, and makes our applications more scalable. By leveraging TypeScript’s type system, we gain better insights into our codebase, which helps us catch potential issues early during development. Throughout this article, we've explored the benefits of using TypeScript in React projects, including type safety, improved tooling, and enhanced developer experience.</p>
<p>Whether we're building small components or large, complex applications, TypeScript ensures that our code remains robust and maintainable. As we become more comfortable using TypeScript with React, we can start to explore advanced patterns like generics, utility types, and type guards, further improving the flexibility and safety of our applications.</p>
<p>With these tools at our disposal, we can confidently build modern, reliable React applications that stand the test of time. So, let's start embracing TypeScript in our React projects and unlock its full potential today.</p>
<p>See you in the next one! 🖖</p>
]]></content:encoded></item><item><title><![CDATA[How to Choose Between Front-End and Full-Stack Web Development]]></title><description><![CDATA[As a software developer, one of the key decisions you'll face in your career is whether to specialize in front-end development or pursue a full-stack role. Both paths offer unique opportunities and challenges, and the right choice depends on your int...]]></description><link>https://blog.damiandemasi.com/how-to-choose-between-front-end-and-full-stack-web-development</link><guid isPermaLink="true">https://blog.damiandemasi.com/how-to-choose-between-front-end-and-full-stack-web-development</guid><category><![CDATA[Frontend Development]]></category><category><![CDATA[Full Stack Development]]></category><category><![CDATA[full stack]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Mon, 22 Jul 2024 23:25:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1721690602685/c0f03694-7b84-46f9-8af6-bb6040f5e99d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>As a software developer, one of the key decisions you'll face in your career is whether to specialize in front-end development or pursue a full-stack role. Both paths offer unique opportunities and challenges, and the right choice depends on your interests, skills, and career goals. Let's explore the key differences between these two roles to help you make an informed decision. </p>
<h1 id="heading-front-end-development-crafting-user-experiences">Front-End Development: Crafting User Experiences</h1>
<h2 id="heading-front-end-development-in-a-nutshell">Front-End Development in a Nutshell</h2>
<p>Front-end developers are specialists who focus on creating the user-facing aspects of websites and applications. If you enjoy working with designs, visual elements, and have a keen eye for user experience, front-end development might be your calling.</p>
<h3 id="heading-pros-of-front-end-development">Pros of Front-End Development</h3>
<ol>
<li><p>Direct impact on user experience</p>
</li>
<li><p>Opportunity to express creativity and innovation</p>
</li>
<li><p>Specialization in a focused set of technologies</p>
</li>
<li><p>High demand in larger companies</p>
</li>
</ol>
<h3 id="heading-cons-of-front-end-development">Cons of Front-End Development</h3>
<ol>
<li><p>Narrow focus might limit versatility</p>
</li>
<li><p>Complex and sometimes messy technology landscape</p>
</li>
<li><p>Limited exposure to back-end technologies</p>
</li>
</ol>
<h2 id="heading-going-deeper-into-front-end-development">Going Deeper into Front-End Development</h2>
<p>Front-end developers are the architects of the digital user experience. They specialize in creating the visual and interactive elements of websites and applications that users directly engage with. If you have a passion for design, user interaction, and creating seamless digital experiences, front-end development might be your ideal path.</p>
<h3 id="heading-key-responsibilities">Key Responsibilities</h3>
<ul>
<li><p>Building complex user interfaces</p>
</li>
<li><p>Enhancing user experience (UX)</p>
</li>
<li><p>Ensuring accessibility for all users</p>
</li>
<li><p>Developing responsive designs for various devices</p>
</li>
<li><p>Implementing (asynchronous) interactivity</p>
</li>
</ul>
<p>Technologies and Skills: Front-end developers typically work with a core set of technologies, including HTML, CSS, and JavaScript. However, the field is constantly evolving, with new frameworks and libraries emerging regularly. Some popular front-end technologies include React, Vue.js, Angular, and CSS preprocessors like SASS.</p>
<h3 id="heading-why-choose-front-end-development">Why Choose Front-End Development</h3>
<ul>
<li><p>Creative Expression: Front-end development offers significant opportunities for creativity. You'll work closely with designers to bring visual concepts to life and have the freedom to innovate in how users interact with digital products.</p>
</li>
<li><p>Immediate Visual Impact: One of the most satisfying aspects of front-end work is seeing your code translate directly into visual elements that users interact with. This immediate feedback can be highly rewarding.</p>
</li>
<li><p>Focus on User-Centric Design: If you're passionate about creating intuitive, accessible, and enjoyable user experiences, front-end development allows you to directly influence these aspects.</p>
</li>
<li><p>Specialization: By focusing on front-end technologies, you can become a true expert in your field. This specialization can make you highly valuable, especially in larger companies where roles tend to be more clearly defined.</p>
</li>
<li><p>High Demand: With the increasing emphasis on user experience in the digital world, skilled front-end developers are in high demand, particularly in established companies with complex products.</p>
</li>
</ul>
<h3 id="heading-challenges-to-consider">Challenges to Consider</h3>
<ul>
<li><p>Rapidly Changing Landscape: Front-end technologies evolve quickly. Staying up-to-date requires continuous learning and adaptation.</p>
</li>
<li><p>Browser Compatibility: Ensuring consistent experiences across different browsers and devices can be challenging and sometimes frustrating.</p>
</li>
<li><p>Performance Optimization: With the growing complexity of front-end applications, optimizing for performance becomes increasingly important and challenging.</p>
</li>
<li><p>Collaboration: Front-end developers often need to work closely with designers, back-end developers, and other stakeholders, requiring strong communication skills.</p>
</li>
</ul>
<h3 id="heading-career-growth">Career Growth</h3>
<p>As you progress in your front-end career, you might specialize further in areas like performance optimization, animation, or accessibility. You could also move into roles like UI/UX designer, front-end architect, or even transition into full-stack development if you decide to broaden your skill set.</p>
<h2 id="heading-is-front-end-development-right-for-you">Is Front-End Development Right for You?</h2>
<p>Consider front-end development if you:</p>
<ul>
<li><p>Enjoy working on visual and interactive elements</p>
</li>
<li><p>Have a keen eye for design and user experience</p>
</li>
<li><p>Are comfortable with continuous learning to keep up with new technologies</p>
</li>
<li><p>Want to specialize and become an expert in a focused area of web development</p>
</li>
<li><p>Thrive on seeing the immediate results of your work</p>
</li>
</ul>
<p>Remember, while front-end development offers a clear specialization, it's still a diverse field with plenty of room for growth and exploration. The key is to align your choice with your interests, strengths, and long-term career aspirations.</p>
<h1 id="heading-full-stack-development-bridging-the-gap">Full-Stack Development: Bridging the Gap</h1>
<h2 id="heading-full-stack-development-in-a-nutshell">Full-Stack Development in a Nutshell</h2>
<p>Full-stack developers are the jack-of-all-trades in the web development world. They work across the entire application stack, from the user interface to the server-side logic and databases.</p>
<h3 id="heading-pros-of-full-stack-development">Pros of Full-Stack Development</h3>
<ol>
<li><p>Versatility and broader skill set</p>
</li>
<li><p>Ability to build complete projects from scratch</p>
</li>
<li><p>Larger job market in most technology stacks</p>
</li>
<li><p>Valuable for startups and small teams</p>
</li>
</ol>
<h3 id="heading-cons-of-full-stack-development">Cons of Full-Stack Development</h3>
<ol>
<li><p>Risk of being spread too thin across multiple domains</p>
</li>
<li><p>Challenges in time management and staying updated</p>
</li>
<li><p>Potential for slower specialization and career progression</p>
</li>
</ol>
<h2 id="heading-going-deeper-into-full-stack-development">Going deeper into full-stack development</h2>
<p>Full-stack developers are the versatile problem-solvers of the web development world. They possess the skills to work on both the client-side and server-side of web applications, effectively bridging the gap between front-end and back-end technologies. If you enjoy tackling diverse challenges and want a comprehensive understanding of web development, the full-stack path might be your ideal choice.</p>
<h3 id="heading-key-responsibilities-1">Key Responsibilities</h3>
<ul>
<li><p>Developing both client-side and server-side components</p>
</li>
<li><p>Designing and managing databases</p>
</li>
<li><p>Implementing business logic</p>
</li>
<li><p>Handling DevOps tasks</p>
</li>
<li><p>Creating and consuming APIs</p>
</li>
<li><p>Ensuring seamless integration between front-end and back-end systems</p>
</li>
</ul>
<p>Technologies and Skills: Full-stack developers work with a wide array of technologies. On the front-end, they use HTML, CSS, and JavaScript, often with frameworks like React or Angular. On the back-end, they might work with languages like Python, Ruby, Java, or Node.js, and frameworks such as Django, Ruby on Rails, or Express. Database management (SQL and NoSQL) and version control systems are also crucial skills.</p>
<h3 id="heading-why-choose-full-stack-development">Why Choose Full-Stack Development</h3>
<ul>
<li><p>Versatility: As a full-stack developer, you'll have the ability to work on all aspects of a web application. This versatility can make you invaluable to smaller teams and startups.</p>
</li>
<li><p>Comprehensive Understanding: Full-stack development provides a holistic view of web applications, allowing you to understand how different components interact and influence each other.</p>
</li>
<li><p>Problem-Solving Opportunities: With knowledge spanning the entire stack, you're well-positioned to troubleshoot complex issues and optimize overall application performance.</p>
</li>
<li><p>Project Ownership: Full-stack skills enable you to build complete projects from the ground up, which can be particularly satisfying for personal projects or when working in small teams.</p>
</li>
<li><p>Broader Job Market: Many companies, especially startups and scale-ups, value the flexibility that full-stack developers bring to their teams.</p>
</li>
</ul>
<h3 id="heading-challenges-to-consider-1">Challenges to Consider</h3>
<ul>
<li><p>Breadth vs. Depth: As a full-stack developer, you'll need to balance having a broad knowledge base with developing deep expertise in specific areas.</p>
</li>
<li><p>Keeping Up with Multiple Domains: Staying current with both front-end and back-end technologies can be time-consuming and challenging.</p>
</li>
<li><p>Time Management: Juggling responsibilities across different areas of an application requires strong time management and prioritization skills.</p>
</li>
<li><p>Potential for Overwhelming: The vast scope of knowledge required can sometimes feel overwhelming, especially for those new to the field.</p>
</li>
</ul>
<h3 id="heading-career-growth-1">Career Growth</h3>
<p>As a full-stack developer, your career path can be quite flexible. You might choose to specialize in a particular stack (e.g., MEAN or LAMP), transition into a technical lead or architect role, or even move into project management. The broad skill set you develop can also be a stepping stone to more specialized roles if you discover a particular area you're passionate about.</p>
<h2 id="heading-is-full-stack-development-right-for-you">Is Full-Stack Development Right for You?</h2>
<p>Consider full-stack development if you:</p>
<ul>
<li><p>Enjoy working on diverse challenges and learning new technologies</p>
</li>
<li><p>Want to understand how web applications work from end to end</p>
</li>
<li><p>Are interested in building complete projects independently</p>
</li>
<li><p>Thrive in dynamic environments where you wear multiple hats</p>
</li>
<li><p>Have strong problem-solving skills and enjoy optimization across different layers of an application</p>
</li>
</ul>
<p>Remember that while full-stack development offers great versatility, it also requires a commitment to continuous learning across a broader range of technologies. The key is to find the right balance between breadth and depth that aligns with your career goals and the needs of your potential employers or projects.</p>
<p>Full-stack development can be an excellent choice for those who want to maximize their versatility in the job market and gain a comprehensive understanding of web development. However, it's important to be prepared for the challenges that come with maintaining such a broad skill set.</p>
<h1 id="heading-making-your-choice">Making Your Choice</h1>
<p>To decide between front-end and full-stack development, consider the following:</p>
<ol>
<li><p>Personal interests: Do you enjoy visual design and user interaction, or are you more excited by complex problem-solving across the entire application?</p>
</li>
<li><p>Career goals: Are you aiming for specialization in a large company, or do you want the versatility to work in startups or on personal projects?</p>
</li>
<li><p>Learning style: Are you comfortable diving deep into a specific area, or do you prefer a broader understanding of multiple technologies?</p>
</li>
<li><p>Job market: Research the demand for both roles in your target industry and location.</p>
</li>
<li><p>Long-term vision: Consider how each path aligns with your long-term career aspirations and the type of projects you want to work on.</p>
</li>
</ol>
<p>Remember, there's no one-size-fits-all answer. Many developers start in one area and transition to the other as their careers progress. The key is to choose the path that aligns best with your passions and goals.</p>
<p>Whichever path you choose, continuous learning and adaptability will be crucial in the ever-evolving world of web development. Whether you decide to specialize in crafting beautiful user interfaces or tackle the full spectrum of web applications, your journey in software development promises to be exciting and rewarding.</p>
]]></content:encoded></item><item><title><![CDATA[How to Learn Python Faster and Easier with This Notion Template]]></title><description><![CDATA[Do you want to learn Python or improve your skills in this popular programming language? If so, you might be interested in the Python for Everybody Specialization course on Coursera. It’s a great way to master the basics of Python and explore its app...]]></description><link>https://blog.damiandemasi.com/how-to-learn-python-faster-and-easier-with-this-notion-template</link><guid isPermaLink="true">https://blog.damiandemasi.com/how-to-learn-python-faster-and-easier-with-this-notion-template</guid><category><![CDATA[Python]]></category><category><![CDATA[learning]]></category><category><![CDATA[newbie]]></category><category><![CDATA[Python 3]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 14 Feb 2024 19:00:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901583027/8ccc6eda-b52b-477a-a0f8-6db818115c14.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Do you want to learn Python or improve your skills in this popular programming language? If so, you might be interested in the <a target="_blank" href="https://www.coursera.org/specializations/python">Python for Everybody Specialization course on Coursera</a>. It’s a great way to master the basics of Python and explore its applications in data analysis, web development, and more.</p>
<h2 id="heading-python-notes-template">Python Notes Template</h2>
<p>But what if you need some extra help or guidance along the way? Don’t worry, I’ve got you covered. I have created a <strong>Notion template</strong> that contains all the notes I made while doing the <a target="_blank" href="https://www.coursera.org/specializations/python">Python for Everybody Specialization</a> course (80 different topics, to be exact 😅). These notes are clear, concise, and easy to follow. You can use them to <strong>support your learning journey in Python</strong> or as a <strong>standalone reference</strong> to understand Python concepts better.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901633284/b0338594-b079-400e-8d1e-73a6665d1f73.png" alt /></p>
<p>Sounds good? Then download the <strong>free</strong> template from <a target="_blank" href="https://www.devnotes.to/templates/python-notes">this link</a> and let me show you how to access and use these notes.</p>
<p>First, you need to click on the “Python Notes” page in the main “Python Notes” template. This will take you to the Python Notes database, where you can find all the information you need.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901660674/18513cd5-64d3-479e-a506-ef0b7a506deb.png" alt /></p>
<p>The Python Notes template database has different views that you can switch between depending on your preferences and goals.</p>
<h3 id="heading-topics">Topics</h3>
<p>This is the default view, showing an ordered list of cards. These cards have my notes on each of the 80 topics covered in the course. It’s best to access them in the order they appear so you can build your knowledge step by step, in order.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901670627/c337e5ec-b188-4594-860b-8e64ac8aaa99.png" alt /></p>
<p>When you click on a card, you’ll find a note explaining the concepts covered in a specific class.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901678776/abbfd328-4cef-4d60-8297-c23c4b76c22f.png" alt /></p>
<p>At the bottom of the note, you’ll see a list of references in the form of cards. These references usually point to the class where the concept in the note was explained and other resources that can help you learn more about that specific concept.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901686005/fc5b2f21-15b2-43ca-bae7-708c41580852.png" alt /></p>
<h3 id="heading-topic-by-area">Topic by Area</h3>
<p>This view shows the list of topics conveniently organised by area of knowledge, such as variables, functions, loops, files, etc. You can use this view to focus on a specific area or review what you have learned.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901696596/8ecbdfd0-3d2a-4beb-8126-e2a1f7206778.png" alt /></p>
<h3 id="heading-study-progress">Study Progress</h3>
<p>This view helps you track your learning progress and stay motivated. Here, you can move cards across the “Not Started,” “In Progress,” and “Done” columns, showing the step each Python topic has reached in your learning journey.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901705542/0aababba-d2c7-453f-9bd6-d10bbf40c303.png" alt /></p>
<h3 id="heading-topics-table">Topics Table</h3>
<p>This view provides a detailed view of how the notes are organized and their properties. This view is useful for creating new notes, editing their properties, and managing the overall composition of the Python Notes database.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901711899/2d5a76f5-9ed4-42f2-98d6-7ee961b00391.png" alt /></p>
<p>That’s it! You’re ready to use the Python Notes template and boost your Python skills. I hope you find it useful and enjoyable. If you have any questions or feedback, feel free to leave a comment or <a target="_blank" href="https://twitter.com/DamianDemasi">contact me</a>.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Download the template <a target="_blank" href="https://www.devnotes.to/templates/python-notes">by clicking here</a>.</div>
</div>

<hr />
<h2 id="heading-advanced-template">Advanced Template</h2>
<p>But... what if you want to go <strong>deeper</strong> into your learning journey? 🤔 Well, then you can get the advanced version of the Python Notes template! The <strong>Python Notes and Questions</strong> advanced template expands on the 80 topics offered in the free version with <strong>375 related questions</strong> and two game-changing techniques: <strong>spaced repetition</strong> and <strong>interleaving learning</strong>. This template is not free but, trust me, it's worth every dollar you pay for it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901744312/439db881-6aa3-4494-b065-714f28f916f3.png" alt /></p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Get the <a target="_blank" href="https://www.devnotes.to/templates/python-notes-and-questions">advanced Python Notes and Questions template here</a>!</div>
</div>

<h3 id="heading-why-questions">Why Questions?</h3>
<p>Do you want to learn more effectively and efficiently? If so, you should try answering questions about what you are studying. Answering questions is crucial for learning, especially when you use the spaced repetition technique. Let me explain why.</p>
<p>When you respond to questions about a topic, you're <strong>recalling information</strong> from your memory to form an answer. This practice of recalling helps you remember and reinforces your understanding of the topic, making it easier to grasp the information. It also helps you identify any gaps in your knowledge that you need to fill.</p>
<p>This Python Notes and Questions template implements two techniques to help you better grasp the concepts you are learning:</p>
<ul>
<li><p>Spaced Repetition, and</p>
</li>
<li><p>Interleaving learning</p>
</li>
</ul>
<p>Let's see how these techniques work and why they are useful.</p>
<h3 id="heading-spaced-repetition">Spaced Repetition</h3>
<p>When you are trying to learn a new subject, such as Python programming, you might be tempted to read a book or watch a video course and try to learn everything in one go. However, this is not the most effective way to truly understand a subject. Research shows that you will forget most of what you learned after a short time, unless you review it periodically.</p>
<p>The most effective way to learn and remember something is to use <strong>spaced repetition</strong>. This means going back to review the material over time, at intervals that are based on how well you remember it. When you answer questions about a topic at different times, it helps your memory. It's like giving your brain a friendly reminder about the important details right when you might be starting to forget them.</p>
<p>The following image shows how spaced repetition works. The red line represents how much you remember over time if you review the material just once. The green lines represent how much you retain when you review the material periodically. As you can see, each time you review, you remember more and forget less. This way, you can achieve long-term retention of the information.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901755624/a98fc2f7-1753-49f2-b38c-6511ce8f6324.png" alt class="image--center mx-auto" /></p>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Spaced_repetition"><em>Source of image</em></a></p>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Spaced_repetition">Spaced repetition</a> is a scientifically-backed learning technique (often employed with flashcards) to optimise the process of acquiring and retaining information. The underlying principle is based on the psychological phenomenon known as the "spacing effect," where the review of material is strategically spaced out over time to enhance memory retention.</p>
<h3 id="heading-interleaved-learning">Interleaved Learning</h3>
<p>Another technique that can boost your learning is interleaving, or mixing up different topics or problem types. You might think that it is easier and more efficient to focus on one topic or problem type at a time, until you master it. However, this is not the case. <a target="_blank" href="https://www.scientificamerican.com/article/the-interleaving-effect-mixing-it-up-boosts-learning/?ssp=1&amp;darkschemeovr=1&amp;setlang=en&amp;cc=AU&amp;safesearch=moderate">Studies show</a> that interleaving, or alternating between topics, can improve your learning outcomes and problem-solving skills in the long run.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901776727/0bc9714b-6fb4-401f-a5c6-6944c51d2ade.png" alt class="image--center mx-auto" /></p>
<p>Why is interleaving effective? Because it challenges your brain to switch between different kinds of information and tasks. This makes you pay more attention and think more deeply. It also helps you see the connections and differences between the topics or problems. This way, you can develop a more flexible and robust understanding of the subject.</p>
<p>Interleaving is especially useful when you are learning subjects that involve problem-solving, such as math, science, or programming. For example, if you are learning Python, instead of doing exercises on one topic, such as loops, you can mix up exercises on loops, variables, functions, and so on. This will help you apply your knowledge to different situations and avoid getting stuck in a rut.</p>
<h3 id="heading-python-notes-and-questions-template">Python Notes and Questions Template</h3>
<p>Now that you know how spaced repetition and interleaving can help you learn better, you might be wondering how to use them in practice. Well, you are in luck, because I have designed <a target="_blank" href="https://www.devnotes.to/templates/python-notes-and-questions">this Python Notes and Questions template</a> with these ideas in mind.</p>
<p>This template contains a collection of questions that cover various topics and levels of difficulty in Python programming. By answering these questions regularly, you can practice spaced repetition and interleaving, and improve your Python skills.</p>
<p>Answering questions regularly, especially with spaced repetition, in an interleaved manner, is like exercising your brain. It makes the information stick, helping you learn and remember things for a longer time.</p>
<h3 id="heading-python-questions-template-user-guide">Python Questions Template User Guide</h3>
<p>Before you start using the Questions template for the first time, you need to do one simple thing. Click on the "Reset Questions Config" button. This button will automatically set up the dates in the template to start counting from the date you begin using it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901794165/3274bbe8-5bb0-4504-bae0-ca40fc2addb5.png" alt /></p>
<p>After clicking the "Reset Questions Config" button, a confirmation pop-up will appear in case you clicked it accidentally. You can click "Continue" to confirm, or "Cancel" to go back.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901803073/2d9dda39-cff0-4714-8eb6-b3d84f223160.png" alt /></p>
<p>Once you confirm the "Reset Questions Config" button action, you're ready to start using the questions. Now, click on the "Python Questions" page.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901809975/daad8388-19c6-4331-9775-ac71bdf0ef9a.png" alt class="image--center mx-auto" /></p>
<p>The first view you'll see is the "Recall Today" view. Here, you'll find a series of cards with questions. These questions cover various topics, implementing interleaved learning.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901826676/822e46bb-ba77-4981-80cb-db00554332ae.png" alt /></p>
<p>Try answering the questions out loud, provide examples when possible, and make your own notes. After answering, click on the card containing your answer. This will reveal the correct answer, which is a summarised version of the note related to the question found on the Python Notes page of this template.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901834381/77cbbb31-13fe-40f6-a73e-3e075ef8d61b.png" alt /></p>
<p>Below the answer, you'll find the "Source" section, containing a link to the actual note related to the question.</p>
<p>You can return to the question by clicking on the button highlighted in the image below or by pressing the <code>ESC</code> key on your keyboard.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901842608/24af433e-cf66-4ab9-8f2c-2d1d5ebc051c.png" alt /></p>
<p>After checking your answer with the provided one, you'll have two possible outcomes:</p>
<ul>
<li>Your answer was <strong>incorrect</strong>: This means you need to revisit this question soon. Click the "Incorrect" button in the "Recall" section to mark the question for review again soon.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901849830/3aeba615-b380-4500-b453-037769ab90a1.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>Your answer was <strong>correct</strong>: This means you understand the question well. You'll revisit it in the future, and how far in the future will depend on the "Question Level." All questions start at level <code>0</code>. Increase their level by clicking on one of the five-level buttons in the "Recall" section:</p>
<ul>
<li><p>If the question level is <code>0</code>, and your answer is correct, click "Level 1" to increase its level,</p>
</li>
<li><p>If the question level is <code>1</code>, and your answer is correct, click "Level 2," and so on.</p>
</li>
</ul>
</li>
</ul>
<p>    As the "Question Level" increases, the time gap to revisit the question will also increase, implementing the <strong>Spaced Repetition</strong> technique.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901860238/3090e561-8291-4fe5-8d03-e918979ef89b.png" alt /></p>
<p>You can see how the questions spread over time in the "Recall Calendar" view.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901867046/17d2cb9b-8aa8-4946-9d67-248673fe4231.png" alt /></p>
<p>If you prefer to sort the questions by difficulty, use the "Questions by Difficulty" view.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901874493/62d334d3-a144-4f92-9a64-5c2f6616f871.png" alt /></p>
<p>Finally, you can view all the questions at once in the "Questions Table" view. This view is useful for performing administrative tasks on the Questions database, such as adding new questions or deleting ones you don't need.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901885333/7f3b056d-9ab4-4943-9c16-07317b7b5ddf.png" alt /></p>
<h2 id="heading-one-more-thing">One more thing</h2>
<p>If you ever find that some topics, questions, or pages are missing in any of the templates, don’t forget to look at the bottom of the page. Notion sometimes hides extra information, so you’ll need to click on “Show more” (or something similar) to reveal the rest of the items.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707901898014/34f75bd6-96e7-42b9-a535-00c53ac61684.png" alt /></p>
<h2 id="heading-closing-thoughts">Closing thoughts</h2>
<p>That's all for now! I hope you had fun reading this and that you are finding the templates I shared with you helpful for learning Python.</p>
<p>See you in the next one! 🖖</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content,</em> <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter"><em>subscribe to my newsletter</em></a><em>.</em></p>
<p>🐦 <strong>TWITTER/X -</strong> <em>Follow me on</em> <a target="_blank" href="https://twitter.com/DamianDemasi"><em>Twitter/X</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Python Project: Analysing Australia's Migration Trends and Economic Impact]]></title><description><![CDATA[Python for Everybody Capstone Project
In my recently completed Python for Everybody course, we wrapped up with a capstone project that got me diving into data exploration.
Recently, my attention was caught by discussions and news bits talking about h...]]></description><link>https://blog.damiandemasi.com/python-project-analysing-australias-migration-trends-and-economic-impact</link><guid isPermaLink="true">https://blog.damiandemasi.com/python-project-analysing-australias-migration-trends-and-economic-impact</guid><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Developer]]></category><category><![CDATA[data analysis]]></category><category><![CDATA[coding]]></category><category><![CDATA[template]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 07 Feb 2024 09:01:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1707218510491/30b39ea1-5d00-4079-b702-9c4dfff6c80d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-python-for-everybody-capstone-project">Python for Everybody Capstone Project</h2>
<p>In my recently completed Python for Everybody course, we wrapped up with a capstone project that got me diving into data exploration.</p>
<p>Recently, my attention was caught by discussions and news bits talking about how international migration shakes up Australia's job and housing scenes. So, with my curiosity fired up, I decided to dig into the data, hoping to discover connections between international migration and the trends in these markets.</p>
<p>Being an international migrant myself, I've got a personal stake in understanding how Australia's migration policies and the flow of immigrants play out in the country's economy.</p>
<p>Fortunately, Australia boasts an incredible data gold mine: the Australian Bureau of Statistics (ABS). I managed to search their data and find information about <a target="_blank" href="https://www.abs.gov.au/statistics/people/population/overseas-migration/2022-23-financial-year">Overseas Migration</a>, <a target="_blank" href="https://www.abs.gov.au/statistics/labour/employment-and-unemployment/labour-force-australia/nov-2023">Labour Force</a>, <a target="_blank" href="https://www.abs.gov.au/statistics/people/housing/housing-occupancy-and-costs/2019-20">Housing Occupancy and Costs</a>, and <a target="_blank" href="https://www.abs.gov.au/statistics/economy/price-indexes-and-inflation/total-value-dwellings/latest-release#:~:text=The%20number%20of%20residential%20dwellings%20in%20Australia%20rose%20by%2052%2C300,%2419%2C200%20to%20%24925%2C400%20this%20quarter.">Total Value of Dwellings</a>.</p>
<p>I initially intended to perform the following tasks with this data:</p>
<ul>
<li><p><strong>Database Integration:</strong> Import the data into a database for efficient querying and analysis.</p>
</li>
<li><p><strong>Visualization:</strong> Generate maps, charts, and graphs to represent migration and economic data.</p>
</li>
<li><p><strong>Economic Impact Analysis:</strong> Understand the economic impact of migration on housing and job markets.</p>
</li>
<li><p><strong>Correlation Analysis:</strong> Identify potential correlations between migration, labour force, and housing data.</p>
</li>
</ul>
<hr />
<p><em>Discover the power of knowledge! Grab my newest free Notion template, packed with detailed<strong><strong>notes on 80 specific topics</strong></strong>covered during my journey through the University of Michigan's 'Python for Everybody' course on Coursera. Ready to level up your Python skills?</em><a target="_blank" href="https://www.devnotes.to/templates/python-notes"><em>Click here now</em></a><em>!</em></p>
<p><a target="_blank" href="https://www.devnotes.to/templates/python-notes"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707218802192/c301148e-865f-4564-8bac-7ec5c19aacb9.png" alt class="image--center mx-auto" /></a></p>
<hr />
<h2 id="heading-picking-the-data-source">Picking the Data Source</h2>
<p>When I first dug into the data from the ABS, I noticed they had it neatly laid out in both MS Excel and CSV formats. Seemed like it could be pretty straightforward to handle, perhaps with a handy Python script.</p>
<p>The topics I was interested in were:</p>
<ul>
<li><p><a target="_blank" href="https://www.abs.gov.au/statistics/people/population/overseas-migration/2022-23-financial-year">Overseas Migration</a></p>
</li>
<li><p><a target="_blank" href="https://www.abs.gov.au/statistics/labour/employment-and-unemployment/labour-force-australia/nov-2023">Labour Force</a></p>
</li>
<li><p><a target="_blank" href="https://www.abs.gov.au/statistics/people/housing/housing-occupancy-and-costs/2019-20">Housing Occupancy and Costs</a></p>
</li>
<li><p><a target="_blank" href="https://www.abs.gov.au/statistics/economy/price-indexes-and-inflation/total-value-dwellings/latest-release#:~:text=The%20number%20of%20residential%20dwellings%20in%20Australia%20rose%20by%2052%2C300,%2419%2C200%20to%20%24925%2C400%20this%20quarter.">Total Value of Dwellings</a></p>
</li>
</ul>
<p>But then, I found out there was another door to this data exploration – an API provided by the ABS. This meant I could easily fetch the data using Python, push it into a database, and then dive into analysis mode. As the API provides an XML response, I could be using <code>ElementTree</code> to parse it.</p>
<p>After trying to build an API request on my own, I stumbled upon a tool that the Australian Bureau of Statistics provides to explore data called <a target="_blank" href="https://www.abs.gov.au/about/data-services/data-explorer">Stat Data Explorer</a>. What's neat about it is that it lets you visually explore the data and even generates the right API request for the info you've seen.</p>
<p>So, I ditched the idea of using the initial data from the Excel files and opted to pick out the juiciest datasets for my analysis using this cool tool.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>Note:</strong> you can take a more technical look at how I used the Stat Data Explorer and the API endpoints I got by taking a read to the <code>README.md</code> file in <a target="_blank" href="https://github.com/Colo-Codes/ossu-01-introduction-to-programming-python-for-everybody/tree/main/capstone_project">my GitHub repository</a>.</div>
</div>

<h2 id="heading-building-a-data-fetching-script">Building a Data Fetching Script</h2>
<p>I kicked things off by creating a nifty Python script called <code>data_getter.py</code> to get the data from the Australian Bureau of Statistics API. As I mentioned earlier, since the data dances in XML format, I enlisted the help of the <code>xml.etree.ElementTree</code> module to untangle its secrets 😅.</p>
<p>For the analysis, I set my sights on the period from 2011 to 2022. Why, you ask? Well, that's because the data for the number of residential dwellings is only available from 2011 onwards, and there was no migration data for 2023 at the moment of working on this project.</p>
<p>Once I processed the XML data, I tucked it neatly into an SQLite database named <code>capstone.sqlite</code>. Why SQLite? Because it's lightweight and easy to use (and the database that we have been using throughout the course).</p>
<p>After analysing it for a while, and a bit of trial and error, I came up with an Entity-Relationship Diagram (ERD) for the database that looks like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707219068503/aa1d8f52-c7ac-4a49-a436-45103646103c.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">If you are following along with the code in <a target="_blank" href="https://github.com/Colo-Codes/ossu-01-introduction-to-programming-python-for-everybody/tree/main">my repository</a>, you can test the data-fetching script by running <code>python3 data_getter.py</code> in your terminal.</div>
</div>

<h2 id="heading-building-a-data-normalization-script">Building a Data Normalization Script</h2>
<p>Once I fetched the data, I spotted a little quirk – it wasn't playing nice in terms of consistency. The count of homes came in quarters, but the job scene spilled the beans monthly. So, I decided to bring order to the chaos and normalize the data, all cosy and snug in a yearly fashion, just like our migration data.</p>
<p>It was now the turn of another Python script: <code>data_normaliser.py</code>. This script not only handles the data makeover but also inserts the revamped data into a squeaky-clean database named <code>capstone_normalised.sqlite</code>. This polished database is all set to steal the spotlight for the grand finale – the analysis and visualization of our data tale.</p>
<h2 id="heading-data-analysis">Data Analysis</h2>
<p>Now that our data is all neat and tidy, it was time to roll up our sleeves and dive into the world of analysis and visualization. To kick things off, I created a Python script called <code>data_stats.py</code> that churned out some essential statistics to explore:</p>
<ul>
<li><p>Migration</p>
<ul>
<li><p>Year with highest migration</p>
</li>
<li><p>Year with lowest migration</p>
</li>
<li><p>Average Migration per year</p>
</li>
<li><p>Average Migration per state</p>
</li>
</ul>
</li>
<li><p>Employment ratio</p>
<ul>
<li><p>Year with highest employment ratio</p>
</li>
<li><p>Year with lowest employment ratio</p>
</li>
<li><p>Average employment ratio per year</p>
</li>
<li><p>Average employment ratio per state</p>
</li>
</ul>
</li>
<li><p>Dwellings (quantity)</p>
<ul>
<li><p>Year with highest dwellings number</p>
</li>
<li><p>Year with lowest dwellings number</p>
</li>
<li><p>Average dwellings number per year</p>
</li>
</ul>
</li>
<li><p>Dwellings (price)</p>
<ul>
<li><p>Year with highest dwelling price</p>
</li>
<li><p>Year with lowest dwelling price</p>
</li>
<li><p>Average dwelling price per year</p>
</li>
</ul>
</li>
</ul>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Note that you can test this script by running <code>python3 data_stats.py</code> in your terminal if you are following along.</div>
</div>

<p>This is an example of the output of the script:</p>
<pre><code class="lang-bash">➜  capstone_project git:(main) ✗ python3 data_stats.py
Getting migration data from database...

    == ---------------------------------------- ==
       Migration statistics
    == ---------------------------------------- ==
    Highest Migration year was 2022 with 422,230 migrations.
    Lowest Migration year was 2020 with -20,370 migrations.
        The Migration variation between the highest and lowest year is about 20.73 <span class="hljs-built_in">times</span> the lowest year.
    Average Migration per year is 45,061 migrations.
    Average Migration per state is:
        New South Wales: 70,884 migrations
        Victoria: 61,682 migrations
        Queensland: 29,642 migrations
        South Australia: 11,857 migrations
        Western Australia: 21,871 migrations
        Tasmania: 2,165 migrations
        Northern Territory: 1,685 migrations
        Australian Capital Territory: 2,979 migrations
        Australia: 202,784 migrations

Getting employment ratios data from database...

    == ---------------------------------------- ==
       Employment Ratio statistics
    == ---------------------------------------- ==
    Highest Employment Ratio year was 2017 with 73 %.
    Lowest Employment Ratio year was 2013 with 55 %.
        The Employment Ratio variation between the highest and lowest year is about 1.33 <span class="hljs-built_in">times</span> the lowest year.
    Average Employment Ratio per year is 62 %.
    Average Employment Ratio per state is:
        New South Wales: 60 %
        Victoria: 61 %
        Queensland: 61 %
        South Australia: 58 %
        Western Australia: 64 %
        Tasmania: 56 %
        Northern Territory: 70 %
        Australian Capital Territory: 68 %
        Australia: 61 %

Getting dwelling numbers data from database...

    == ---------------------------------------- ==
       Dwelling Number statistics
    == ---------------------------------------- ==
    Highest Dwelling Number year was 2022 with 10,907 (x1000) dwellings.
    Lowest Dwelling Number year was 2011 with 74 (x1000) dwellings.
        The Dwelling Number variation between the highest and lowest year is about 147.39 <span class="hljs-built_in">times</span> the lowest year.
    Average Dwelling Number per year is 2,201 (x1000) dwellings.
    Average Dwelling Number per state is:
        New South Wales: 3,080 (x1000) dwellings
        Victoria: 2,545 (x1000) dwellings
        Queensland: 1,976 (x1000) dwellings
        South Australia: 764 (x1000) dwellings
        Western Australia: 1,049 (x1000) dwellings
        Tasmania: 241 (x1000) dwellings
        Northern Territory: 81 (x1000) dwellings
        Australian Capital Territory: 166 (x1000) dwellings
        Australia: 9,909 (x1000) dwellings

Getting dwelling prices data from database...

    == ---------------------------------------- ==
       Dwelling Mean Prices statistics
    == ---------------------------------------- ==
    Highest Dwelling Mean Prices year was 2022 with 1,170 (x1000) AUD.
    Lowest Dwelling Mean Prices year was 2012 with 297 (x1000) AUD.
        The Dwelling Mean Prices variation between the highest and lowest year is about 3.94 <span class="hljs-built_in">times</span> the lowest year.
    Average Dwelling Mean Prices per year is 576 (x1000) AUD.
    Average Dwelling Mean Prices per state is:
        New South Wales: 810 (x1000) AUD
        Victoria: 671 (x1000) AUD
        Queensland: 514 (x1000) AUD
        South Australia: 453 (x1000) AUD
        Western Australia: 551 (x1000) AUD
        Tasmania: 401 (x1000) AUD
        Northern Territory: 473 (x1000) AUD
        Australian Capital Territory: 671 (x1000) AUD
        Australia: 645 (x1000) AUD
</code></pre>
<h2 id="heading-data-visualisation">Data Visualisation</h2>
<p>Moving on, I built a Python script named <code>data_</code><a target="_blank" href="http://visualiser.py"><code>visualiser.py</code></a> to whip up some captivating visualizations. Here's the end result:</p>
<ul>
<li><p>A snazzy 2D chart laying out the data landscape on a national scale.</p>
</li>
<li><p>Four dynamic 3D charts, giving us a state-level peek into the data dimensions across Australia.</p>
</li>
</ul>
<p>At first, I gave the <code>3d.js</code> library a shot for the charts, but it struggled when I tried to juggle multiple data dimensions in the same graph. Not to worry, I pivoted to the <code>plotly.js</code> library, and it played nice, letting me plot those dimensions, but not without breaking a sweat 😓.</p>
<p>Oh, by the way, you can view these charts live online by <a target="_blank" href="https://projects-p4e.damiandemasi.com/capstone_project/charts.htm">clicking here</a>!</p>
<p>The result was a grand chart focusing on Migration, Employment Ratio, Dwelling Quantity, and Mean Price nationwide. This beauty allowed me to dissect how these variables dance together and catch any trends. Now, mind you, correlation in this chart doesn't automatically mean causation – there's a whole orchestra of factors for a proper analysis. But for our project's sake, the plotted data paints quite the picture.</p>
<p><a target="_blank" href="https://projects-p4e.damiandemasi.com/capstone_project/charts.htm"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707291050447/9d5d4d04-a401-42bd-aca7-c234e647c6d9.png" alt class="image--center mx-auto" /></a></p>
<p>In 2020, a noticeable dip in migrations coincided with the aftermath of COVID-19, leading to a significant decline in the Employment Ratio—hinting at a rise in unemployment. The drop in employment is likely a result of the pandemic's impact on the job market rather than a direct consequence of decreased migration. Meanwhile, the number of available homes continued its steady growth, while the average dwelling price started a descent as it approached 2020.</p>
<p>As we stepped into 2021 and 2022, witnessing a resurgence in migration as Australia reopened its borders, a parallel spike in both the Employment Ratio and mean dwelling prices caught my eye. Interestingly, the number of dwellings maintained its consistent growth. The surge in mean dwelling prices during these years could be attributed to the increased influx of migrants, and the fact that the <strong>number of dwellings remained unaltered in its tendency</strong>, creating a higher demand for houses.</p>
<p>Interestingly, as migration gained momentum in 2021 and 2022, the Employment Ratio also showed improvement, suggesting that the increase in migration didn't negatively impact employment.</p>
<p>I dug into creating four more 3D charts, each showcasing the dynamics of Migration, Employment Ratio, Dwelling Quantity, and Mean Price across different states in Australia. These charts unveil interesting insights, like migrants showing a preference for New South Wales and Victoria. These states seem to play a significant role in the growing number of available homes. Meanwhile, the Northern Territory experiences a more gradual increase in dwelling prices, and its employment market appears to be in robust shape.</p>
<p><a target="_blank" href="https://projects-p4e.damiandemasi.com/capstone_project/charts.htm"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707291111088/351b3c20-0451-4b4f-97aa-f2bac7ec1e51.png" alt class="image--center mx-auto" /></a></p>
<p><a target="_blank" href="https://projects-p4e.damiandemasi.com/capstone_project/charts.htm"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707291118289/181345bb-bf93-421f-b503-d024d083ee8c.png" alt class="image--center mx-auto" /></a></p>
<p>Employing a 2D line chart for a nationwide data overview proved effective in uncovering trends and correlations, aligning with the initial goal when first exploring the data. The use of 3D graphs to compare states added a dynamic and engaging layer to the analysis, offering a deeper understanding of the data dynamics across different regions.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Note: if you are following along, you can generate these charts by running <code>python3 data_visualiser.py</code> in your terminal and then opening the <code>charts.htm</code> file in your browser. The raw data for the charts can be found in the <code>charts.js</code> file.</div>
</div>

<h2 id="heading-key-takeaways">Key Takeaways</h2>
<p>The lessons learned from this project will undoubtedly have a positive impact on my future endeavours. It served as a platform to apply my recently learned skills in Python, SQL databases, data analysis, visualization, and interpretation. Despite the occasional challenges of navigating through real-world data, it significantly enhanced my problem-solving abilities. In essence, this project has been a valuable learning journey, contributing significantly to my growth as a software engineer.</p>
<hr />
<p><em>Discover the power of knowledge! Grab my newest free Notion template, packed with detailed<strong><strong>notes on 80 specific topics</strong></strong>covered during my journey through the University of Michigan's 'Python for Everybody' course on Coursera. Ready to level up your Python skills?</em><a target="_blank" href="https://www.devnotes.to/templates/python-notes"><em>Click here now</em></a><em>!</em></p>
<p><a target="_blank" href="https://www.devnotes.to/templates/python-notes"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1707291262049/dac03968-ef98-41ec-b0de-f30732cbf6c3.png" alt class="image--center mx-auto" /></a></p>
<hr />
<p>🗞️ <strong>NEWSLETTER -*</strong>If you want to hear about my latest articles and interesting software development content,<em> [</em>subscribe to my newsletter<em>](https://mailchi.mp/22b236f812b1/subscribe-to-newsletter)</em>.*</p>
<p>🐦 <strong>TWITTER/X -*</strong>Follow me on<em>[</em>Twitter/X<em>](https://twitter.com/DamianDemasi)</em>.*</p>
]]></content:encoded></item><item><title><![CDATA[Ruby on Rails Foundations]]></title><description><![CDATA[In this post, we're diving into the world of Ruby on Rails (RoR) and discussing the essential foundations you need to lay down before embarking on your first or next project. Whether you're a seasoned developer or just starting out, these fundamental...]]></description><link>https://blog.damiandemasi.com/ruby-on-rails-foundations</link><guid isPermaLink="true">https://blog.damiandemasi.com/ruby-on-rails-foundations</guid><category><![CDATA[Ruby]]></category><category><![CDATA[Ruby on Rails]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[mvc]]></category><category><![CDATA[Databases]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Mon, 21 Aug 2023 11:08:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1692011637815/099223a2-29eb-4ae0-8138-d742929f6fc9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this post, we're diving into the world of Ruby on Rails (RoR) and discussing the essential foundations you need to lay down before embarking on your first or next project. Whether you're a seasoned developer or just starting out, these fundamental concepts will set you up for success in building robust and efficient RoR applications.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>TL;DR: </strong>This article explores the basic aspects of <strong>Ruby on Rails (RoR)</strong> and stresses the importance of understanding <strong>Ruby</strong>, the core language behind RoR, which is essential for effective development. It discusses how Ruby is used within RoR's structure, its role in executing instructions, handling application logic, and managing add-ons through RubyGems. The article also highlights the significance of <strong>databases</strong>, like SQLite3, in RoR projects, noting SQLite3's suitability for simpler development and testing settings. Furthermore, an overview of <strong>RoR's versatile features</strong> is given, including its complete framework, simple configuration, adherence to the MVC design, Active Record's part in database communication, user-friendly architecture, pre-built structures, integration of extensions using RubyGems, practical help from Active Support, built-in safety measures, and its lively community.</div>
</div>

<p>Before you even begin with Rails, it's crucial to have a solid grasp of what Ruby is and what it is used for.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1692181851658/2650b11e-9acc-4858-a5e5-17e46f88bd44.gif" alt class="image--center mx-auto" /></p>
<h1 id="heading-1-ruby">1. Ruby</h1>
<p>In a Ruby on Rails project, you need to install Ruby because Ruby on Rails is a web framework built using the Ruby programming language. Ruby is the foundational language that powers Rails and provides the core functionality for developing web applications.</p>
<p>So, let’s see some of the reasons why you need to install Ruby to work on a Ruby on Rails project:</p>
<ul>
<li><p><strong>Language Dependency:</strong> Ruby on Rails is written in Ruby, and it is tightly integrated with the Ruby language. Rails leverages the features, syntax, and capabilities of Ruby to create web applications efficiently. Without Ruby, Rails cannot function as it relies on the underlying Ruby language for its codebase.</p>
</li>
<li><p><strong>Executing Rails Commands:</strong> Many of the command-line tools and utilities used in Rails development, such as <code>rails new</code>, <code>rails generate</code>, and <code>rails server</code>, are Ruby scripts. These commands initiate specific actions within your Rails application and are executed using the Ruby interpreter.</p>
</li>
<li><p><strong>Application Logic:</strong> In a Rails project, you write application-specific logic and business rules in Ruby code. As Rails implements the MVC pattern, you’ll use Ruby code to define and implement models, controllers, and views, as well as business logic and data manipulation. Without Ruby, you wouldn't have the language required to express these aspects of your application.</p>
</li>
<li><p><strong>Gem Management:</strong> RubyGems is the package manager for Ruby, and it plays a crucial role in installing and managing the various gems (libraries and plugins) used in a Rails project. RubyGems is Ruby-based, and when you install gems, they become part of your Ruby environment.</p>
</li>
</ul>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">In the context of the Ruby programming language, a "gem" refers to a packaged Ruby library or plugin that can be easily installed and used in Ruby projects. Gems are a fundamental building block of the Ruby ecosystem and are designed to provide specific functionalities, extend the capabilities of Ruby, and enhance the development process.</div>
</div>

<ul>
<li><strong>Integrating with Web Servers:</strong> When you run a Rails application, it is served by a web server, such as WEBrick or Puma. These servers are Ruby-based and interact with the Rails application using Ruby.</li>
</ul>
<h2 id="heading-11-model-view-controller-mvc">1.1. Model, View, Controller (MVC)</h2>
<p><strong>MVC</strong> stands for Model-View-Controller, and it's a design pattern that separates an application into three interconnected components:</p>
<ol>
<li><p><strong>Model</strong>: The Model represents the data and business logic of the application. It deals with database interactions, data validation, and encapsulates the rules for manipulating the data. In a Ruby on Rails app, the models are often implemented using ActiveRecord, which provides an Object-Relational Mapping (ORM) layer for database operations.</p>
</li>
<li><p><strong>View</strong>: The View is responsible for presenting the data to the user. It encompasses the user interface components, layouts, and templates that generate the HTML and other content displayed in the browser. In Rails, Views are often created using embedded Ruby (ERB) templates, allowing dynamic content to be mixed seamlessly with static HTML.</p>
</li>
<li><p><strong>Controller</strong>: The Controller acts as an intermediary between the Model and the View. It receives requests from the user's browser, processes them, and communicates with the Model to retrieve or modify data. Once the data is prepared, the Controller selects the appropriate View template to render the response, which is then sent back to the user's browser.</p>
</li>
</ol>
<p>The MVC framework provides a clear separation of concerns, making it easier to maintain and extend the application over time. Changes to the user interface (View) can be made independently of the data and business logic (Model), and vice versa. This separation enhances code organization, collaboration among developers, and the overall flexibility of the application.</p>
<p>In a Ruby on Rails app, this architecture is central to the framework's philosophy and greatly contributes to its efficiency and productivity.</p>
<h2 id="heading-12-rubygems">1.2. RubyGems</h2>
<p><strong>RubyGems</strong> is a package manager for the Ruby programming language. It is a tool that simplifies the process of installing, managing, and distributing Ruby libraries (gems) and applications. Gems are pre-packaged libraries or plugins that extend the functionality of Ruby applications, making it easier for developers to add features or reuse code in their projects.</p>
<p>Here are the key features and functions of RubyGems:</p>
<ul>
<li><p><strong>Gem Installation:</strong> RubyGems allows developers to install gems effortlessly with a single command. When a gem is installed, it becomes available for use in Ruby projects, and its functionality can be accessed within the code.</p>
</li>
<li><p><strong>Gem Management:</strong> Once installed, RubyGems helps developers manage gems in their projects. It allows you to view installed gems, uninstall unnecessary ones, and update gems to their latest versions.</p>
</li>
<li><p><strong>Gem Dependency Resolution:</strong> RubyGems handles gem dependencies, meaning when you install a gem, it automatically installs other gems that the target gem requires to function properly. This ensures that all necessary dependencies are met without requiring manual intervention.</p>
</li>
<li><p><strong>Gemspec Files:</strong> Each gem typically includes a <code>gemspec</code> file, which contains metadata about the gem, such as its name, version, author, description, and required dependencies. The <code>gemspec</code> file provides essential information for RubyGems to install and manage the gem correctly.</p>
</li>
<li><p><strong>Centralized Repository:</strong> RubyGems operates on a centralized repository known as the <a target="_blank" href="http://RubyGems.org">RubyGems.org</a> or RubyGems server. This repository serves as the central hub for hosting and distributing Ruby gems. Developers can publish their gems on <a target="_blank" href="http://RubyGems.org">RubyGems.org</a> for others to use.</p>
</li>
<li><p><strong>Bundler Integration:</strong> Bundler is another essential tool in the Ruby ecosystem that manages gem dependencies for a specific project. It works hand in hand with RubyGems to ensure that the correct versions of gems are installed and used in a particular project.</p>
</li>
<li><p><strong>Community Contribution:</strong> RubyGems fosters a vibrant community of gem developers who contribute to the vast ecosystem of gems available. The community continuously develops and maintains gems, making them available for public use.</p>
</li>
</ul>
<p>Read more about RubyGems <a target="_blank" href="https://guides.rubygems.org/rubygems-basics/">here</a>.</p>
<h1 id="heading-2-databases">2. Databases</h1>
<p>In a Ruby on Rails project, you need to install SQLite3 (or another database adapter) because Rails relies on a database to store and manage the application's data. SQLite3 is one of the supported database adapters in Rails, and it is often used as the default database for development and testing environments due to its simplicity and ease of setup.</p>
<p>You might be curious about what are the key components and concepts related to data storage and management in a Ruby on Rails application, so let’s do a quick exploration of them:</p>
<ul>
<li><p><strong>Data Persistence:</strong> Rails applications are typically designed to interact with a database to store and retrieve data. The database acts as a persistent storage solution, allowing the application to store information across multiple user sessions and server restarts.</p>
</li>
<li><p><strong>Models and Active Record:</strong> In Rails, models are Ruby classes that represent database tables. Models are created using Active Record, which is a Rails feature that provides an Object-Relational Mapping (ORM) layer. Active Record maps Ruby objects to database records, allowing developers to interact with the database using familiar Ruby syntax.</p>
</li>
<li><p><strong>Migration and Schema:</strong> Rails uses database migrations to manage changes to the database schema over time. Migrations are Ruby scripts that describe changes to the database structure, such as creating tables, adding columns, or modifying indexes. When migrations are run, they update the database schema accordingly.</p>
</li>
<li><p><strong>Database-Backed Applications:</strong> Many Rails applications are database-backed, meaning they rely on a database to handle various aspects of the application, such as storing user data, managing authentication information, and recording application-specific data.</p>
</li>
</ul>
<h2 id="heading-22-ror-is-database-agnostic">2.2. RoR is database-agnostic</h2>
<p>Ruby on Rails is designed to be database-agnostic, which means you can use a variety of databases with it. However, Rails has a closer integration with certain databases, and some databases are more commonly used due to their compatibility and community support.</p>
<p>While you can technically use any database with Rails, it's important to consider factors such as compatibility, performance, and community support. The databases that are well-supported and commonly used with Ruby on Rails include PostgreSQL, MySQL, and SQLite. These databases have established gems (libraries) and documentation to facilitate their integration with Rails.</p>
<ul>
<li><p><strong>PostgreSQL</strong>: PostgreSQL is a powerful open-source relational database management system. It's known for its advanced features, extensibility, and support for complex queries. Many Rails developers prefer PostgreSQL for its robustness and support for handling large datasets.</p>
</li>
<li><p><strong>MySQL</strong>: MySQL is another popular open-source relational database system. It's widely used in Rails projects and is known for its speed and reliability. MySQL is a good choice for projects that require scalability and high performance.</p>
</li>
<li><p><strong>SQLite</strong>: SQLite is a lightweight, file-based relational database engine. It's often used in development and testing environments due to its simplicity and ease of use. While it might not be suitable for high-traffic production applications, it's a great choice for smaller projects or testing purposes.</p>
</li>
</ul>
<p>Learn more about SQLite3 <a target="_blank" href="https://www.sqlite.org/index.html">here</a>.</p>
<h1 id="heading-3-rails">3. Rails</h1>
<p>Finally, let’s talk about Rails. Ruby on Rails, often simply referred to as Rails, is an open-source web application framework written in the Ruby programming language. As discussed earlier, Rails follows the Model-View-Controller (MVC) architectural pattern and aims to provide a productive and convention-over-configuration approach to building web applications. It was created by David Heinemeier Hansson and was first released in 2004.</p>
<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text"><strong>David Heinemeier Hansson (DHH)</strong> is a Danish programmer, entrepreneur, and the creator of the Ruby on Rails framework. He is also known for his contributions to the development of web application frameworks and his involvement in the technology and startup communities. DHH includes photography and race car driving in his extensive list of hobbies. In 2012, he participated in the 24 Hours of Le Mans as a driver for OAK Racing. Additionally, he achieved victory in two races during the season while driving a Morgan-Nissan P2 car for Conquest Racing in the American Le Mans Series (ALMS).</div>
</div>

<p>Rails has many features that make it a great framework to work with, although sometimes it can feel a bit overwhelming (especially when you are just starting to learn how to use it). Here's an overview of some of its main features:</p>
<ul>
<li><p><strong>Full-Stack Web Framework</strong>: Rails is a full-stack web framework, meaning it provides a comprehensive set of tools and libraries for developing the entire web application, including handling the backend logic, managing the database, and rendering the frontend views.</p>
</li>
<li><p><strong>Convention over Configuration</strong>: Rails follows the principle of convention over configuration, which means it makes assumptions about how the application should be structured and configured. By adhering to these conventions, developers can achieve more straightforward and consistent development without having to specify every detail explicitly.</p>
</li>
<li><p><strong>Model-View-Controller (MVC) Pattern</strong>: Rails follows the MVC pattern, which separates the application into three components: models, responsible for managing data and business logic; views, responsible for rendering the user interface; and controllers, responsible for handling user requests and coordinating the models and views.</p>
</li>
<li><p><strong>Active Record</strong>: Rails includes Active Record, an Object-Relational Mapping (ORM) layer that simplifies database interactions by representing database tables as Ruby objects. Active Record allows developers to work with the database using familiar Ruby syntax, reducing the need to write raw SQL queries.</p>
</li>
<li><p><strong>RESTful Architecture</strong>: Rails encourages the use of Representational State Transfer (REST) principles for designing web applications. RESTful routes and actions provide a consistent and predictable way to interact with resources in the application.</p>
</li>
<li><p><strong>Scaffolding</strong>: Rails provides scaffolding, a code generation feature that automatically creates a basic set of controllers, models, and views for a specific resource. Scaffolding accelerates development by quickly providing a working prototype of the application.</p>
</li>
<li><p><strong>Gems and RubyGems</strong>: Rails leverages RubyGems, the package manager for Ruby, to manage dependencies and integrate third-party libraries (gems) into the application. Gems extend the functionality of Rails and allow developers to add features to their projects with ease.</p>
</li>
<li><p><strong>Active Support</strong>: Rails comes with Active Support, a collection of utility classes and standard library extensions that provide additional functionality to Ruby. Active Support includes methods for working with dates, strings, collections, and more.</p>
</li>
<li><p><strong>Security</strong>: Rails includes built-in security features to protect against common web application vulnerabilities, such as Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF).</p>
</li>
<li><p><strong>Community and Ecosystem</strong>: Rails has a vibrant and active community of developers who contribute to its ongoing development and maintenance. The Ruby on Rails ecosystem includes numerous gems, plugins, and tools that further enhance the framework's capabilities.</p>
</li>
</ul>
<p>I intend to go into each of these features (and more) in more detail in the upcoming posts, so stay tuned! 📻</p>
<h1 id="heading-4-closing-thoughts">4. Closing thoughts</h1>
<p>This post discussed Ruby on Rails (RoR) and its foundational aspects. Understanding these concepts is important for creating good RoR applications, whether you're experienced or just starting out.</p>
<p>Before learning Rails, you should know Ruby well. Ruby is the foundation of Rails and is used for making web applications.</p>
<p>RoR supports many databases, including PostgreSQL, MySQL, and SQLite. This means you can choose the one that fits your project best.</p>
<p>RoR is a powerful and productive framework with many features:</p>
<ul>
<li><p>Full-Stack Framework</p>
</li>
<li><p>Convention over Configuration</p>
</li>
<li><p>MVC Pattern</p>
</li>
<li><p>Active Record for Database Interaction</p>
</li>
<li><p>RESTful Architecture</p>
</li>
<li><p>Scaffolding for Rapid Prototyping</p>
</li>
<li><p>Integration of Gems and RubyGems</p>
</li>
<li><p>Active Support</p>
</li>
<li><p>Embedded Security Features</p>
</li>
<li><p>Flourishing Community and Ecosystem</p>
</li>
</ul>
<p>My aim with this post was to give developers a good understanding of Ruby's role in Rails, the importance of database adapters like SQLite3, and the many capabilities of the Ruby on Rails framework itself. With this knowledge, you can now confidently start digging into creating dynamic and efficient web applications with Ruby on Rails.</p>
<p>Thanks for reading, and see you next time! 👋</p>
<h1 id="heading-bonus-knowledge-check">Bonus: knowledge check!</h1>
<details><summary>Why do you need to install Ruby to work in a Ruby on Rails project?</summary><div data-type="detailsContent">Ruby on Rails is built using the Ruby programming language. Ruby provides the core functionality for developing web applications in Rails, and many of the Rails commands and utilities are Ruby scripts. Additionally, application-specific logic and business rules in Rails projects are written in Ruby code.</div></details><details><summary>What is a gem in the context of Ruby programming language and RubyGems?</summary><div data-type="detailsContent">In the context of the Ruby programming language, a "gem" refers to a packaged Ruby library or plugin that can be easily installed and used in Ruby projects. RubyGems is the package manager for Ruby, responsible for installing and managing these gems. Gems extend the capabilities of Ruby and provide specific functionalities to enhance the development process.</div></details><details><summary>Why do you need to install SQLite3 (or another database adapter) in a Ruby on Rails project?</summary><div data-type="detailsContent">Rails applications require a database to store and manage data. SQLite3 is one of the supported database adapters in Rails and is often used as the default database for development and testing environments due to its simplicity. Installing SQLite3 allows Rails to interact with the database, handle data persistence, and manage the application's models and schema using Active Record.</div></details><details><summary>What are the key features and functions of RubyGems in the Ruby ecosystem?</summary><div data-type="detailsContent">RubyGems simplifies the process of installing, managing, and distributing Ruby libraries (gems) and applications. Its key features and functions include: gem Installation, gem management, gem dependency resolution, gemspec files, centralised repository, bundler integration, and community contribution.</div></details><details><summary>What is Ruby on Rails, and what are its key features?</summary><div data-type="detailsContent">Ruby on Rails (Rails) is an open-source web application framework written in Ruby. Its key features include: Full-Stack Web framework, convention over configuration, Model-View-Controller (MVC) pattern, Active Record, RESTful architecture, scaffolding, Gems and RubyGems, Active Support, security, and a great community and ecosystem.</div></details>

<hr />
<p>Cover photo by <a target="_blank" href="https://unsplash.com/@dev_qube?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Yulian Alexeyev</a> - <a target="_blank" href="https://unsplash.com/photos/ZFJgmAonylo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p>
]]></content:encoded></item><item><title><![CDATA[Navigating Mutability and Reference Issues in JavaScript]]></title><description><![CDATA[Mutability
Mutability refers to the ability of a value or data structure to be changed after it has been created.
Primitive values are immutable
Primitive values (string, number, bigint, boolean, undefined, symbol and null) are immutable, which means...]]></description><link>https://blog.damiandemasi.com/navigating-mutability-and-reference-issues-in-javascript</link><guid isPermaLink="true">https://blog.damiandemasi.com/navigating-mutability-and-reference-issues-in-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Mon, 27 Feb 2023 09:40:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1677490299000/92e83d8b-0ba1-4648-bb7d-bd2391adcf5b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-mutability">Mutability</h3>
<p>Mutability refers to the ability of a value or data structure to be changed after it has been created.</p>
<h3 id="heading-primitive-values-are-immutable">Primitive values are immutable</h3>
<p>Primitive values (<code>string</code>, <code>number</code>, <code>bigint</code>, <code>boolean</code>, <code>undefined</code>, <code>symbol</code> and <code>null</code>) are immutable, which means that they cannot be changed once created.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> myString = <span class="hljs-string">"Hello, world!"</span>

<span class="hljs-comment">// Attempting to mutate (change) the string:</span>
myString[<span class="hljs-number">0</span>] = <span class="hljs-string">"J"</span>
<span class="hljs-comment">// -&gt; 'J'</span>

<span class="hljs-comment">// Proof that strings are immutable, because it didn't change:</span>
myString
<span class="hljs-comment">// -&gt; 'Hello, world!'</span>
</code></pre>
<p>The string <code>"Hello, world!"</code> will always be <code>"Hello, world!"</code>.</p>
<p>We can change the value to which the variable is grasping (a new string that also will be immutable), but the string itself (the value) will remain the same (immutable):</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> myString = <span class="hljs-string">"Hello, world!"</span>

myString
<span class="hljs-comment">// -&gt; 'Hello, world!'</span>

myString = <span class="hljs-string">"Hey, world!"</span> 

myString
<span class="hljs-comment">// -&gt; 'Hey, world!'</span>

myString[<span class="hljs-number">0</span>] = <span class="hljs-string">"X"</span>
<span class="hljs-comment">// -&gt; 'X'</span>

myString
<span class="hljs-comment">// -&gt; 'Hey, world!'</span>
</code></pre>
<h3 id="heading-objects-are-mutable">Objects are mutable</h3>
<p>Objects are mutable, as they can be modified:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Object creation</span>
<span class="hljs-keyword">const</span> person = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">'Sarah'</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">30</span>
};

<span class="hljs-comment">// Change the value of a property</span>
person.age = <span class="hljs-number">42</span>;

<span class="hljs-comment">// Add a new property</span>
person.gender = <span class="hljs-string">'Female'</span>;

<span class="hljs-comment">// Delete a property</span>
<span class="hljs-keyword">delete</span> person.age;

person;
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">//     "name": "Sarah",</span>
<span class="hljs-comment">//     "gender": "Female"</span>
<span class="hljs-comment">// }</span>
</code></pre>
<p>In this scenario, an object is mutable because we can change its properties.</p>
<p>If the object properties are other objects, their values will be mutable, whereas if they are primitive values, their values will be immutable.</p>
<pre><code class="lang-javascript">person.gender[<span class="hljs-number">0</span>] = <span class="hljs-string">"X"</span>

person
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">//     "name": "Sarah",</span>
<span class="hljs-comment">//     "gender": "Female"</span>
<span class="hljs-comment">// }</span>
</code></pre>
<p>Even though an object is mutable, its properties might not be.</p>
<p>We can make an object immutable by using the <code>Object.freeze()</code> function:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// Object creation</span>
<span class="hljs-keyword">const</span> person = {
  <span class="hljs-attr">name</span>: <span class="hljs-string">'Sarah'</span>,
  <span class="hljs-attr">age</span>: <span class="hljs-number">30</span>
};

<span class="hljs-built_in">Object</span>.freeze(person)

person.name = <span class="hljs-string">"Connor"</span>
person.enemy = <span class="hljs-string">"T-1000"</span>

person
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">// {</span>
<span class="hljs-comment">//     "name": "Sarah",</span>
<span class="hljs-comment">//     "age": 30</span>
<span class="hljs-comment">// }</span>
</code></pre>
<h3 id="heading-the-reference-confusion-in-objects">The reference confusion in objects</h3>
<p>When we assign a <strong>primitive</strong> value to a variable, we are making that variable point to a primitive value in the memory of the machine. We can then assign the variable to another variable, thus making the second variable grasp the first one, and, by extension, <strong>reference</strong> the same value.</p>
<p>If we wanted to change the value of the second variable, ss we cannot change primitive values (they are immutable), we could assign a new value. By doing so, the second variable will be <strong>referencing</strong> a new value.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> variable1 = <span class="hljs-string">"hello"</span>

<span class="hljs-keyword">let</span> variable2 = variable1

variable2 === variable1
<span class="hljs-comment">// -&gt; true</span>

variable2 = <span class="hljs-string">"bye"</span>

variable2 === variable1
<span class="hljs-comment">// -&gt; false</span>

variable1
<span class="hljs-comment">// -&gt; 'hello'</span>

variable2
<span class="hljs-comment">// -&gt; 'bye'</span>
</code></pre>
<p>With objects, the behaviour is a bit different. We can assign an object to a variable, which means that the variable grasps the object, or has a <strong>reference</strong> to it. If we then assign that variable to another variable, the new variable will grasp the first one and, by extension, <strong>reference</strong> the same object. As objects are mutable, a change in the object will affect both variables.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> object1 = {
    <span class="hljs-attr">value1</span>: <span class="hljs-string">"abc"</span>,
    <span class="hljs-attr">value2</span>: <span class="hljs-number">123</span>
}

<span class="hljs-keyword">const</span> object2 = object1

object2 === object1
<span class="hljs-comment">// -&gt; true</span>

object2.value1 = <span class="hljs-string">"xyz"</span>

object1
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">//     "value1": "xyz",</span>
<span class="hljs-comment">//     "value2": 123</span>
<span class="hljs-comment">// }</span>

object2
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">//     "value1": "xyz",</span>
<span class="hljs-comment">//     "value2": 123</span>
<span class="hljs-comment">// }</span>
</code></pre>
<p>On the other hand, we can define a new object in the second variable, and thus make it not reference the same object as the first one. One thing to note is that, even if all the object properties are the same, these two objects will be different:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> object1 = {
    <span class="hljs-attr">value1</span>: <span class="hljs-string">"abc"</span>,
    <span class="hljs-attr">value2</span>: <span class="hljs-number">123</span>
}

<span class="hljs-keyword">const</span> object2 = {
    <span class="hljs-attr">value1</span>: <span class="hljs-string">"abc"</span>,
    <span class="hljs-attr">value2</span>: <span class="hljs-number">123</span>
}

object2 === object1
<span class="hljs-comment">// -&gt; false</span>

object2.value1 = <span class="hljs-string">"xyz"</span>

object1
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">//     "value1": "abc",</span>
<span class="hljs-comment">//     "value2": 123</span>
<span class="hljs-comment">// }</span>

object2
<span class="hljs-comment">// -&gt; {</span>
<span class="hljs-comment">//     "value1": "xyz",</span>
<span class="hljs-comment">//     "value2": 123</span>
<span class="hljs-comment">// }</span>
</code></pre>
<h3 id="heading-references">References</h3>
<ul>
<li><p><a target="_blank" href="https://eloquentjavascript.net/04_data.html#h_C3n45IkMhg">Eloquent JavaScript: Mutability</a></p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Mutable">MDN: Mutable</a></p>
</li>
<li><p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/Immutable">MDN: Immutable</a></p>
</li>
</ul>
<p>Thanks for reading, and see you next time! 👋</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content,</em> <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter"><em>subscribe to my newsletter</em></a><em>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on</em> <a target="_blank" href="https://twitter.com/DamianDemasi"><em>Twitter</em></a><em>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Learning how to code: with our special guest, Ron]]></title><description><![CDATA[Let me introduce you to Ron, an ordinary person like you and me, except that he was born into a world of magic. Life led Ron to experience many adventures when he was young. Still, he somehow ended up working as a manager in a retail wizarding joke e...]]></description><link>https://blog.damiandemasi.com/learning-how-to-code-with-our-special-guest-ron</link><guid isPermaLink="true">https://blog.damiandemasi.com/learning-how-to-code-with-our-special-guest-ron</guid><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[learning]]></category><category><![CDATA[#codenewbies]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 12 Oct 2022 13:30:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1665571223536/VMAQLdUTF.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let me introduce you to Ron, an ordinary person like you and me, except that he was born into a world of magic. Life led Ron to experience many adventures when he was young. Still, he somehow ended up working as a manager in a retail wizarding joke emporium, a job he ultimately got tired of. As he wanted to start working in something more rewarding, he began investigating a possible career in programming and, more specifically, in web development.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664918691712/zxWerUoVl.png" alt="image.png" /></p>
<p><em>This content is also available on my YouTube channel, and you can <a target="_blank" href="https://youtu.be/0LOj90PjN-Y">watch it here</a>:</em></p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/0LOj90PjN-Y"></iframe>

<p>But Ron knows he has some problems with his study techniques: he doesn’t know how to improve his weakest points, often thinks that tests are a waste of time, and constantly takes feedback incorrectly.</p>
<p>In this article, we will help Ron by teaching him how to attack his weakest points to improve them, how he can learn by testing himself about programming concepts and allow feedback to improve his coding skills.</p>
<p>This article is the second one about distilling the concepts presented in the book <a target="_blank" href="https://amzn.to/3PNLqJM">Ultralearning by Scott Yong</a>. I apply those concepts to learning programming, as I believe they are very useful. If you wish to know more about these topics, I recommend reading the book.</p>
<p>I will publish at least two more learning principles applied to programming in the upcoming article, so you might want to <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a> get a notification when it's published.</p>
<p>OK, let's help Ron with the first principle: Drills.</p>
<h2 id="heading-drills-attack-your-weakest-point">Drills: Attack Your Weakest Point</h2>
<p>As soon as Ron sat down and opened his online course about programming, he felt overwhelmed by the complexity of the topics he wanted to learn. According to the book, applying a "divide and conquer" approach is the best way to overcome these challenges.</p>
<p>Ron could break down complex topics into smaller pieces, understand them, practice them, and once he masters those small parts, put them back together.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664919723762/1xvYXhK6c.png" alt="Screen Shot 2022-10-05 at 08.10.39.png" /></p>
<p>The key idea behind drills is to choose critical concepts and practice them. Drills build up from the principle of Directness, discussed in my previous article, but it goes a bit deeper, with a narrower focus.</p>
<p>Suppose we start by putting into practice a programming concept through directness. In that case, we could then find the most complex components that produce the most significant impact on the main concept and create drills, which are essentially practice sessions, to improve them. After we have completed our practice sessions, we can go back to the central concept and see if we understand it better.</p>
<p>Ron finds it difficult to transfer this idea into practice, so let's give him a couple of tactics he can use to design his drills.</p>
<h3 id="heading-tactic-1-components">Tactic 1: Components</h3>
<p>In this tactic, we will find ways to drill (practice) only one specific component of the concept or skill we are learning.</p>
<p>As it turns out, Ron has problems understanding the structure of HTML documents. In this case, he could practice small pieces of the HTML structure, such as the <a target="_blank" href="https://www.w3.org/TR/html4/struct/global.html">HTML version information</a>. Once he has practised this piece until it comes natural to him, he can move on to other elements, thus growing his knowledge and expertise about HTML.</p>
<h3 id="heading-tactic-2-copycat">Tactic 2: Copycat</h3>
<p>Sometimes we will need to practice a part of a concept that's not easy to reproduce by itself. In these situations, we could copy the features we don't want to practice to focus on the parts we do.</p>
<p>Ron wants to practice some HTML form elements, such as <code>&lt;input&gt;</code> and <code>&lt;label&gt;</code>. To do this properly, he will need to write a lot of HTML code just to reach the section in which he can finally introduce a <code>&lt;form&gt;</code> element and practice its sub-elements: <code>&lt;input&gt;</code> and <code>&lt;label&gt;</code>.</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>The label element<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>
            Click on one of the text labels to toggle the related radio button:
        <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>

        <span class="hljs-tag">&lt;<span class="hljs-name">form</span> <span class="hljs-attr">action</span>=<span class="hljs-string">"/action_page.php"</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"radio"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"html"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"fav_language"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"HTML"</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"html"</span>&gt;</span>HTML<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"radio"</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"css"</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"fav_language"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"CSS"</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"css"</span>&gt;</span>CSS<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span>
                <span class="hljs-attr">type</span>=<span class="hljs-string">"radio"</span>
                <span class="hljs-attr">id</span>=<span class="hljs-string">"javascript"</span>
                <span class="hljs-attr">name</span>=<span class="hljs-string">"fav_language"</span>
                <span class="hljs-attr">value</span>=<span class="hljs-string">"JavaScript"</span>
            /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">label</span> <span class="hljs-attr">for</span>=<span class="hljs-string">"javascript"</span>&gt;</span>JavaScript<span class="hljs-tag">&lt;/<span class="hljs-name">label</span>&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span><span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">input</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"submit"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Submit"</span> /&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">form</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>By using the copycat tactic, Ron can just copy and paste the code needed to build an empty form and build on top of that, practising the elements he wants to learn.</p>
<p>Building on this concept, and once Ron gains more knowledge about versioning systems, he could even use Git to create branches of his code and practice parts of it.</p>
<h3 id="heading-tactic-3-the-programming-dojo">Tactic 3: The Programming Dojo</h3>
<p>Another way to practice specific code concepts is to have a programming session around a coding challenge. Websites like <a target="_blank" href="https://www.codewars.com/">CodeWars</a> offer many coding challenges we can use to practice our coding skills and improve.</p>
<p>In websites like this one, Ron is not only going to write code but also look at other muggles', I mean people's, solutions, something that will teach him about the different ways a programming challenge can be solved.</p>
<p>🧑‍💻 Here is a list of sites to practice code:</p>
<ul>
<li><a target="_blank" href="https://www.codewars.com/">CodeWars</a></li>
<li><a target="_blank" href="https://leetcode.com/">LeetCode</a></li>
<li><a target="_blank" href="https://coderbyte.com/">CoderByte</a></li>
<li><a target="_blank" href="https://www.codechef.com/">CodeChef</a></li>
<li><a target="_blank" href="https://www.hackerrank.com/">HackerRank</a></li>
</ul>
<p>Let's now help Ron to overcome his preconceptions about tests and use them as a learning tool.</p>
<h2 id="heading-retrieval-test-to-learn">Retrieval: Test to Learn</h2>
<p>Ron is used to thinking about testing as a way to assess knowledge when, in fact, it's also a way of creating it. We should test ourselves before we feel confident, even if we don't know all the answers, because doing this will prepare our minds to pay attention to information that looks like a solution when we learn it later.</p>
<p><img src="https://media.giphy.com/media/ZaRz2080kt4Yg/giphy.gif" /></p>
<p>Ron is used to spending long hours passively reviewing his highlights on books and notes, hoping that something will stick to his memory, but this is not what retrieval is about. Retrieval is closing the book and trying to answer questions about the topic we just learned. This is why it's essential to build our own projects in programming because it's here when we discover what we know and don't know.</p>
<p>If we have the answers to what we want to retrieve, such as the book's answer keys, we can compare our recalled knowledge with the actual correct answers, thus improving our understanding and retention.</p>
<p>Ron is taking a course on JavaScript, and the instructor says, after showing how something is built, "OK, now you try to build this functionality". Ron should try to build it without taking a second look at how the instructor did it and Googling things he doesn't know or remembers. After he finishes creating it, he can continue watching the course and compare his solution with the solution provided by the instructor. This will trigger several "aha!" moments for Ron, keeping him engaged in the learning activities.</p>
<p><img src="https://media.giphy.com/media/VwUquCGtIatGg/giphy.gif" /></p>
<p>Ron should avoid doing simple retrieval, such as answering multiple-choice questions. He should try to do open retrieval: writing as much as he knows about a specific topic. This is the best method to make the most of his retrieval activities. For more details about the scientific proof behind this, read chapter 8 of the book Ultralearning.</p>
<p>Ron asks for some tactics about how to put the retrieval concept into practice, so let's take a look at the following ones.</p>
<h3 id="heading-tactic-1-free-recall">Tactic 1: Free recall</h3>
<p>After reading a book section or learning a new concept, we could try to write down everything we remember on a blank piece of paper. Doing this will help us to remember these concepts later.</p>
<h3 id="heading-tactic-2-the-question-book-method">Tactic 2: The question-book method</h3>
<p>We often take notes during our learning process to highlight things that we consider to be important. A better way of taking notes is to write them down as questions to be answered later.</p>
<p>I actually did this when I was doing a Udemy course about JavaScript. As the course introduced concepts, I wrote them down on a Notion database in the form of questions. This is how I managed to write 318 questions (with their answers) and have them ready for my recall sessions.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664960586267/p3I_uAPTM.png" alt="Screen Shot 2022-10-05 at 19.32.32.png" /></p>
<p>For example, instead of writing "Type coercion is…" we could write "What is type coercion?" and refer to where we can find the answer. In this example, a link to a blog post in FreeCodeCamp will suffice: "Type coercion is the process of converting a value from one type to another (such as string to number)."</p>
<p>But I have a disclaimer to do, and I'm sure Ron is going to relate to this: even though I have all these questions, I'm still struggling to find time and energy to do some recall on them. So, don't be like me, and find time to answer the questions! 😅</p>
<h3 id="heading-tactic-3-self-generated-challenges">Tactic 3: Self-generated challenges</h3>
<p>As we go through our learning material, we could create challenges for ourselves to solve later. For example, if we are learning about APIs, we could create a challenge to use an API.</p>
<p>We could create a list of all these challenges to address later and have our own repository of code examples we could use in the future.</p>
<p>Let's now help Ron overcome his tendency to take feedback in the wrong way.</p>
<p><img src="https://media.giphy.com/media/rjiRFTZ0NIdi/giphy.gif" /></p>
<h2 id="heading-feedback-dont-dodge-the-punches">Feedback: Don't Dodge the Punches</h2>
<p>During our learning process, we are going to find feedback. It could come from other people expressing their opinions, but more often than not, it will come from a computer: our code doesn't work as expected.</p>
<p>We shouldn't let our egos get in the way of this feedback. On the one hand, we can think that as our program is not working, we are not suitable to be programmers. Or on the other hand, believe that we are great programmers because we got our "Hello, world" code working on the first try.</p>
<p>Ron usually feels reluctant to share his code with others as he will face criticism. The bad news is that others must review our code, as this is a standard practice in the programming industry. Here we should remember the concept of having a growth mindset (as I discussed in the first article of this series) and don't take feedback or criticism in the wrong way. Feedback is what makes us better programmers.</p>
<p>Let's give Ron some tactics to improve his response to feedback and use it in the best way possible.</p>
<h3 id="heading-tactic-1-noise-cancellation">Tactic 1: Noise cancellation</h3>
<p>Every time we receive feedback, it will be made of a constructive and noisy part. We should learn to disregard the noise and focus on the constructive part.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1664959773391/e6EFIRMd_.png" alt="Screen Shot 2022-10-05 at 19.18.32.png" /></p>
<p>For example, someone can comment about Ron's code: "You are not good in programming because you forgot to clear the timeout in this React component. You should go back to selling magic jokes…". The constructive part of this feedback is that Ron should pay more attention to clearing timeouts in his code to avoid memory leaks, for example. The noise is the first and last part of this feedback, a subjective judgement someone made about Ron's capabilities as a programmer, and he should disregard that, as the person giving the feedback probably doesn't know Ron well. He can't possibly write code without making mistakes (that's why our code needs to be reviewed by peer programmers and pass quality assurance tests).</p>
<h3 id="heading-tactic-2-hitting-the-difficulty-sweet-spot">Tactic 2: Hitting the difficulty sweet spot</h3>
<p>We need the computer's feedback when writing code, as it will tell us if the code is working or not. If Ron makes too many mistakes, or too few, he should decrease or increase the difficulty of the project he's working on to get helpful feedback.</p>
<h3 id="heading-tactic-3-metafeedback">Tactic 3: Metafeedback</h3>
<p>This kind of feedback is not about the code we are writing but the overall success of the strategy we use to learn how to code.</p>
<p>Ron could experiment with different study methods, comparing and contrasting them. The best way to make this comparison is to test himself: does he learns more with method A or B? Which method takes more time? Which method is the most likely he will use in his study activities?</p>
<p><img src="https://media.giphy.com/media/FCeqsn7FF2xIQ/giphy.gif" /></p>
<h2 id="heading-closing-thoughts">Closing thoughts</h2>
<p>Coming to an end in this article, I hope we have given Ron a good idea about how he can improve his weakest points, learn effectively by testing himself and constructively take feedback to improve his coding skills. I'm sure Ron now feels more confident about learning how to program.</p>
<p>I want to remind you that there are at least two more principles I'll cover in the coming article, so you might want to <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a> to get a notification when it's published.</p>
<p>Have you ever felt like Ron did? Which one of the covered principles resonated most with you? Please leave your answer in the comments so we can discuss more about it.</p>
<p>Thanks for reading, and see you next time! 👋</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Learning how to code: the first 3 steps]]></title><description><![CDATA[In this post, I’m going to cover the concepts described in the book Ultralearning, and describe the first three principles:

Metalearning,
Focus, and
Directness

This content is also available on my YouTube channel, and you can watch it here:


Ultra...]]></description><link>https://blog.damiandemasi.com/learning-how-to-code-the-first-3-steps</link><guid isPermaLink="true">https://blog.damiandemasi.com/learning-how-to-code-the-first-3-steps</guid><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[learning]]></category><category><![CDATA[#codenewbies]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 21 Sep 2022 15:30:41 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1663586234905/irr2R55pP.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this post, I’m going to cover the concepts described in the book Ultralearning, and describe the first three principles:</p>
<ol>
<li>Metalearning,</li>
<li>Focus, and</li>
<li>Directness</li>
</ol>
<p>This content is also available on my YouTube channel, and you can <a target="_blank" href="https://youtu.be/adCxUDCe-aw">watch it here</a>:</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/adCxUDCe-aw"></iframe>

<p>Ultralearning is a book written by Scott Yong, and in it, he presents several principles that we can apply to learn difficult topics, such as programming. If you wish to know more about these topics, I highly recommend you read the book.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663664171168/u5gQc4l8P.png" alt="image.png" class="image--center mx-auto" /></p>
<p>I’m going to publish at least 5 more learning principles applied to programming in the upcoming posts, so you might want to <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a> to get a notification when they are out.</p>
<p>By now, you are probably wondering what is ultralearning. It’s basically a strategy for gaining skills and knowledge that is both self-directed and intense. It’s not passive or entertaining, as could be conveniently watching a tutorial whilst relaxing on the couch.</p>
<p><img src="https://media.giphy.com/media/bDTtPo3HyEluE/giphy.gif" /></p>
<p>Instead, it’s systematic and iterative. It’s the difference between wishful thinking (“oh… it would be nice to learn how to program, so let’s watch some YouTube videos about it”) and massive action (“as I’m convinced that I want to learn to program, I’m going to devote myself to that task”).</p>
<p><img src="https://media.giphy.com/media/fQZX2aoRC1Tqw/giphy.gif" /></p>
<p>When applying the ultralearning principles, we are going to be learning by doing what we want to learn (this concept is called “directness”) and starting way before we are ready. This means that we are going to start programming in a new language from day 1. We will want to get instant feedback (the code is throwing error messages or not compiling), and in this way, we will know what needs to be corrected and improved. A clear example of this is taking a programming course on <a target="_blank" href="https://www.freecodecamp.org/learn">freeCodeCamp</a> (which I highly recommend): you’ll start coding from the beginning, even though you don’t know much about code.</p>
<p>But why would we want to invest all that effort in order to learn to code? Learning a skill in a deep way like this can provide a sense of purpose in life because developing skills is meaningful.</p>
<p>One of the main themes throughout the book is having a challenge: a project on which we are going to be working on during our learning process. In our case, this project could be building a specific website or app whilst we are learning how to code. This will help to learn with purpose.</p>
<p><img src="https://media.giphy.com/media/AWv3UAFkgz39u/giphy.gif" /></p>
<p>Now, it’s important to keep in mind that if some principles or approaches are not working, we should reassess them and change what needs to be changed.</p>
<p>OK, enough introduction. Let’s start with the first principle: Metalearning.</p>
<h2 id="heading-metalearning">Metalearning</h2>
<p>Our learning journey will start by drawing a map of what learning programming looks like. Here we should be interested in knowing how programming knowledge is acquired and structured.</p>
<p>But you don’t have to start from scratch. I’ve built a Notion template summarising the core topics involved in web development, a list of roadmaps and topics that are related to programming. You can <a target="_blank" href="https://mailchi.mp/77b7cbf1b03a/web-development-notion-template">download that template</a> and modify it as you wish, expanding it according to your needs.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1663664711812/VfcoJfbLU.png" alt="image.png" class="image--center mx-auto" /></p>
<p>Going back to the principle of Metalearning, do your best to answer these three questions: “why?”, “what?”, and “how?”.</p>
<h3 id="heading-why">“Why?”</h3>
<p>In my first post in this series, I talked about the importance of having a clear why. What’s the motivation to learn to program? To help answer this question, you can talk to programmers already doing what you want to do and ask them what they like most (and least) about their jobs.</p>
<h3 id="heading-what">“What?”</h3>
<p>Build a list of knowledge and abilities you need to acquire. You can start with the Notion template I shared with you and build on top of it. Create lists of the concepts (ideas that need to be understood but not memorised), facts (things that need to be memorised), and procedures (anything that needs to be practised, actions to be performed).</p>
<h3 id="heading-how">“How?”</h3>
<p>To find out the how, you can use two methods:</p>
<h4 id="heading-method-1-benchmarking">Method 1: Benchmarking</h4>
<p>Find references on how people are learning to code. Look at the curricula used in universities, tables of content in online courses and books, and roadmaps (like the ones included in the Notion template). Try to find good quality materials.</p>
<h4 id="heading-method-2-emphasise-and-exclude">Method 2: Emphasise and exclude</h4>
<p>Considering why you want to learn to program, double down on the areas that are in line with your why. For example, you could want to learn web development to build an app to track tasks during different progress stages, like in Kanban methodology, so double down on web technologies and avoid learning low-level programming languages, like C, or game engines. </p>
<p>Once you have a clear idea about how to answer the “why”, the “what” and the “how”, it’s time to focus.</p>
<h2 id="heading-focus">Focus</h2>
<p>I covered this concept in the second post of this series when I spoke about Deep Work, but this is such an important principle that’s also present in the book Ultralearning.</p>
<p><img src="https://media.giphy.com/media/MdGUUTVHk7s1BA5Pyk/giphy.gif" /></p>
<p>We need to develop the ability to concentrate. We need to allocate portions of time in which we are going to be learning and make it easy to do so.</p>
<p>The most common struggles to focus happen when we are starting (we procrastinate) and when we need to maintain our focus (we get distracted).</p>
<h3 id="heading-procrastination">Procrastination</h3>
<p>To help cope with procrastination you can establish deadlines to help us start working on what needs to be done. It’s important to be able to recognise that we are procrastinating. We need to remember that the thing that’s unpleasant about the task is just the impulse, the first few minutes of it. Once we start doing the task (studying programming), the unpleasant sensation decreases.</p>
<p><img src="https://media.giphy.com/media/jkPTSxuolA5jy/giphy.gif" /></p>
<p>A technique that can help us here is the Pomodoro timer: set 25 minutes to do the task and allow yourself to rest for 5 minutes after that. Repeat as many times as necessary.</p>
<p>Another useful technique is to use small checkpoints: we can start studying and finish when we have read a page, a chapter, or a specific topic.</p>
<h3 id="heading-distraction">Distraction</h3>
<p>The key here is to enter a state of flow (some people call this being “in the zone”). In this state, our mind will be completely absorbed by the task we are performing. We need to set the difficulty of the task to something that’s not too hard or too easy, so we can achieve flow effortlessly.</p>
<p><img src="https://media.giphy.com/media/Mt0IKnQaKdSTu/giphy.gif" /></p>
<p>But… we shouldn’t worry too much if we don’t manage to achieve a flow state. What we can do instead is to focus on achieving short goals. Similarly to the small checkpoints described earlier, this will help us to maintain motivation.</p>
<p>We also need to maintain a balance between studying programming and resting. 50 minutes to an hour is enough for many learning tasks. After that, we can rest for a while, and repeat the cycle again. Using the Pomodoro timer could also be helpful here.</p>
<p>Additionally, we need to make sure our environment is free from distractions such as our phones, watching videos or playing games during our study sessions, distracting noises, or the lack of tools to study (like pencils, books, or a lamp).</p>
<p>We should engage with the task. We can do this by taking notes to explain difficult concepts, asking questions to the book or video course (writing them down to look for the answers later), and trying to identify where we can apply what we are learning.</p>
<p><img src="https://media.giphy.com/media/3ohc1bNYPZR8gQ5ybS/giphy.gif" /></p>
<p>Finally, if we get stuck, we should take a break and let our focus expand. We can go for a walk, grab a snack, or have a quick chat with someone. This will bring new ideas to our consciousness that we can use to unstuck ourselves.</p>
<p>Let’s now move on to the principle of Directness.</p>
<h2 id="heading-directness">Directness</h2>
<p>We will learn better by doing the thing we want to do. Do you want to build a website? Start building it and learn what you need along the way. Doing this will feel difficult, frustrating, and painful even, so we are going to want to avoid it. But what we should do is focus on solving the problems practically, instead of loading ourselves with theoretical concepts. As the author of the book says: “Doing the thing that you want to get good at is when much of the learning takes place.”</p>
<p><img src="https://media.giphy.com/media/bKnEnd65zqxfq/giphy.gif" /></p>
<p>We can apply different tactics to learn by doing.</p>
<h3 id="heading-tactic-1-project-based-learning">Tactic 1: Project-based learning</h3>
<p>We can organise our learning around producing something. For example, we can decide that we want to build the website for a restaurant, and we can divide that project into smaller pieces: user login components, menu bars, database tables for orders, etc. Then we can learn what’s needed for each of those parts. If you don’t know what you need to learn for each of the parts, jump into a forum (like Reddit), Twitter or Discord channel, and ask around to more experienced developers.</p>
<h3 id="heading-tactic-2-immersive-learning">Tactic 2: Immersive learning</h3>
<p>Surround yourself with the environment in which programming is being practised. Join Meetup groups, participate in open-source projects, explore Discord channels, and take part in hackathons or coding challenges. The objective is to look for things to do that can push us to learn new things.</p>
<h3 id="heading-tactic-3-the-overkill-approach">Tactic 3: the overkill approach</h3>
<p>Decide to do something that’s way more complex than the topic you want to learn. For example, instead of just learning JavaScript to build an interactive website, decide that you are going to teach a course about JavaScript and that this course will be publicly available. By doing this, even if we fail to deliver the course as we envisioned, we are going to be learning far more than we initially imagined when we thought about just building our JavaScript app.</p>
<h2 id="heading-closing-thoughts">Closing thoughts</h2>
<p>Now, coming to an end in this post, I want to remind you that there are still at least 5 more principles that I’ll cover in the coming posts, so you might want to <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a> to get a notification when they are published.</p>
<p>🤔 Which one of the covered principles resonated most with you? Leave your answer in the comments so we can discuss more about it.</p>
<p>Don’t forget to <a target="_blank" href="https://mailchi.mp/77b7cbf1b03a/web-development-notion-template">download the Notion template</a> in which I cover resources for learning web development and, programming in general, so you can start getting your feet wet with the programming world.</p>
<p>Thanks for reading and see you next time! 👋</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Learning how to code: what you should know first (part 2)]]></title><description><![CDATA[Are you thinking of learning how to code? I think there’s still something you need to know first…
This is the second post of a two parts series, and I’m going to cover:

The importance of Grit
The key to consistency: Habits
Why doing Deep Work is imp...]]></description><link>https://blog.damiandemasi.com/learning-how-to-code-what-you-should-know-first-part-2</link><guid isPermaLink="true">https://blog.damiandemasi.com/learning-how-to-code-what-you-should-know-first-part-2</guid><category><![CDATA[Programming Tips]]></category><category><![CDATA[learn coding]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[learning]]></category><category><![CDATA[Learning Journey]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Mon, 05 Sep 2022 18:00:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1662372587929/RD8CLZYaj.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Are you thinking of learning how to code? I think there’s still something you need to know first…</p>
<p>This is the second post of a two parts series, and I’m going to cover:</p>
<ol>
<li>The importance of Grit</li>
<li>The key to consistency: Habits</li>
<li>Why doing Deep Work is important to have productive study sessions</li>
<li>Why you should Care about Your Craft, and</li>
<li>Why you shouldn’t compare yourself to others</li>
</ol>
<p>Just in case you missed it, <a target="_blank" href="https://blog.damiandemasi.com/learning-how-to-code-what-you-should-know-first">this is the first article</a> of this series.</p>
<p>You can watch this content on my <a target="_blank" href="https://youtu.be/6UZmSZ8En_Q">YouTube video</a>:</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/6UZmSZ8En_Q"></iframe>

<p>If you missed the first post, you should consider <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribing to my newsletter</a> so you can get a notification when I publish my videos.</p>
<p>In this post, we are going to continue developing an attitude and mindset that will allow us to face the challenge of learning programming in the best way possible.</p>
<p>Let's start by discussing Grit.</p>
<h2 id="heading-grit">Grit</h2>
<p>Grit can be defined as a fierce determination to perform our work. Grit means being able to endure setbacks and work hard. Once more, keeping in mind our "why" will be very helpful here.</p>
<p>We can have a high potential (or almost none), but what’s really important is what we do with it.</p>
<p>Someone with great potential, like a person that understands mathematics and logic easily, but with no grit, will not be able to progress far in the programming journey.</p>
<p><img src="https://media.giphy.com/media/WRQBXSCnEFJIuxktnw/giphy.gif" /></p>
<p>On the other hand, someone with low potential, like a person that needs to read a definition several times to really understand it, but with plenty of grit, will progress far in programming.</p>
<p>If you want to know more about this topic, I recommend you read the book <a target="_blank" href="https://amzn.to/3oGaYMR">Grit</a>.</p>
<p>Let's now move on to Habits.</p>
<h2 id="heading-habits">Habits</h2>
<p>We need to decide what our identity will be and develop habits that can sustain that identity. Our habits shape our identity, and, in turn, our identity also shapes our habits.</p>
<p>Ask yourself: What type of identity do you want to develop? Do you want to be a programmer? What habits does a programmer have?</p>
<p><img src="https://media.giphy.com/media/13HgwGsXF0aiGY/giphy.gif" /></p>
<p>We can define our identity as follows: “I’m a programmer that takes care in giving the best of himself or herself at this very moment“. Then, when we are about to do something that goes against that identity, we will have a clear indication of what we should be doing:</p>
<ul>
<li>“Will a programmer that’s giving the best of herself sit to watch a Netflix show, or, instead, would she choose to work on a project for her portfolio?”</li>
<li>“Willa programmer that’s giving the best of himself choose to work or study without a break, or choose to go outside for a while to clear his head and stretch the body?”</li>
</ul>
<p>The key here is not to fool ourselves, because we are the easiest person to fool.</p>
<p>To know more about this topic, I recommend you to read the book <a target="_blank" href="https://amzn.to/3oItGmY">Atomic Habits</a>.</p>
<p>Let's now talk about Deep Work.</p>
<h2 id="heading-deep-work">Deep Work</h2>
<p>According to Carl Newport, Deep Work is a “professional activity performed in a state of distraction-free concentration that pushes your cognitive capabilities to their limit”. The key here is “distraction-free concentration”.</p>
<p>If you wish to know more about this, read the book <a target="_blank" href="https://amzn.to/3qtrQrj">Deep Work</a>.</p>
<p>One of the main obstacles to overcome in order to achieve distraction-free concentration are social networks (Facebook, TikTok, Reddit, Twitter, etc.). When we are studying programming, or working on a project, we should avoid using social networks if we want to keep the focus on the task at hand.</p>
<p><img src="https://media.giphy.com/media/aDan8Uo90usaCu2Z26/giphy.gif" /></p>
<p>In his book, Carl Newport recommends allocating specific days and times in which we are going to be studying, distraction-free. This will help us to:</p>
<ul>
<li>avoid burnout,</li>
<li>avoid pilling up subjects to learn or projects to practice, and</li>
<li>keep the focus on the studying activity.</li>
</ul>
<p>The hours of our day are not all equal. We are going to be more productive at certain times of the day rather than others. For example, we could study best early in the morning, or in the late afternoon, so we need to pay attention to which time serves us better according to what we want to do.</p>
<p>What I usually do is assign a relative value to the different parts of the day. Early mornings are my most valuable hours. I’m full of energy, no one is going to interrupt me, and I can use those moments to study programming or work on a project, no matter the day of the week.</p>
<p>Let's now Care about our craft.</p>
<h2 id="heading-care-about-your-craft">Care about your craft</h2>
<p>What we do in our work and in our studying activities will be a reflection of the type of professional we want to be. Therefore, it will be in our best interest to do things the best way we can:</p>
<ul>
<li>We shouldn’t be mindlessly studying, overlooking important topics.</li>
<li>We should try to care about the quality of the code we are writing (even if it just how well indented it is).</li>
</ul>
<p>The objective here is to do whatever we do, in the best way we can, given our current circumstances.</p>
<p>I find it very helpful to ask myself if my future self (not someone else) would be proud of how and what I’m doing right now.</p>
<p><img src="https://media.giphy.com/media/aDcvK946SC3GwCqLk8/giphy.gif" /></p>
<p>To learn more about this topic, you should read the book <a target="_blank" href="https://amzn.to/3KIu3IB">The Pragmatic Programmer</a>.</p>
<p>Now... remember not to compare yourself with others.</p>
<h2 id="heading-dont-compare-yourself-to-others">Don’t compare yourself to others</h2>
<p>We are all different, and you don’t know what paths have led people to where they are today. So, comparing yourself with someone else has no point.</p>
<p>Instead of comparing ourselves with someone else, choose to make that comparison with your own self.</p>
<ul>
<li>Where were you 2, 5, or 10 years ago? Are you in a better position today? Did you know how to program 5 years ago? What about today?</li>
<li>Where could you be in 2, 5, or 10 years in the future, if you continue doing what you are doing? If you keep studying programming, could you become a senior developer 5 years from now?</li>
</ul>
<p><img src="https://media.giphy.com/media/LMhuP91QIPo52/giphy.gif" /></p>
<p>This concept is so important to me that I’ve written down the question “How would my life be in 10 years if I stick to this?” (speaking of programming), and hung it over my monitor, together with my list of my "whys".</p>
<h2 id="heading-finishing-up">Finishing up</h2>
<p>I want to remind you that this is just a guide to what I consider to be the best way to set the right mindset and attitude toward becoming a software developer.</p>
<p>Which one of these concepts resonated the most with you? Leave it in the comments so we can see which ones are the favourite picks!</p>
<h2 id="heading-next-posts">Next posts</h2>
<p>In the next posts, I’m going to cover the concepts and techniques described in the book <a target="_blank" href="https://amzn.to/3PNLqJM">Ultralearning</a>, so you may want to <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a> to get a notification when the video is out.</p>
<p>Thanks for reading, and see you next time! 👋</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Learning how to code: what you should know first (part 1)]]></title><description><![CDATA[Introduction
Are you thinking of learning how to code? 🤔 I think there’s something you need to know first…
This is the first post of a two-part series. In it, I’ll cover the following topics:

The importance of having a good idea of Why you want to ...]]></description><link>https://blog.damiandemasi.com/learning-how-to-code-what-you-should-know-first</link><guid isPermaLink="true">https://blog.damiandemasi.com/learning-how-to-code-what-you-should-know-first</guid><category><![CDATA[Programming Tips]]></category><category><![CDATA[learn coding]]></category><category><![CDATA[#codenewbies]]></category><category><![CDATA[learning]]></category><category><![CDATA[Learning Journey]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Tue, 30 Aug 2022 19:30:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1661854333020/Q_9fAeOuC.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Are you thinking of learning how to code? 🤔 I think there’s something you need to know first…</p>
<p>This is the first post of a two-part series. In it, I’ll cover the following topics:</p>
<ol>
<li>The importance of having a good idea of <strong>Why you want to learn how to code</strong></li>
<li>How <strong>Passion</strong> is overrated</li>
<li>Why it’s important to have a <strong>Growth mindset</strong></li>
<li>Why you shouldn’t rely on <strong>Motivation</strong></li>
<li>Why focus on <strong>Systems over Goals</strong></li>
</ol>
<p>When starting the journey of learning programming, one tends to focus on the programming languages to learn, courses to take and books to read. But I think the most important thing is to develop an attitude and mindset that allow us to face the challenge of learning programming in the best way possible.</p>
<p>I discuss these concepts in my first published YouTube video! You can <a target="_blank" href="https://youtu.be/VJZEEqHC63o">watch it here</a>.</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/VJZEEqHC63o"></iframe>

<h3 id="heading-have-a-clear-idea-of-why-you-want-to-learn-how-to-code">Have a clear idea of why you want to learn how to code</h3>
<p>Knowing our why will help us to keep going when motivation fails us, and things get difficult 😰.</p>
<p>Ideally, your why would be internally focused, so don’t start studying programming just because you want to earn more money (something external). Programming is very hard, and doing it just for the money may not be a reason powerful enough to stick with it 💰💰💰.</p>
<p>Instead, try to find internal reasons why you want to study programming. For example, some of the internal reasons that work for me are: </p>
<ul>
<li>To learn and grow personally and professionally.</li>
<li>To choose better quality problems and to choose a struggle to enjoy.</li>
<li>To build mastery at something.</li>
<li>To be an inspiration to others (family, friends, strangers).</li>
</ul>
<p>Having a clear why will give meaning to the effort we are going to invest in our learning journey. </p>
<p>You can read more about this topic in the book <a target="_blank" href="https://amzn.to/3R0nnaW">Man’s Search for Meaning</a>.</p>
<p>I actually have my why printed and hung on top of my monitor. I use it as a tool to lift my mood and motivation when I don’t feel like studying or when I’m stuck with a programming problem or bug. It reminds me of what I have chosen to do and the reasons behind that choice, something that’s very helpful as a reminder that I need to keep going in spite of feeling uncomfortable.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34y2r7lthgo06jjk1gar.png" alt="My Why" /></p>
<p>By deciding to become a programmer, I’m choosing to have better problems, because problems are going to be present no matter what we decide to do. One thing is to have problems that someone enforces on you, and a very different thing is to choose your own problems. </p>
<p>You can read more about choosing your own problems in the book <a target="_blank" href="https://amzn.to/3wCBdbs">The Subtle Art of Not Giving a F*ck</a>.</p>
<h3 id="heading-passion">Passion</h3>
<p>I’ve been struggling to find my passion for most of my life. Ultimately, I’ve learned that passion is not something that you find, but something you build day by day.</p>
<p><img src="https://media.giphy.com/media/ItvHXpVnqGffddbNBA/giphy.gif" /></p>
<p>You can choose an activity that sparks interest in you, but that interest will evolve into a passion over time. It’s because of this that we shouldn’t pay too much attention to passion when we are just starting with programming and give it time to build up.</p>
<h3 id="heading-growth-mindset">Growth mindset</h3>
<p>The Growth mindset is a concept developed by psychologist Carol Dweck. You can read more about it in her book <a target="_blank" href="https://amzn.to/3AU7ixS">Mindset</a>.</p>
<p>The way in which we see ourselves deeply affects how we manage in life. If we perceive ourselves as someone who is not intelligent, or incapable of learning programming, we will start our learning journey on the wrong foot. </p>
<p>On the other hand, if we understand that intelligence is something we can develop over time, as well as most of our skills, we are going to be better prepared mentally to begin studying programming.</p>
<p><img src="https://media.giphy.com/media/d3mlE7uhX8KFgEmY/giphy.gif" /></p>
<p>The growth mindset is based on the idea that our qualities can be cultivated and developed through effort.</p>
<p>You can have a deeper dive into this topic by reading <a target="_blank" href="https://ccsre.stanford.edu/publications/mindset-updated-edition-changing-way-you-think-fulfill-your-potential">this article</a>.</p>
<h3 id="heading-motivation">Motivation</h3>
<p>According to Steven Pressfield (author of The War of Art), motivation is the push we feel when “the pain of not doing something is worse than the pain of doing it”. For example, the pain of being in a job we hate is greater than the pain we feel when we must sit to study programming to change our careers, so we are pushed to sit and study how to code.</p>
<p>There are two types of motivation: </p>
<ul>
<li><strong>External:</strong> it’s outside of our control. For example, study programming to get a good salary in the future, solve a bug to receive praise from others, and prove someone’s code is wrong so others can see us as intelligent coders.</li>
<li><strong>Internal:</strong> it’s in our control, within ourselves. For example: study programming to get good at it and gain mastery, solve a bug because we love our craft (our code), or solve someone’s else code because we care about delivering a good product.</li>
</ul>
<p>We should focus on internal motivation, as it’s the only one we can control.</p>
<p><img src="https://media.giphy.com/media/J7jsbfcJ2O5eo/giphy.gif" /></p>
<p>Furthermore, it’s very important to realise that motivation is the result of an action, not the cause of it. This means that motivation will come after we start doing the thing we need to do (but don’t feel like doing it). You can know more about this topic by reading the book <a target="_blank" href="https://amzn.to/3Q27VtE">Atomic Habits</a>.</p>
<p>So, the key to keeping ourselves motivated is to make the thing we need to do as easy to start as possible. We can arrange a calendar with the times and places to study programming, for example, so our decision-making process can be automated.</p>
<p>We can follow the same ritual or habit each time we sit to study programming, thus conditioning our study activity. For example, we can choose the same place in the house, at the same time in the day, with the same music playlist, each time we sit to study.</p>
<p>You can have a deeper dive into this topic by reading <a target="_blank" href="https://jamesclear.com/motivation">this article</a>.</p>
<h3 id="heading-systems-over-goals">Systems over Goals</h3>
<p>It’s important to have a goal, a clear objective. But it’s also important not to focus too much on it. What we should do instead is to focus on the system we are going to use in order to achieve our goal. </p>
<p>Those who achieve a goal and those who don’t, ultimately have the same goal. So, having a goal by itself is not a guarantee to get it. Many people want to become programmers, but not all of them end up achieving that.</p>
<p>Focusing on our systems will help us to achieve our goals by providing discipline, reminding us why we are doing what we are doing, and avoiding procrastination.</p>
<p>For example, our system could look like this: </p>
<ul>
<li>Wake up early</li>
<li>Take a shower so we can be more awake</li>
<li>Make our breakfast</li>
<li>Sit in front of the computer with our breakfast</li>
<li>Open the programming book or online course</li>
<li>Start to study whilst we are having breakfast, and do this for at least one hour (we are stacking habits here, as described in the book Atomic Habits)</li>
</ul>
<p>By focusing on the process (our habits) we are working on our system every day. We are focusing on the immediate, without worrying too much about the future: all the programming languages we don’t know, or how much time is left to become a programmer. By focusing on the day-by-day tasks, we can diminish our anxiety. </p>
<p><img src="https://media.giphy.com/media/1FMaabePDEfgk/giphy.gif" /></p>
<p>If we keep applying our system, day in and day out, we are going to achieve our goal of becoming a programmer.</p>
<p>You can have a deeper dive into this topic by reading <a target="_blank" href="https://jamesclear.com/goals-systems">this article</a>.</p>
<h3 id="heading-finishing-up">Finishing up…</h3>
<p>I want to remind you that this is just a guide to what I consider to be the best way to set the right mindset and attitude toward becoming a software developer.</p>
<p>Which one of these concepts resonated the most with you? Leave it in the comments so we can see which ones are the favourite picks!</p>
<h3 id="heading-next-post">Next post</h3>
<p>In the next post, I’m going to cover the rest of these concepts, so you may want to <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a> to get a notification when the post is out.</p>
<p>See you next time! 👋</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[How to debug a React app]]></title><description><![CDATA[Introduction
Since I started working as a software developer, I find myself spending the majority of the day debugging a big react app. This is not the result of a poorly implemented code, but what I feel is the natural process in which I find myself...]]></description><link>https://blog.damiandemasi.com/how-to-debug-a-react-app</link><guid isPermaLink="true">https://blog.damiandemasi.com/how-to-debug-a-react-app</guid><category><![CDATA[React]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Bugs and Errors]]></category><category><![CDATA[debugging]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Mon, 02 May 2022 19:37:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1651391962334/x6yHFTwUq.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Since I started working as a software developer, I find myself spending the majority of the day debugging a big react app. This is not the result of a poorly implemented code, but what I feel is the natural process in which I find myself involved daily:</p>
<ul>
<li>I can debug to find the root cause of an actual <strong>bug</strong></li>
<li>Or I can debug as part of the normal <strong>development process</strong> (most likely)</li>
</ul>
<p><img src="https://media.giphy.com/media/10eJOwQ9BKrF72/giphy.gif" /></p>
<p>When hunting for actual bugs in the code, we need to focus on tools and systematic processes to analyse the code in search of what's not working and accept the fact that the person that wrote the code may not be available to answer our questions. Sometimes, though, the bug might have been introduced by ourselves 🙋‍♂️, and we can find it difficult to step in the shoes of our past selves in order to understand why we did what we did. No matter what's the case, they all have something in common: we need to use tools to help us debug the app and find what's wrong with it.</p>
<p>More often than not, I feel debugging is not solving a particular issue affecting a customer, but the natural process inherent to the development of software. If I want to create a feature for an existing app (or build one from scratch), I will often face code that is not working as it is supposed to 🤷‍♂️, and here is when I will pull out the "debugging arsenal" to find out what's wrong with the code in order to keep moving forward in the development process.</p>
<h3 id="heading-a-special-note-when-a-bug-is-introduced-by-ourselves">A special note: when a bug is introduced by ourselves</h3>
<p>Let's apply some logic here: 🤔 <em>if <strong>we have created a bug</strong>, then <strong>we are not in the position to be able to solve it</strong>, because if we could, we wouldn't have created it in the first place!</em> This is why we need additional tools that can help us to step outside ourselves in the process of finding a bug, just like if we were detectives trying to solve a crime in which we are the prime suspect. We need to be methodical, go step by step, test a lot, and gather evidence. Here is where debugging tools come to our rescue.</p>
<h2 id="heading-breakpoints-and-the-debugger">Breakpoints and the <code>debugger</code></h2>
<p>When debugging a React app, I often find breakpoints to be very helpful. There are two main ways in which we can use them:</p>
<ul>
<li>By writing the <code>debugger</code> statement in our source code</li>
<li>By clicking on a specific line of the code in the Chrome web browser (or Firefox, Edge, etc.) Developer Tools.</li>
</ul>
<h3 id="heading-using-the-debugger-statement">Using the <code>debugger</code> statement</h3>
<blockquote>
<p>The debugger statement invokes any available debugging functionality, such as setting a breakpoint. If no debugging functionality is available, this statement has no effect. - <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger">Source</a></p>
</blockquote>
<p>Let's say we have a project in which we are interested in finding out what's happening in a particular section of code. In this example, I'm using the source code of my portfolio site, which you can find in <a target="_blank" href="https://github.com/Colo-Codes/portfolio-v2">this GitHub repository</a>). I have introduced a bug, and now I will search for it using the debugger.</p>
<p>In this particular bug, the third animation related to the portfolio title is not working correctly, so I can write the <code>debugger</code> statement in that section of the code.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650856471474/yD4jsNY4D.png" alt="Hunting a bug" /></p>
<p>Once the file is saved and compiled, as soon as I reload the page and the browser parses that code, it will stop on the line that has the <code>debugger</code> statement on it. The browser will then display useful data in the Developer Tools pane.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650856488132/Og9HWSBcs.png" alt="Developer Tools" /></p>
<p>We can see the value of variables at that moment by <strong>hovering</strong> over them in the source code, or in the panel located on the right, in the <strong>Scope</strong> section. Thanks to this, I can see that the value of the <code>setIsAnimated1</code> function is being called with the wrong value.</p>
<h3 id="heading-using-breakpoints">Using breakpoints</h3>
<p>Breakpoints work in a very similar way. To enable breakpoints we need to open our site in a web browser (I'm using Chrome in this case) and open the <strong>Developer Tools</strong>. Now, if we click in the <strong>Sources</strong> tab and in the tab with the <strong>file name</strong> that we are interested in debugging, we will see our source code once more, as happened in the previous method using <code>debugger</code>.</p>
<blockquote>
<p>Note: for more information about the <strong>Developer Tools</strong>' <strong>Source</strong> tab, read <a target="_blank" href="https://developer.chrome.com/docs/devtools/javascript/">this article</a>.</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1650856786675/i5YnhjWbG.png" alt="Using breakpoints" /></p>
<p>Now, in order to create a breakpoint, we can click on the margin just next to the line number. These breakpoints will be listed in the panel shown on the right, in the <strong>Breakpoints</strong> section. We can now reload the page, and the loading of it will stop at the breakpoints we have set (we can click the play button to tell the browser that it should continue executing the code and, thus, loading the page).</p>
<p>If you want to learn more about this topic, and even set <strong>conditional breakpoints</strong> or <strong>stop the code execution when a node is removed</strong>, for example, I think you should read the <a target="_blank" href="https://developer.chrome.com/docs/devtools/javascript/breakpoints/">Pause your code with breakpoints</a> article.</p>
<h2 id="heading-react-developer-tools">React Developer Tools</h2>
<p>The previous debugging tools apply not only to React apps but to any JavaScript app. But, when working with React apps in specific, we have a very useful tool: the <strong>React Developer Tools</strong> browser extension. You can find this extension by searching for it on the corresponding browser extension marketplace. For example, for Chrome, you can install it from <a target="_blank" href="https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi">this link</a>.</p>
<p>The react Developer Tools is a set of two main tools:</p>
<ul>
<li>the <strong>Components</strong> tool, where you can analyse the structure of the components,</li>
<li>and the <strong>Profiler</strong> tool, where you can see the time each component took to render and how they are updated.</li>
</ul>
<h3 id="heading-the-components-tab">The Components tab</h3>
<p>In the Components tab, you will be able to see the component structure of the site you are analysing (left panel), as well as the <code>props</code>, <code>hooks</code> (for function components) or <code>state</code> (for class components) that a selected component has (right panel), together with a list of the ancestors that ended up rendering the component you have selected.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651387233982/1SZvzsci2.png" alt="Components" /></p>
<p>Just by the information this tool is presenting I think it's very valuable, but that's not all! You can also modify the <code>props</code> and <code>hooks</code> of the component you have selected, and this will affect the site in real-time, something that's very useful for debugging purposes. 🤯</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651387895341/rOl0YE0Yo.png" alt="Modifying a component" /></p>
<h3 id="heading-the-profiler-tab">The Profiler tab</h3>
<p>As mentioned earlier, we can use the Profiler to record the time it took each component to be rendered. In order to do so, we need to click the <code>Start profiling</code> or <code>Reload and start profiling</code> buttons.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651388146779/us3oTSNOg.png" alt="Profiler" /></p>
<p>Once the site has been rendered, we'll need to click the <code>Stop profiling</code> button, and we will see a graph detailing the time each of the components took to be rendered. Instead of clicking on the <code>Stop profiling</code> button, we can interact with the site, clicking on buttons, menus, etc., and the profiler will record these interactions at a component level.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651388376024/1mCiEIBT7.png" alt="Profiler record" /></p>
<p>This is very helpful when we need to debug certain interactions with our app.</p>
<h3 id="heading-bonus-check-why-a-component-was-rendered">Bonus: check why a component was rendered</h3>
<p>If we are interested in knowing why a particular component was rendered, we can activate this feature by clicking on the <strong>gear icon</strong>, then in the <strong>Profiler tab</strong>, and finally ticking the <code>Record why each component rendered while profiling.</code> checkbox. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651388506920/mt3uyiIFx.png" alt="Extra options" /></p>
<p>Now we need to start a new profiling, just as before, and we'll be able to see extra information concerning the reasons why a component was rendered. Some of the most common reasons for a component to (re)render are, as you can see by using this tool:</p>
<ul>
<li>the parent component was rendered</li>
<li>its <code>props</code> changed</li>
<li>its state-related <code>hooks</code> changed</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651388748200/TsdPOp0gY.png" alt="Re-renders" /></p>
<p>I have found that recording why a component was rendered saved me many headaches when debugging a complex React app.</p>
<h2 id="heading-workflow-debugging">Workflow debugging</h2>
<p>There are some occasions in which none of the previously mentioned tools can help us to find a bug. In this case, I like to use a "workflow debugging" approach. This method consists in start analysing the code in the closest region to where the bug is happening, and following the flow of the code "upstream": which method is creating this section of code, what's its parent, grand-parent, etc.</p>
<p>Let's say a header in our app has a wrong margin. We can start by analysing the code closest to this header, looking for methods that can be altering its margin, and then analysing the code that's affecting the header at higher levels, like an inverse <a target="_blank" href="https://en.wikipedia.org/wiki/Matryoshka_doll">Matryoshka doll</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1651389275457/t8kbBo3Im.png" alt="Matryoshka doll" />
<em>Photo by Didssph on Unsplash</em></p>
<h2 id="heading-the-debugging-methodical-process">The debugging methodical process</h2>
<p>In order to be consistent in how we proceed to find a bug, we can create our own process or framework by combining these tools and approaches. For example, when facing a bug we could:</p>
<ol>
<li>Start by analysing the workflow the code is following that affects a particular section of code.</li>
<li>If nothing wrong is found, we could use the React  Developer Tools to analyse each component closely.</li>
<li>If that analysis is not delivering results, we could apply breakpoints at different sections in the code and see how the variables are being altered.</li>
<li>If everything else fails, just comment out pieces of code and see what happens. Experiment.</li>
</ol>
<h2 id="heading-conclusion">Conclusion</h2>
<p>We have many  tools at our disposal to look for bugs, but it's not always easy to find them. I think it's very important not to feel frustrated when debugging an app, and to focus on a systematic, step by step process to analyse the code.</p>
<p>I'm sure I haven't covered all the techniques available for debugging a React app, so if you have one that's your favourite and that is not listed here, please share it in the comments so we can all learn from it. 😊</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Problem-solving techniques to avoid yelling at your computer]]></title><description><![CDATA[I have been facing some tough code monsters at work lately. I guess I'm out of shape and my sword isn't sharp enough, because I find myself struggling greatly.
This is the reason I decided to upgrade some of my attributes (especially intelligence and...]]></description><link>https://blog.damiandemasi.com/problem-solving-techniques-to-avoid-yelling-at-your-computer</link><guid isPermaLink="true">https://blog.damiandemasi.com/problem-solving-techniques-to-avoid-yelling-at-your-computer</guid><category><![CDATA[Web Development]]></category><category><![CDATA[problem solving skills]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Tue, 12 Apr 2022 19:58:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1649754094741/GwVlzujUc.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I have been facing some tough code monsters at work lately. I guess I'm out of shape and my sword isn't sharp enough, because I find myself struggling greatly.</p>
<p>This is the reason I decided to upgrade some of my attributes (especially intelligence and wisdom) in order to help me cope with this struggle. Luckily, I found a great loot: <a target="_blank" href="https://www.penguin.com.au/books/think-like-a-programmer-9781593274245">Think Like a Programmer, by Spraul, V. Anton</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1649557247984/KqylXGyBy.png" alt="Think Like a Programmer" /></p>
<p>This book explains how we should approach problems in order to solve them in a methodical manner. I have just started reading it, but I have already learned the basics of problem-solving techniques, and I wanted to share them with you.</p>
<h2 id="heading-general-problem-solving-techniques">General Problem-Solving Techniques</h2>
<h3 id="heading-1-always-have-a-plan">1. Always Have a Plan</h3>
<p>When working on a solution to a problem, starting by typing code without a clear direction in mind is not a good idea. Sometimes I found myself typing without putting too much thought into it, just for the sake of building something fast and, if I’m "lucky", stumbling with the solution to the problem. This is an awful approach.</p>
<p>According to the book, we should always have a plan. In the beginning, the plan usually will consist in how we are going to find the solution to our problem.</p>
<p><img src="https://media.giphy.com/media/l0IylOPCNkiqOgMyA/giphy.gif" /></p>
<p>Our plan will, most likely, require alterations along the way, and this is OK. Without a plan, we are directionless, we miss on evaluating possible scenarios and different alternatives to find a solution.</p>
<blockquote>
<p>“I have always found that plans are useless, but planning is indispensable.” - General Dwight D. Eisenhower</p>
</blockquote>
<p>I prefer to think about a plan as a map that allows seeing all the possible roads to a destination (or even draw new ones as they manifest along the journey).</p>
<p>The book emphasises that plans allow us to set intermediate goals, and achieve them. This is of extreme importance because by achieving these intermediate goals we feel we are making progress towards the solution. As we are usually going to struggle until the solution is found, feeling that we are making progress will help to cope with despair.</p>
<h3 id="heading-2-restate-the-problem">2. Restate the Problem</h3>
<p>A problem that at first seems incommensurable, could be expressed in other terms, or in a different manner. At first sight, we might think the problem is one way, but upon restating it we can discover that it's something different.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1649558249544/tZhDCAqMR.png" alt="Change of perspective" /></p>
<p>Restating the problem in new, simpler or more familiar terms, could help us to redefine it and to come up with different solutions (hopefully, easier to implement than what we first thought would be).</p>
<p>Restating the problem could be thought of as one of the planning steps in solving a problem, and if we do restate the problem, we will be making progress towards the solution.</p>
<h3 id="heading-3-divide-the-problem">3. Divide the Problem</h3>
<p>You don’t eat an elephant in one bite but in multiple small bites. Actually, I have never eaten an elephant, and I wouldn't either, as they are one of my favourite animals! But the metaphor is still applicable.</p>
<p><img src="https://media.giphy.com/media/9S1zkYeluvYwzoj9pC/giphy.gif" /></p>
<p>If the problem is too complex, divide it into smaller chunks. If we need to ask for user input, process the data, and store it in a database, start by building a simple input field that prints on the console, and build on top of that.</p>
<p>If we need to build a complex loop, we can start with one line, or a couple of lines, and manually perform the tasks that the loop should do until we have a clear idea of what is needed.</p>
<p>This is the technique I use the most when coding and is the one that helps me to keep my sanity when facing complex problems.</p>
<h3 id="heading-4-start-with-what-you-know">4. Start with What You Know</h3>
<p>After dividing the problem into pieces, we can start by solving what we already know how to solve. Later we can focus on the tricky parts of it.</p>
<p><img src="https://media.giphy.com/media/13f5iwTRuiEjjW/giphy.gif" /></p>
<p>Does our problem require finding unique values? If we know how to use a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/Set"><code>Set</code></a> in JavaScript, that could help us to solve it.</p>
<blockquote>
<p>By starting with what you know, you build confidence and momentum toward the goal. - Spraul, V. Anton</p>
</blockquote>
<h3 id="heading-5-reduce-the-problem">5. Reduce the Problem</h3>
<p>If the problem is too complex or if it can’t be subdivided into smaller pieces, we can reduce its complexity by applying (or removing) constraints to it.</p>
<p><img src="https://media.giphy.com/media/IHnROpQICe4kE/giphy.gif" /></p>
<p>Should a user be able to drag and drop tasks in our to-do app? Let’s write step by step all that is needed in order to implement this functionality and eliminate (for now) what’s too complex. Later we could review what we have left out and ask for help in order to solve those specific aspects of the problem (and not the whole problem).</p>
<p>The author of the book uses an excellent example here:</p>
<blockquote>
<p>One never wants to be reduced to saying, “Here’s my program, and it doesn’t work. Why not?” Using the problem-reduction technique, one can pinpoint the help needed, saying something like, “Here’s some code I wrote. As you can see, I know how to find the distance between two three-dimensional coordinates, and I know how to check whether one distance is less than another. But I can’t seem to find a general solution for finding the pair of coordinates with the minimum distance.” - Spraul, V. Anton</p>
</blockquote>
<h3 id="heading-6-look-for-analogies">6. Look for Analogies</h3>
<p>We are often solving the same problem, but in a different flavour, over and over again.</p>
<p><img src="https://media.giphy.com/media/iGXpb2gJM3JkQXfBXv/giphy-downsized-large.gif" /></p>
<p>We should pay attention to similarities between the problem we have in front of us, and other problems we solved in the past. </p>
<p>If the problem is totally new, that’s great, because it’s a great opportunity to put it inside our “cookie jar of solved problems” for future use.</p>
<h3 id="heading-7-experiment">7. Experiment</h3>
<p>If everything looks dark and we don’t know why the program is behaving as if it had life on its own, experimenting with it can help us.</p>
<p><img src="https://media.giphy.com/media/QU1pSfyEynvgY/giphy.gif" /></p>
<p>I usually use <code>console.log</code> as a “probing” method to find out what’s happening. We can tweak something here and there and see how the output gets modified. Then make hypotheses and put them to the test.</p>
<p>It is important to make a distinction between <strong>experimenting</strong> and <strong>guessing</strong>. Experimenting is a controlled process: we gather the information that can help us solve the problem. Guessing is typing code mindlessly and hoping for the best.</p>
<h3 id="heading-8-dont-get-frustrated">8. Don’t Get Frustrated</h3>
<p>The final technique is more of a recommendation than a technique in itself: don't get frustrated.</p>
<p><img src="https://media.giphy.com/media/3ohs81rDuEz9ioJzAA/giphy-downsized-large.gif" /></p>
<p>I must confess that I had felt frustrated many times, and I can assure you that it didn’t help me one bit to solve the problem.</p>
<p>How does the rage you feel inside of you help you solve a problem? Why are you angry? Or a better question even: <strong>why do you choose to be angry?</strong></p>
<p>Here is where two maxims of the Stoic philosophy come for our help:</p>
<blockquote>
<p>“We suffer more often in <strong>imagination</strong> than in <strong>reality</strong>.” - Seneca</p>
</blockquote>
<p>And:</p>
<blockquote>
<p>“The chief task in life is simply this: to identify and separate matters so that I can say clearly to myself which are <strong>externals not under my control</strong>, and which have to do with the <strong>choices I actually control</strong>. Where then do I look for good and evil? Not to uncontrollable externals, <strong>but within myself to the choices that are my own…</strong>” - Epictetus, Discourses, 2.5.4–5</p>
</blockquote>
<p>We have to learn to manage how we respond to frustration. As developers, it’s very likely that we are going to face bugs in our code or complicated features to implement on a daily basis, and a good portion of them are going to be difficult to solve. Hence, it’s better to learn not to feel frustrated because of this, but rather think of this as a “feature” of our job.</p>
<p>I often remember <a target="_blank" href="https://markmanson.net/life-purpose">this question</a>:</p>
<blockquote>
<p>What shit sandwich do you want to eat? Because eventually, we all get served one. - Mark Manson</p>
</blockquote>
<p>And then I realise: "I have chosen this struggle, so I shouldn't get mad because of it."</p>
<p>Something that can help us to get out of a frustrating moment is to iterate on these steps again: build a new plan, restate the problem differently, create different problem divisions and alterations, etc.</p>
<h2 id="heading-practice-time">Practice time</h2>
<p>Now, let’s put all these concepts into practice. I have adapted one of the problems presented in the book from C++ to JavaScript for convenience purposes.</p>
<p>By the way, you can get the source code from my repository (I plan on keep adding new problems as I move forward in reading the book): <a target="_blank" href="https://github.com/Colo-Codes/think-like-a-programmer-book-problems">think-like-a-programmer-book-problems</a>.</p>
<pre><code class="lang-text">Write a program that uses a single console.log statement to produce a pattern of hash symbols shaped like half of a perfect 5 x 5 square (or a right triangle):

#####
####
###
##
#

Spraul, V. Anton. Think Like a Programmer (p. 26). Adapted from C++ to JavaScript by Damian Demasi.
</code></pre>
<h3 id="heading-the-plan">The plan</h3>
<p>We are going to take the problem, divide it into smaller pieces, and start solving the pieces one by one. We are going to search for analogies along the way. In the end, we will put everything together.</p>
<h3 id="heading-restating-the-problem">Restating the problem</h3>
<p>After analysing the problem a bit deeper, we can see that there is a pattern that needs to be printed and that this pattern gets altered on each line. I don’t know about you, but this is suggesting “iteration” to me, so we will use some sort of loop to solve it.</p>
<p>Our restatement could be something like: “write a loop that prints a line of hash symbols where each line gets one less hash symbol that the previous one, starting with 5 symbols on the first line.”</p>
<h3 id="heading-divide-the-problem">Divide the problem</h3>
<p>We can divide this problem like this:</p>
<ol>
<li>Print a line of 5 hash symbols</li>
<li>Print 5 lines of 5 hash symbols</li>
<li>Find a way to decrease a number as a count grows</li>
<li>Apply point 3 to point 2</li>
</ol>
<h3 id="heading-start-with-what-you-know">Start with What You Know</h3>
<p>Let’s start by the easy part: print 5 hashes:</p>
<pre><code class="lang-javascript">    <span class="hljs-keyword">let</span> halfSquare = <span class="hljs-string">''</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
        halfSquare += <span class="hljs-string">'#'</span>;
    }
    <span class="hljs-built_in">console</span>.log(halfSquare);
</code></pre>
<p>Output:</p>
<pre><code class="lang-text">#####
</code></pre>
<p>Great! It’s not much, but it’s honest work 😅.</p>
<h3 id="heading-reduce-the-problem">Reduce the Problem</h3>
<p>Now, instead of printing five lines with a decreasing number of hashes, let's print 5 lines with the same number of hashes. By doing this we are simplifying the problem and reducing its complexity and constraints.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> halfSquare = <span class="hljs-string">''</span>;
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> j = <span class="hljs-number">1</span>; j &lt;= <span class="hljs-number">5</span>; j++) {
            halfSquare += <span class="hljs-string">'#'</span>;
        }
        halfSquare += <span class="hljs-string">'\n'</span>;
    }
    <span class="hljs-built_in">console</span>.log(halfSquare);
</code></pre>
<p>Output:</p>
<pre><code class="lang-text">#####
#####
#####
#####
#####
</code></pre>
<h3 id="heading-look-for-analogies">Look for Analogies</h3>
<p>In the previous block of code, we are using something we already know (a loop) to repeat the line of hashes 5 times, resulting in a nested <code>for</code> loop. This is our analogy.</p>
<h3 id="heading-experiment">Experiment</h3>
<p>Now we need to find a way to decrease a value as the loop increases. In the book, this is referenced as “counting down by counting up”.</p>
<p>Let’s experiment to find this behaviour starting with the easier part: counting up.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
    <span class="hljs-built_in">console</span>.log(i);
}
</code></pre>
<p>Output:</p>
<pre><code class="lang-text">1
2
3
4
5
</code></pre>
<p>After looking at the expected end result (the triangle of hashes) and comparing it with our experiment, we can think of these numbers as the number of hashes that need to be subtracted on each line plus 1:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Line</td><td>Result</td></tr>
</thead>
<tbody>
<tr>
<td>First line:</td><td>5 hashes - 1 + 1 = 5 hashes</td></tr>
<tr>
<td>Second line:</td><td>5 hashes - 2 + 1 = 4 hashes</td></tr>
<tr>
<td>Third line:</td><td>5 hashes - 3 + 1 = 3 hashes</td></tr>
<tr>
<td>Fourth line:</td><td>5 hashes - 4 + 1 = 2 hashes</td></tr>
<tr>
<td>Fifth line:</td><td>5 hashes - 5 + 1 = 1 hash</td></tr>
</tbody>
</table>
</div><p>If we use 6 hashes, we can get rid of the “+ 1” part:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Line</td><td>Result</td></tr>
</thead>
<tbody>
<tr>
<td>First line:</td><td>6 hashes - 1 = 5 hashes</td></tr>
<tr>
<td>Second line:</td><td>6 hashes - 2 = 4 hashes</td></tr>
<tr>
<td>Third line:</td><td>6 hashes - 3 = 3 hashes</td></tr>
<tr>
<td>Fourth line:</td><td>6 hashes - 4 = 2 hashes</td></tr>
<tr>
<td>Fifth line:</td><td>6 hashes - 5 = 1 hash</td></tr>
</tbody>
</table>
</div><p>So, as 6 looks like an important number for our purposes, and as the subtracted number looks like the for loop iterating as a new line gets printed, let’s see what happens when we subtract the current iteration number from 6:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
    <span class="hljs-built_in">console</span>.log(<span class="hljs-number">6</span> - i);
}
</code></pre>
<p>Output:</p>
<pre><code class="lang-text">5
4
3
2
1
</code></pre>
<p>This is starting to look good!</p>
<p>So, as the first line will need to have 5 hashes, the iteration should go from 1 to 6 - 1 = 5.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> hashLine = <span class="hljs-string">''</span>;
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">6</span> - <span class="hljs-number">1</span>; i++) {
    hashLine += <span class="hljs-string">'#'</span>;
}
<span class="hljs-built_in">console</span>.log(hashLine);
</code></pre>
<p>Output:</p>
<pre><code class="lang-text">#####
</code></pre>
<p>Moving to the next line, to build it our loop will need to change the <code>i &lt;= 6 - 1</code> condition to <code>i &lt;= 6 - 2</code> condition. This pattern is pointing to a loop incrementing a value on each iteration, and we already have that loop: it’s the outer <code>for</code> loop.</p>
<p>When combining these findings with what we already have we can arrive to the conclusion of our problem:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> halfSquare = <span class="hljs-string">''</span>;
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">1</span>; i &lt;= <span class="hljs-number">5</span>; i++) {
    <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> j = <span class="hljs-number">1</span>; j &lt;= <span class="hljs-number">6</span> - i; j++) {
        halfSquare += <span class="hljs-string">'#'</span>;
    }
    halfSquare += <span class="hljs-string">'\n'</span>;
}
<span class="hljs-built_in">console</span>.log(halfSquare);
</code></pre>
<p>Output:</p>
<pre><code class="lang-text">#####
####
###
##
#
</code></pre>
<p>And this is the fruit of the struggle, the thinking and the experimenting.</p>
<p><img src="https://media.giphy.com/media/5bivKwxhVzshNk2Rjw/giphy.gif" /></p>
<h2 id="heading-closing-thoughts">Closing thoughts</h2>
<p>Applying all these techniques at once is not easy for me. I discovered that I have “my way” of solving problems, but it’s often not the most suitable way of doing so. As with most new habits, implementing a particular process comes with a certain resistance. This is why I’m taking the approach of implementing these problem-solving techniques one step at a time (and I’ve noticed that I’m going full-on "inception" here, using the division of a problem into smaller pieces as a technique to implement the problem-solving techniques 🤯).</p>
<p><img src="https://media.giphy.com/media/VEcLrbBDy4B1tTKhq7/giphy.gif" /></p>
<hr />
<h2 id="heading-notion-templates-trackers-and-roadmaps">Notion templates, trackers and roadmaps</h2>
<p>🙋‍♂️ Psst! Before you go, I have something to share with you. If you are a subscriber of my newsletter, you already know this, but in case you are not, I would like to share with you these 3 free resources:</p>
<p>👍 My <a target="_blank" href="https://mailchi.mp/77b7cbf1b03a/web-development-notion-template">Notion template with over 440 pages of web development content</a>, so you can <a target="_blank" href="https://blog.damiandemasi.com/using-notion-to-organise-programming-topics">use Notion to organise programming topics</a>.</p>
<p>👍 My <a target="_blank" href="https://blog.damiandemasi.com/html-study-progress-tracker-notion-template">HTML Study Progress Tracker and Roadmap Notion Template</a>, so you can keep track of your progress in learning HTML concepts (and review  them).</p>
<p>👍 And my <a target="_blank" href="https://blog.damiandemasi.com/css-study-progress-tracker-and-roadmap-notion-template">CSS Study Progress Tracker and Roadmap Notion Template</a>, to to the same  as before but with CSS.</p>
<p>They are totally free for download and use, but I'm always open to donations (I need to buy coffee to transform it into code 😅).</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[CSS Study Progress Tracker and Roadmap Notion Template]]></title><description><![CDATA[It's been a while since a posted anything because, you know, life gets in the way, I got married, and stuff 😂. But I didn't forget about what I promise, and I want to resolve it right now (wink, wink).
I have finished my CSS study progress tracker N...]]></description><link>https://blog.damiandemasi.com/css-study-progress-tracker-and-roadmap-notion-template</link><guid isPermaLink="true">https://blog.damiandemasi.com/css-study-progress-tracker-and-roadmap-notion-template</guid><category><![CDATA[Web Development]]></category><category><![CDATA[CSS]]></category><category><![CDATA[template]]></category><category><![CDATA[Web Design]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Tue, 08 Mar 2022 19:13:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1646727293232/bGKwsnz1B.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It's been a while since a posted anything because, you know, life gets in the way, <strong>I got married</strong>, and stuff 😂. But I didn't forget about what I <code>promise</code>, and I want to <code>resolve</code> it right now (wink, wink).</p>
<p>I have finished my <strong>CSS study progress tracker Notion template</strong> and I want to share it with you! Before continuing, if you haven't got the <strong>HTML</strong> version of this template, you can take a look at it <a target="_blank" href="https://blog.damiandemasi.com/html-study-progress-tracker-notion-template">here</a>.</p>
<h2 id="heading-a-quick-look-at-the-css-study-template">A quick look at the CSS study template</h2>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0bxaivt9nen6rdixy5c.png" alt="CSS Study Template" /></p>
<p>In this Notion template, you will find a progress bar that automatically updates whenever you check a topic as completed, <strong>73 CSS topics</strong> classified in three difficulty levels (initial, medium and advanced) and divided into 19 topic groups (ranging from Animation to Layout and Responsive Web Design).</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3f6help6vklh54bdqaj.png" alt="CSS topics" /></p>
<p>Each topic has a link to an online source discussing it (usually Mozilla Development documentation), and space for you to take notes on it.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3pdrc3xc2u1fckz42eg.png" alt="CSS topic detail" /></p>
<p>As always, feel free to modify this template and adapt it to your needs.</p>
<h2 id="heading-how-to-use-the-template">How to use the template</h2>
<p>Once more, I wanted to create a template that is easy to use and leave room for you to tweak it as you see fit. The steps to add a new topic (on top of the 73 already there), and mark it as completed once it has been studied is simple:</p>
<h3 id="heading-step-1-add-a-new-topic">Step 1: add a new topic</h3>
<p>Add a new topic to the "CSS topics and roadmap" database (you can do this on any of the two pages of the template), choose the level, its group, and its order.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qep1edise7apa95d70zj.png" alt="Add a new topic" /></p>
<p>But most importantly, choose the corresponding related value in the "Related to Progress (Property)" (don't worry, there is only one). This will link this database with the progress bar tracker.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gy9a52uu4uqrzda270b.png" alt="Linking topic with progress bar" /></p>
<h3 id="heading-step-2-add-notes-to-the-topic">Step 2: add notes to the topic</h3>
<p>Each of the 73 topics I have shared has a link to an <a target="_blank" href="https://developer.mozilla.org/en-US/">MDN</a> page with explanations for that topic.</p>
<p>I encourage you to use this topic page to create your "repository" of notes about it.</p>
<h3 id="heading-step-3-making-progress">Step 3: making progress</h3>
<p>Once you are happy with how much do you know about a certain topic, you can click the checkbox under the "Completed" column to mark the topic as learned. This will trigger an update on the progress bar, and it will grow accordingly, thus measuring your progress automatically.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efx3m5ht2h3rhvscj9bl.gif" alt="Making progress" /></p>
<h3 id="heading-step-4-customisation">Step 4: customisation</h3>
<p>As I said before, you can customise the template as you like. Something I'll do is hide the "Completed" and "Goal" columns of the <strong>Progress</strong> section to make it more minimalistic.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upq7i0png2gnh4uc7eb8.png" alt="Customise" /></p>
<h2 id="heading-getting-the-template">Getting the template</h2>
<p>🤷‍♂️ - "This is all good and all, but Damian, where can I get the Notion template?"</p>
<p>😅 - Grab your mouse and smash this link: <a target="_blank" href="https://damiandemasi.gumroad.com/l/lzbyj">download CSS Study Progress Tracker Notion Template</a> </p>
<p>The template is totally free, but I present you with the option of paying any amount you like for it so I can keep investing my time and effort into creating this kind of content for you 😊.</p>
<h2 id="heading-final-words">Final words</h2>
<p>Please, let me know in the comments section what do you think about this template, as I would love to improve it. I'm also working on a <strong>Role Playing Game (RPG) quest-based</strong> template to keep us <strong>motivated</strong> during our learning progress, so consider subscribing to my newsletter to get a notification when it's out (and maybe some ideas about what you would like to include in it)!</p>
<p>Cheers!</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[HTML Study Progress Tracker Notion Template]]></title><description><![CDATA[Continuing with the topic of helping new web development enthusiasts to track their progress, I would like to share a new Notion template with you. You can use it by itself, or include it on the Web Dev Resources template I already shared here.
The H...]]></description><link>https://blog.damiandemasi.com/html-study-progress-tracker-notion-template</link><guid isPermaLink="true">https://blog.damiandemasi.com/html-study-progress-tracker-notion-template</guid><category><![CDATA[HTML5]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[template]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Mon, 17 Jan 2022 21:57:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1642228475581/qu4EJywUV.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Continuing with the topic of helping new web development enthusiasts to <a target="_blank" href="https://blog.damiandemasi.com/measuring-your-progress-in-web-development-why-is-it-important-and-how-to-do-it">track their progress</a>, I would like to share a new Notion template with you. You can use it by itself, or include it on the <strong>Web Dev Resources</strong> template I already shared <a target="_blank" href="https://blog.damiandemasi.com/i-share-my-notion-template-with-over-440-pages-of-web-development-content">here</a>.</p>
<h2 id="heading-the-html-study-progress-tracker-notion-template">The HTML Study Progress Tracker Notion Template</h2>
<p>This template focuses on a specific topic: HTML. Thanks to researching great <a target="_blank" href="https://read.amazon.com.au/kp/embed?asin=B07DQ5RZJV&amp;preview=newtab&amp;linkCode=kpe&amp;ref_=cm_sw_r_kb_dp_GG0NXQZ153WH6B0VVTV0">books</a> and awesome <a target="_blank" href="https://developer.mozilla.org/en-US/">internet sources</a>, I have compiled the 42 most important subjects that we need to learn for mastering HTML. In the template, you can find the <strong>topic</strong>, its <strong>category</strong>, the <strong>difficulty level</strong> (according to my own experience), and checkboxes to keep track of what you have learned so far.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642225735366/q4pTCNQ0p.png" alt="List of topics" /></p>
<p>The objective of presenting HTML topics this way is to build some sort of road map to help us navigate the learning process. Each topic has an order that I have seen works best, but you can jump around as you see fit.</p>
<h2 id="heading-measuring-progress">Measuring progress</h2>
<p>The template also includes a Study Progress Tracker (patent pending 😉) that shows in a clear way your progress through the HTML part of the web development learning journey. I have asked people to tell me what are some of the challenges they find in their learning path, and many have replied that an unclear way of measuring progress is one of their main challenges. This is the reason behind this part of the template, and it's just a suggestion that you can change and alter as it works best for you.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642226328794/JiDOrBdLY.png" alt="Measuring progress" /></p>
<h2 id="heading-how-to-use-the-template">How to use the template</h2>
<p>I wanted to create a template as easy and straightforward to use as possible, so as not to include too much friction into the process of using it. The steps to add a new topic (on top of the 42 already there), and mark it as completed once it has been studied is simple:</p>
<h3 id="heading-step-1-add-a-new-topic">Step 1: add a new topic</h3>
<p>Add a new topic to the "HTML topics and roadman" database (you can do this on any of the two pages of the template), choose the level, its group, and its order.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642226700690/2KBmx9Prf.png" alt="Add a new topic" /></p>
<p>But most importantly, choose the corresponding related value in the "Related to Progress (HTML topics)" (don't worry, there is only one). This will link this database with the progress bar tracker.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642226908035/ky4lLG4yC.png" alt="Linking topic with progress bar" /></p>
<h3 id="heading-step-2-add-notes-to-the-topic">Step 2: add notes to the topic</h3>
<p>Each of the 42 topics I have shared has a link to an MDN page with explanations for that topic.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642227105435/uhY3VRn0N.png" alt="Topic notes" /></p>
<p>I encourage you to use this topic page to create your "repository" of notes about it.</p>
<h3 id="heading-step-3-making-progress">Step 3: making progress</h3>
<p>Once you are happy with how much do you know about a certain topic, you can click the checkbox under the "Completed" column to mark the topic as learned. This will trigger an update on the progress bar, and it will gro accordingly, thus measuring your progress automatically.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642227410216/H2fmWNiMQ.gif" alt="Making progress" /></p>
<h3 id="heading-step-4-customisation">Step 4: customisation</h3>
<p>As I said before, you can customise the template as you like. Something I'll do is hide the "Completed" and "Goal" columns of the <strong>Progress</strong> section to make it more minimalistic.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1642227575120/uuaRE54g5.png" alt="Customise" /></p>
<h2 id="heading-getting-the-template">Getting the template</h2>
<p>🤷‍♂️ - "This is all good and all, but Damian, where can I get the Notion template?"</p>
<p>😅 - I almost forgot! You can get the template from this link: <a target="_blank" href="https://damiandemasi.gumroad.com/l/html-study-progress-tracker">download HTML Study Progress Tracker Notion Template</a> </p>
<p>The template is totally free, but I present you with the option of paying any amount you like for it so I can keep investing my time and effort into creating this kind of content for you 😊.</p>
<h2 id="heading-final-words">Final words</h2>
<p>Please, let me know in the comments section what do you think about this template, as I would love to improve it. I'm also working on a CSS template that I should release soon, so consider subscribing to my newsletter to get a notification when it's out!</p>
<p>Cheers!</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Hackathon: Building a MongoDB fuzzy search web app with React, Next.js and TailwindCSS]]></title><description><![CDATA[Web Development Glossary Search is a web application that I created with the objective of taking part in the MongoDB Atlas Hackathon hosted by the DEV.to community.
The app makes use of several MongoDB features:

Search indexing for auto-complete and...]]></description><link>https://blog.damiandemasi.com/hackathon-building-a-mongodb-fuzzy-search-web-app-with-react-nextjs-and-tailwindcss</link><guid isPermaLink="true">https://blog.damiandemasi.com/hackathon-building-a-mongodb-fuzzy-search-web-app-with-react-nextjs-and-tailwindcss</guid><category><![CDATA[hackathon]]></category><category><![CDATA[MongoDB]]></category><category><![CDATA[React]]></category><category><![CDATA[Next.js]]></category><category><![CDATA[Tailwind CSS]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 05 Jan 2022 21:36:21 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1641380528496/EGYo8RAcu.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong><a target="_blank" href="https://hackathon-mongodb-devto.vercel.app/">Web Development Glossary Search</a></strong> is a web application that I created with the objective of taking part in the <a target="_blank" href="https://dev.to/devteam/announcing-the-mongodb-atlas-hackathon-on-dev-4b6m">MongoDB Atlas Hackathon</a> hosted by the DEV.to community.</p>
<p>The app makes use of several MongoDB features:</p>
<ul>
<li>Search indexing for auto-complete and normal searches using MongoDB Atlas.</li>
<li>Serverless functions that are called to perform the actual auto-complete and search features using MongoDB Realm.</li>
<li>The capacity to do a fuzzy search, querying the data for the top 10 closest matches to the search term.</li>
</ul>
<p>In this project, I also implemented a <em>save to favourites</em> functionality using <code>localStorage</code>, and React pagination to browse through the multiple documents returned by MongoDB.</p>
<p>The app was developed using:</p>
<ul>
<li><a target="_blank" href>React</a> for the front end with the following packages:<ul>
<li><a target="_blank" href="https://www.npmjs.com/package/realm-web"><code>realm-web</code></a>: for the MongoDB connectivity and Realm access</li>
<li><a target="_blank" href="https://www.npmjs.com/package/html-react-parser"><code>html-react-parser</code></a>: for parsing the data contained in the documents</li>
<li><a target="_blank" href="https://github.com/AdeleD/react-paginate"><code>react-paginate</code></a>: to paginate the documents returned by MongoDB</li>
</ul>
</li>
<li><a target="_blank" href="https://nextjs.org/">Next.js</a> for the back end</li>
<li><a target="_blank" href="https://heroicons.com/">Heroicons</a> for the icons</li>
<li><a target="_blank" href="https://tailwindcss.com/">TailwindCSS</a> for the styling</li>
</ul>
<hr />
<p>👉 Watch it live here: https://hackathon-mongodb-devto.vercel.app/</p>
<hr />
<h2 id="heading-about-the-web-app">About the web app</h2>
<p>The project is basically a glossary search app. The user can search a web development related term and save it as a favourite.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfe8u14k4kmlnbfjlywz.gif" alt="Application tour" /></p>
<p>On the start page, the app will present a list with all the terms that are present on the MongoDB database. As there are quite a lot of them, they are paginated.</p>
<p>Once the user starts searching for a particular term, the search field will offer auto-complete options after the third character is entered in the input field. This is accomplished by calling a serverless function on MongoDB Realm.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/puorouc9b6bgyrgpoirf.png" alt="Serverless function for auto-complete" /></p>
<p>This is the code for the function:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">exports</span> = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">arg</span>) </span>{
    <span class="hljs-keyword">let</span> collection = context.services.get(<span class="hljs-string">"mongodb-atlas"</span>).db(<span class="hljs-string">"hackathon_db"</span>).collection(<span class="hljs-string">"web_glossary"</span>);

    <span class="hljs-keyword">let</span> pipeline = [
        {
            <span class="hljs-attr">$search</span>: {
                <span class="hljs-attr">index</span>: <span class="hljs-string">"autoCompleteDefinitions"</span>,
                <span class="hljs-string">"autocomplete"</span>: {
                    <span class="hljs-string">"query"</span>: arg,
                    <span class="hljs-string">"path"</span>: <span class="hljs-string">"title"</span>,
                    <span class="hljs-string">"tokenOrder"</span>: <span class="hljs-string">"sequential"</span>
                }
            }
        },
        {
            <span class="hljs-attr">$limit</span>: <span class="hljs-number">10</span>
        },
        {
            <span class="hljs-attr">$project</span>: {
                <span class="hljs-comment">// "_id": 0</span>
                <span class="hljs-string">"title"</span>: <span class="hljs-number">1</span>
            }
        }];

    <span class="hljs-keyword">return</span> collection.aggregate(pipeline);
};
</code></pre>
<p>What this function does is to build a pipeline that searches the auto-complete index (defined in MongoDB Atlas) for query matches, limits those matches to 10, and returns the title of the matching documents. As a result, a dropdown list is shown when the user searches for a term, and the user can select one of them to see its definition:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/426u1r9q8rcazhbpm2tt.png" alt="Drop down" /></p>
<p>Here is a demo of this functionality in action:</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b53368mgpwnb64b3gdap.gif" alt="Auto-complete in action" /></p>
<p>The user can also type a term on the search field and press <code>Enter</code> or click on the <code>Search</code> button. This will call another serverless function defined in MongoDB Realm that will deliver the first 10 matches that are similar to the query sent by the user.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kdgn4y8wuxt42s1419u.png" alt="Fuzzy matching" /></p>
<p>This allows for fuzzy matching terms. For example, the user can enter <code>javoscrpt</code>, and MongoDB will return documents that are a close match to that term, such as <code>JavaScript</code>. This is a really awesome functionality! MongoDB will also return a <code>score</code> indicating how close to the query term is the returned result.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v5ejfct0qxvn9z8181f.png" alt="Scores" /></p>
<p>Here is a demo of this functionality in action:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641379671682/9bgkUuFth.gif" alt="Fuzzy Search" /></p>
<p>In case you are wondering, this is the code for this serverless function:</p>
<pre><code class="lang-javascript"><span class="hljs-built_in">exports</span> = <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params">arg</span>) </span>{
    <span class="hljs-keyword">let</span> collection = context.services.get(<span class="hljs-string">"mongodb-atlas"</span>).db(<span class="hljs-string">"hackathon_db"</span>).collection(<span class="hljs-string">"web_glossary"</span>);
    <span class="hljs-keyword">let</span> pipeline = [
        {
            <span class="hljs-string">'$search'</span>: {
                <span class="hljs-string">'index'</span>: <span class="hljs-string">'searchDefinitions'</span>,
                <span class="hljs-string">'text'</span>: {
                    <span class="hljs-string">'query'</span>: arg,
                    <span class="hljs-string">'path'</span>: {
                        <span class="hljs-string">'wildcard'</span>: <span class="hljs-string">'*'</span>
                    },
                    <span class="hljs-string">'fuzzy'</span>: {}
                }
            }
        },
        {
            <span class="hljs-attr">$project</span>: {
                <span class="hljs-attr">title</span>: <span class="hljs-number">1</span>,
                <span class="hljs-attr">excerpt</span>: <span class="hljs-number">1</span>,
                <span class="hljs-attr">score</span>: { <span class="hljs-attr">$meta</span>: <span class="hljs-string">"searchScore"</span> }
            }
        },
        {
            <span class="hljs-attr">$limit</span>: <span class="hljs-number">10</span>
        }
    ];

    <span class="hljs-keyword">return</span> collection.aggregate(pipeline);
};
</code></pre>
<p>I wanted to keep this app simple enough to focus on the MongoDB aspect of it, so if you think it's quite bare-bones, that's the reason why. That's also the reason behind the data (the definitions) not being polished enough.</p>
<hr />
<h2 id="heading-link-to-source-code">Link to Source Code</h2>
<p>You can take a look at the app source code in my <a target="_blank" href="https://github.com/Colo-Codes/hackathon-mongodb-devto">GitHub repository</a>.</p>
<hr />
<h2 id="heading-additional-information-and-resources">Additional Information and Resources</h2>
<h3 id="heading-initial-research">Initial research</h3>
<p>Before starting working on this hackathon, I knew one thing: I wanted to implement auto-complete on a search bar because that was something I had never done before. This was the initial stepping stone that pushed me to create a project for the hackathon.</p>
<p>I explored several ideas regarding what the app was going to be all about, ranging from an e-commerce store to hire Hobbits to help around the house, to a database of monsters from Dungeons and Dragons (D&amp;D), and some other cool ideas, but all of them had one fatal flaw: the user should know what to search for. Not many people know by heart the names of Hobbits or D&amp;D demons, so I switched to something more proper for the audience of this hackathon: web development terms.</p>
<p>Doing my research I came across the <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary">MDN Glossary of Web-related terms definitions</a>. I found out that I could clone their repository and get all the definitions straight from their <a target="_blank" href="https://github.com/mdn/content">GitHub repository</a>, so I did just that!</p>
<h3 id="heading-data-preparation">Data preparation</h3>
<p>My goal was to get all the definitions from MDN and transform them into JSON format so I could upload that into a MongoDB collection (a table, in SQL language). Unfortunately, due to the nature of the data, it wasn't an easy task.</p>
<p>The glossary data from MDN is divided into multiple files in markdown format, and I wasn't planning on copying and pasting that by hand. After some online search, I came across the <a target="_blank" href="https://www.npmjs.com/package/markdown-json">markdown-json</a> package which, after some trial and error, converted all my markdown files into a single JSON file. I did this directly in the console:</p>
<pre><code class="lang-bash">npx markdown-json -c ./my-app-settings.json -p */*.md
</code></pre>
<p>Once the data was ready, I created a new database and collection on MongoDB and imported the JSON file.</p>
<p><img src="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ds1ci81fzw3vddu7zclp.png" alt="Database and collection" /></p>
<h3 id="heading-learning-about-mongodb-atlas">Learning about MongoDB Atlas</h3>
<p><img src="https://media.giphy.com/media/13f5iwTRuiEjjW/giphy.gif" /></p>
<p>I didn't know anything about MongoDB Atlas, so I wanted to know what it was capable of and how I could use it. I found an awesome tutorial by <a target="_blank" href="https://www.youtube.com/channel/UCDCHcqyeQgJ-jVSd6VJkbCw">codeSTACKr</a> (who, as far as I know, is working for MongoDB) in which he builds an <a target="_blank" href="https://www.youtube.com/playlist?list=PL4RCxklHWZ9v2lcat4oEVGQhZg6r4IQGV">e-commerce solution using MongoDB Atlas</a>.</p>
<p>After building that app, I had an idea of what I could be doing with my own app. I used React, Next.js, and TailwindCSS to build it, as well as a couple of packages to implement certain functionalities, such as pagination and HTML parsing (the glossary terms extracted from MDN are described using HTML code). I tried to make my app as different from the tutorial as possible so I could actually learn and understand what I was doing. I hope to have accomplished that.</p>
<p>Another great resource for understanding how MongoDB works is its <a target="_blank" href="https://docs.mongodb.com/">official documentation</a>. This proved to be helpful when I had to modify and delete the collection, because I had to do this using the <a target="_blank" href="https://docs.mongodb.com/manual/tutorial/remove-documents/">MongoDB shell</a>.</p>
<p>If you would like a full, detailed, tutorial about how to build this app, please send me a message to my <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a> account.</p>
<p>I hope you enjoyed this post. Hopefully, I managed to inspire you to build your own implementation of the MongoDB features I described earlier.</p>
<p>Cheers!</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[Measuring your progress in Web Development: why is it important and how to do it]]></title><description><![CDATA[The learning journey in the web development world can be chaotic at times. If you think about the fact that there are too many topics to learn, too much to remember, and the incommensurable amount of rabbit holes, it's easy to lose motivation or to f...]]></description><link>https://blog.damiandemasi.com/measuring-your-progress-in-web-development-why-is-it-important-and-how-to-do-it</link><guid isPermaLink="true">https://blog.damiandemasi.com/measuring-your-progress-in-web-development-why-is-it-important-and-how-to-do-it</guid><category><![CDATA[Web Development]]></category><category><![CDATA[projects]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Wed, 29 Dec 2021 00:53:36 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1640737682357/GYvKTFS52.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The learning journey in the web development world can be chaotic at times. If you think about the fact that there are too many topics to learn, too much to remember, and the incommensurable amount of rabbit holes, it's easy to lose motivation or to feel lost.</p>
<h2 id="heading-the-problem-with-programming-being-intangible">The problem with programming being intangible</h2>
<p>Learning web development is not like actually building something with our hands. Programming is abstract, and we can't actually "touch" our program, which gives us a sense of not having accomplished something. By contrast, a carpenter can start working on building a chair, and after a while, the carpenter can point to the chair, even touch it, and say "I've built that!". As programming, and much of the knowledge work, is intangible, we need a way to improve the feedback on our effort. Using progress indicators is a great way of doing so.</p>
<p><img src="https://media.giphy.com/media/VhE7ABvkD8CHe/giphy.gif" /></p>
<p>The key to succeeding in your study process (and for building projects) is to stick to a good habit of learning and building every day. According to <a target="_blank" href="https://jamesclear.com/">James Clear</a>, the best way to stick to a habit is to make it satisfying. This is where <em>visual measures</em> come into play.</p>
<h2 id="heading-habit-trackers">Habit trackers</h2>
<p>Visual measures can be presented in many different ways, such as journaling, progress bars, and page numbers in a book. They are useful because they add immediate feedback and satisfaction after performing a habit, making <em>habit trackers</em> one of the best ways to measure our progress.</p>
<p>The way in which we track our progress needs to be attractive and satisfying, thus making it enjoyable, something we aspire to do after finishing a habit.</p>
<blockquote>
<p>Habit trackers and other visual forms of measurement can make your habits satisfying by providing clear evidence of your progress.</p>
<ul>
<li>Clear, James. Atomic Habits (p. 204). Penguin Publishing Group.</li>
</ul>
</blockquote>
<h2 id="heading-implementing-habit-trackers">Implementing habit trackers</h2>
<p>We should be mindful of tracking things that are under our control, such as how many hours we invest in programming a project, and avoid tracking things outside our control, such as how many people star our project on GitHub or how many followers we have on <a target="_blank" href="https://hanamakhlouf.medium.com/4-reasons-to-get-on-tech-twitter-now-cafc020ad5d8">Tech Twitter</a>.</p>
<p>The activities we can track can be broadly divided into two categories depending on:</p>
<ul>
<li>how much effort we invest, and</li>
<li>how much progress we have made.</li>
</ul>
<h3 id="heading-tracking-effort">Tracking effort</h3>
<p>Effort can depend on <strong>time</strong> (how many hours do we clock in) or on <strong>repetition</strong> (how many projects we have built).</p>
<p>In order to track <strong>time</strong>, I usually use a time-tracker app. My favourite is <a target="_blank" href="https://clockify.me/">Clockify</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640732587682/a_AfJZjdQ.png" alt="Using Clockify" /></p>
<p>I use time tracking like this:</p>
<ul>
<li>👉 First, define how much time I will invest in the activity. For example, if the activity is "studying JavaScript", I will say "I will invest 1 hour a day, 5 days a week, on studying JavaScript". This is the minimum, and I'll do my best effort to invest <em>at least</em> this amount of time in the activity.</li>
<li>👉  Second, define this activity as a project in the time tracking app. By doing so, I can get detailed information on the app regarding how much time I invested over the days.</li>
<li>👉  Third, start tracking time on the app.</li>
<li>👉  Fourth, periodically analyse how this activity is going by taking a look at the time tracking report.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640733079008/PDRWCDP2n.png" alt="JavaScript time tracking" /></p>
<p>For example, as shown in the picture above, during the months of June, July and August, I spent 205 hours studying JavaScript.</p>
<p>By doing this, I can go from "I studied some JavaScript during 2021" to "I spent 205 hours focusing on JavaScript during June, July and August of 2021". I have a number, a real measurement that I can use to get a better feeling of the progress I'm making on JavaScript.</p>
<p>If what we want is to track <strong>repetition</strong>, we can just decide, for example, on how many projects we want to build for a specific goal. We can say that we want 3 projects on our portfolio, so we will track how many projects we are building, and this will give us a sense of <strong>advancing towards our goal</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640733670073/Za9jxWD3r.png" alt="Projects" /></p>
<p>I usually use <a target="_blank" href="https://www.notion.so/">Notion</a> for this, but you can use any app, or just pen and paper.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640735362386/WvL7lSg07.jpeg" alt="Project progress" /></p>
<h3 id="heading-tracking-progress">Tracking progress</h3>
<p>Tracking progress is ideal for activities that take a long time, and that have a beginning and an end. A course or book on JavaScript is the ideal subject to track this way.</p>
<p>What I do in this case is to divide the activity into smaller chunks. If I want to study a book, I will use the book's chapters as steps to measure the progress. If I want to measure a Udemy course, I will use each separate class (video) as a step to measure my progress.</p>
<p>For example, as of December 2021, the <a target="_blank" href="https://eloquentjavascript.net/">Eloquent JavaScript</a> book has 21 chapters plus the introduction, so I will divide my progress on the book into 22 steps. Each time I finish a chapter, I will mark one of those steps as done by increasing the <em>Commpleted</em> counter on the tracking app/system.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640734136194/5zGUyMyl_.png" alt="Progress" /></p>
<p>A similar methodology will be used on Udemy courses or on the freeCodeCamp syllabus.</p>
<p>My preferred tool for measuring this is, again, <a target="_blank" href="https://www.notion.so/">Notion</a>. <strong>You can take a look at the template I use by <a target="_blank" href="https://chipper-designer-8106.ck.page/b0a239f6ae">downloading it from here</a></strong>, and going to the <strong>Study progress</strong> section.</p>
<h2 id="heading-closing-thoughts">Closing thoughts</h2>
<p>Tracking our progress can help us to get a feeling of how much have we accomplished towards a goal, and can also contribute to sticking with difficult habits, such as studying web development every day or building projects. I encourage you to try some of these techniques and see for yourself if they are useful to you.</p>
<p>I would love to hear if you have implemented habit tracking before, or if you have a different method to track your progress, so feel free to post it in the comments section.</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[I share my Notion template with over 440 pages of web development content]]></title><description><![CDATA[I guess Santa came a bit early this Christmas! 🎅

In one of my last posts, Using Notion to organise programming topics, a lot of people asked me to share the Notion template I was using to build my commonplace book about Web Development. So, after s...]]></description><link>https://blog.damiandemasi.com/i-share-my-notion-template-with-over-440-pages-of-web-development-content</link><guid isPermaLink="true">https://blog.damiandemasi.com/i-share-my-notion-template-with-over-440-pages-of-web-development-content</guid><category><![CDATA[webdev]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[React]]></category><category><![CDATA[HTML]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Tue, 21 Dec 2021 19:55:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1640116265154/VQyxi9ulo.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I guess Santa came a bit early this Christmas! 🎅</p>
<p><img src="https://media.giphy.com/media/3o6ZtdulyqqoJjWB6U/giphy.gif" /></p>
<p>In one of my last posts, <a target="_blank" href="https://blog.damiandemasi.com/using-notion-to-organise-programming-topics">Using Notion to organise programming topics</a>, a lot of people asked me to share the Notion template I was using to build my commonplace book about Web Development. So, after spending quite some time removing personal information from it, and polishing it a bit, I would like to share with you a template you can use to create your own commonplace book.</p>
<hr />
<p>👉 You can download the template by clicking <a target="_blank" href="https://mailchi.mp/77b7cbf1b03a/web-development-notion-template">here</a>. 👈</p>
<hr />
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640116402489/fnOA05rjX.png" alt="Template" /></p>
<p>In this template, you will find over 440 pages containing:</p>
<ul>
<li>Over 270 HTML and CSS related questions to practice your knowledge in a spaced repetition manner.</li>
<li>Dozens and dozens of useful links.</li>
<li>Information about CSS, HTML, JavaScript, ReactJS, Ruby on Rails, SQL, and more!</li>
<li>Cheatsheets.</li>
<li>Link to free tutorials and courses.</li>
<li>Mindset (to stay strong in the web development journey).</li>
<li>Information and links about APIs, tools, libraries, web development resources, etc.</li>
<li>Resources for code practice.</li>
<li>Problem-solving strategies.</li>
<li>Lists of interesting articles.</li>
<li>Useful blogs, podcasts and newsletters.</li>
<li>The best YouTube channels I could find.</li>
<li>And much, much more!</li>
</ul>
<p>Please, feel free to create a copy of this template and adapt it to your own needs. I found it very useful in my journey of becoming a Web Developer, and I still use it almost every day. It has become an extension of my brain, and I rely on it every time I have a question or doubt.</p>
<p>I did my best to remove any copyrighted or personal content but, if you find any, please let me know so I can delete it.</p>
<p>I would like to know any suggestions on how to improve this template, and I'm even considering uploading it to GitHub so I can transform it into a collaborative commonplace repository. Let me know what you think about that.</p>
<p>I hope you enjoy it!</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content, <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter">subscribe to my newsletter</a>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on <a target="_blank" href="https://twitter.com/DamianDemasi">Twitter</a>.</em></p>
]]></content:encoded></item><item><title><![CDATA[How to become a Web Developer, with coach Gandalf]]></title><description><![CDATA[In this blog post, I'll be discussing why you shouldn't trust new year's resolutions, how overrated motivation is, tools to help you succeed in the path of learning web development, and the road I took and recommend (as of December 2021) taking to be...]]></description><link>https://blog.damiandemasi.com/how-to-become-a-web-developer-with-coach-gandalf</link><guid isPermaLink="true">https://blog.damiandemasi.com/how-to-become-a-web-developer-with-coach-gandalf</guid><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[React]]></category><category><![CDATA[HTML5]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[Damian Demasi]]></dc:creator><pubDate>Tue, 14 Dec 2021 19:24:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1705735275419/52dbe0c0-8c0d-4ddc-bf80-a30fcb6822c8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this blog post, I'll be discussing why you shouldn't trust new year's resolutions, how overrated motivation is, tools to help you succeed in the path of learning web development, and the road I took and recommend (as of December 2021) taking to become a Web Developer.</p>
<p>I will ask coach Gandalf for his opinions on different topics, and he will pour his wisdom and bluntness over us during the whole post.</p>
<p><img src="https://media.giphy.com/media/Cu0Iqwal4cPyU/giphy.gif" alt /></p>
<h2 id="heading-the-truth-about-new-years-resolutions">The truth about new year's resolutions</h2>
<p>🧑‍💻 - Hey, coach Gandalf, what do you feel about new year's resolutions?</p>
<p>🧙‍♂️ - My dear little human, most of us have been there: a new year is coming, we feel this is our chance to stop some bad habits and start new ones, a perfect body and a perfect wallet are just around the corner. January 1st, we start doing that thing we planned on doing. A week later we find the first excuses on why we are permitted to skip a couple of days (or eat that tasty cake, or buy that nice mechanical keyboard -our third one-). Two weeks later we find ourselves sliding into bad habits once more, telling us that they are not as bad after all. Our motivation explodes into the air a few moments after liftoff, like a failed rocket launch 🚀💥. You don't believe me? Take a look at <a target="_blank" href="https://www.outsideonline.com/health/training-performance/forget-motivation-and-focus-action/">this article</a> describing why only 9% of people stick to their resolutions for a full year.</p>
<p>🧑‍💻 - Hm... OK, maybe that's a bit too blunt, don't you think? I guess you are cranky because you ran out of tobacco for your pipeweed or something...</p>
<h2 id="heading-but-motivation">But... motivation!</h2>
<p>🧑‍💻 - I'm motivated! But sometimes I don't feel like it...</p>
<p>🧙‍♂️ - Allow me to be blunt once more: motivation is overrated. According to <a target="_blank" href="https://jamesclear.com/motivation">this article</a> by James Clear (the guy who wrote the great book <a target="_blank" href="https://amzn.to/3osSJLI">Atomic Habits</a>) describing how motivation works, <strong>motivation often comes after starting a new behaviour, not before</strong>. You don't feel like it? You don't feel in the mood to start typing code, going through that Udemy course, writing that blog post (😉)? Guess what: we all feel like that most of the time. What we need to do is just start. We can say to ourselves "I will just do 10 minutes of this, and then I can drop it". Chances are that we are going to stick for more than 10 minutes, and the motivation will start growing <strong>after</strong> we started working on the thing we <em>just don't feel like</em>.</p>
<h2 id="heading-dont-focus-on-the-objective-focus-on-the-system-instead">Don't focus on the objective, focus on the system instead</h2>
<p>🧑‍💻 - Coach, I love setting goals!</p>
<p>🧙‍♂️ - Do you know that people that reach their goals, and people that don't, have the same goals in common? (Laughs while exhaling smoke from his pipe.) I guess I'm a fan of James Clear because he's back with another great article: <a target="_blank" href="https://jamesclear.com/goals-systems">Forget About Setting Goals. Focus on This Instead</a>.</p>
<blockquote>
<p>Goals can provide direction and even push you forward in the short term, but eventually, a well-designed system will always win. Having a system is what matters. Committing to the process is what makes the difference.</p>
</blockquote>
<p>🧙‍♂️ - Don't think too much about your objective, your goal. Instead, focus your full attention on the day to day tasks you need to do in order to achieve that goal. Our system could be a series of habits that enable us to learn to program. Waking up early and studying programming, taking some time each day to write code, bundling habits (from Atomic Habits), stopping chasing rabbit holes on the Internet, limiting our social network use, doing regular exercise and sleeping well to improve our cognitive stamina, are just some examples of what we could do.</p>
<p>🧙‍♂️ - In the end, learning to program and becoming who we want to become does not depend on a new year starting or on an ambitious goal. It depends on what we are doing day in and day out to support our identity: we are now a programmer.</p>
<p><img src="https://media.giphy.com/media/TcdpZwYDPlWXC/giphy.gif" alt /></p>
<h2 id="heading-tools-to-help-us-maintain-consistency-along-the-way">Tools to help us maintain consistency along the way</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639469986973/1zHgsFVgU.png" alt="Don't Panic" /></p>
<p>🧑‍💻 - This looks that is going to be hard...</p>
<p>🧙‍♂️ - This journey is not going to be easy, nor short. I can promise you moments of struggle, uncertainty, and despair. But don't panic! Not all who wander are lost. Here are some tools that are going to help you succeed in this path:</p>
<ul>
<li><p>🛠 <strong>Grit:</strong> a ferocious determination to put in the work. Being able to be resilient and hardworking. Know in a very deep way what is what you want. (From the book: <a target="_blank" href="https://amzn.to/3GH9Mjd"><strong>Grit</strong></a>)</p>
</li>
<li><p>🛠 <strong>A growth mindset:</strong> the view you adopt for yourself profoundly affects the way you lead your life. The hand you’re dealt is just the starting point for development. The growth mindset is based on the belief that your basic qualities are things you can cultivate through your efforts. (From the book: <a target="_blank" href="https://amzn.to/3ETB6KB"><strong>Mindset</strong></a>)</p>
</li>
<li><p>🛠 <strong>A strong identity and habits that support that identity:</strong> habits shape your identity, and vice-versa. What type of person do you want to be? A programmer? What habits do a programmer have? Will he/she/them be binging Squid Game, or learning React to build an app? (From the book: <a target="_blank" href="https://amzn.to/3oRAYWm"><strong>Atomic Habits</strong></a>)</p>
</li>
<li><p>🛠 <strong>Be able to do deep work:</strong> the ability to perform activities in a state of distraction-free concentration that pushes your cognitive capabilities to their limit. (From the book: <a target="_blank" href="https://amzn.to/3dQNkrK"><strong>Deep Work</strong></a>)</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639469904177/bMsaxhBiQ.png" alt="Tools" /></p>
<p>🧙‍♂️ - If you would like to learn a bit more about these tools, I would like to share with you four book summaries made by <a target="_blank" href="https://www.optimize.me/pn">Brian Johnson</a>:</p>
<ul>
<li><p>📓 <a target="_blank" href="https://assets.optimize.me/philosophers-notes/downloads/pdfs/files/member/grit.pdf">Grit</a></p>
</li>
<li><p>📓 <a target="_blank" href="https://assets.optimize.me/philosophers-notes/downloads/pdfs/files/member/mindset.pdf">Mindset</a></p>
</li>
<li><p>📓 <a target="_blank" href="https://assets.optimize.me/philosophers-notes/downloads/pdfs/files/member/atomic-habits.pdf">Atomic Habits</a></p>
</li>
<li><p>📓 <a target="_blank" href="https://assets.optimize.me/philosophers-notes/downloads/pdfs/files/member/deep-work.pdf">Deep Work</a></p>
</li>
</ul>
<p>(You can find all these books in your favourite bookstore, of course.)</p>
<h2 id="heading-the-web-development-path">The web development path</h2>
<p>🧑‍💻 - Thanks for the useful tips, coach Gandalf. Where should I start my web development journey?</p>
<p>🧙‍♂️ - Now that we have established how we can improve our chances of succeeding in learning web development, let's talk about what I think is the best path to follow. There are many tools and technologies to learn, and you can take a look at a <a target="_blank" href="https://roadmap.sh/frontend">road map here</a>. I think the best option is to start with the <strong>Front-end</strong>, as it's the path that will have a not-so-steep learning curve (compared with DevOps or Back-end) and high demand for jobs.</p>
<p>🧙‍♂️ - <strong>A word of caution:</strong> many times you'll feel drawn to free resources. You should be careful! Many of the free resources are not as deep or thorough as you need them to be. They will leave gaps in your knowledge and you will lose time filling them. I think the best approach is to commit yourself to a comprehensive course, even if you have to pay for it. I'm a strong believer that Udemy is the best option for this. Pick a topic you are interested in learning and search for Udemy courses about it. Read comments, reviews, and recommendations. There is always a Udemy sale, so you shouldn't spend more than $35 for a full course (that usually has 45+ hours of content).</p>
<p>🧙‍♂️ - One more thing: try not to jump around too much. Stick with the technology and content you are learning until the course or project is finished. This will prevent gaps from forming in your knowledge, and help you avoid <a target="_blank" href="https://dev.to/davidmm1707/how-to-escape-from-tutorial-hell-and-never-come-back-bb6"><strong>tutorial hell</strong></a>.</p>
<h3 id="heading-1st-step-git">1st step: Git</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639470471123/WHy7HLRQl.png" alt="Git" /></p>
<p>🧑‍💻 - So... what is the first step?</p>
<p>🧙‍♂️ - Starting with <strong>Git</strong> will allow you to become familiar with the terminal and the way in which software is built. You can create repositories from day 1, something that will look great on your GitHub profile. It will allow you to keep track of all your code and projects, and I think i's a great way to get your feet wet with the world of programming in general.</p>
<hr />
<p><strong>Steps:</strong></p>
<ol>
<li>Udemy course: <a target="_blank" href="https://click.linksynergy.com/link?id=LO030NrbM0E&amp;offerid=507388.221674&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fgit-complete%2F">Git Complete: The definitive, step-by-step guide to Git</a>. Start your journey by taking this course. You can implement the concepts learned here during the rest of your student (and professional) path.</li>
</ol>
<hr />
<h3 id="heading-the-importance-of-building-stuff">The importance of building stuff</h3>
<p>🧙‍♂️ - During your journey, you will be tempted to absorb information as fast as possible to achieve that highly desired outcome: become a web developer. But please, don't just work on the theory. As soon as you start learning HTML and CSS (and JavaScript and React later on), you should be building your own projects. They can be small (just a button), medium (a website), or big (a full web application). Build, build and then build some more (and keep track of them on GitHub). This is how the information you are absorbing is going to be transformed into actual <strong>knowledge</strong>.</p>
<h3 id="heading-2nd-step-bootcamp-optional">2nd step: Bootcamp (optional)</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639470580360/yKWS8SJ-5.png" alt="Bootcamp" /></p>
<p>🧑‍💻 - Should I take a Bootcamp or just focus on each topic separately?</p>
<p>🧙‍♂️ - If you are not in a hurry and you have spare time, taking a <strong>coding Bootcamp</strong> will teach you the overall technologies involved in the web development journey. You are not going to learn those topics deeply, though, which means that you will have to study them after the Bootcamp. Most good Bootcamps are lengthy and require you to absorb many different topics in a cramped time frame.</p>
<p>🧙‍♂️ - You have two main options when choosing a Bootcamp: doing it online, or doing in in-person. Usually, online ones are cheaper but require a greater commitment on your part in order to finish them. In-person Bootcamps are more expensive, but it's easier to finish them because you have paid a lot of money, and you have to go to a specific place at a certain date and time. Another pro for the in-person ones is that you will actually meet people in the same boat as you are.</p>
<p>🧑‍💻 - I agree. I actually took a Bootcamp course on Udemy, and I found it very useful to gain an overall knowledge of the things involved in the web development process. The Bootcamp I took back in the day (2019-2020) had 405 lectures spread across 47 hours of content. This translated into almost 148 hours of actual study (I used a time tracker app to measure it). As I was working and studying at the same time, those 148 hours spread over 5 to 6 months. Initially, I estimated, at the most, half of that time, so beware.</p>
<hr />
<p><strong>Optional step:</strong></p>
<ul>
<li>Udemy course: <a target="_blank" href="https://click.linksynergy.com/link?id=LO030NrbM0E&amp;offerid=507388.625204&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-web-developer-bootcamp%2F">The Web Developer Bootcamp 2022</a>. This is the BootCamp I took and I can highly recommend it. Colt is a great teacher and the course has many projects that you can build.</li>
</ul>
<p>Or</p>
<ul>
<li>Udemy course: <a target="_blank" href="https://click.linksynergy.com/link?id=LO030NrbM0E&amp;offerid=507388.1565838&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-web-development-bootcamp%2F">The Complete 2022 Web Development Bootcamp</a>. I haven't taken Angela's course but I have read many positive comments from people (not only on the Udemy page) recommending it.</li>
</ul>
<p>Either one your choose, you can't go wrong.</p>
<hr />
<h3 id="heading-3rd-step-html-and-css">3rd step: HTML and CSS</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639470673176/devaYnb1m.png" alt="HTML &amp; CSS" /></p>
<p>🧑‍💻 - OK, I now know Git (and maybe I have finished a BootCamp). What's next?</p>
<p>🧙‍♂️ - You still don't know what you don't know. You need to dive deep into HTML and CSS. In this step, you will learn about the correct structure an HTML document should have, accessibility (WAI-ARIA), new HTML5 elements you should use and which ones to avoid, how to style an HTML document, CSS custom properties, good practices, grid, flexbox, etc.</p>
<p>🧙‍♂️ - If you previously took a BootCamp, chances are that you didn't learn these topics in a thorough way, so here is where we are diving deep into these concepts. There are many, many, resources from which you can choose to learn HTML and CSS, so do your research and choose wisely. I would suggest to you to choose good teaching materials, and not just what's free or fashionable.</p>
<p>🧑‍💻 - I agree with you, Gandalf. I remember that I almost entered a "paralysis by analysis" stage when researching where or how I could get good quality teaching materials for HTML and CSS. I ended up selecting a free course, a book and a Udemy course, and I feel that those resources were some of the best I could have selected.</p>
<hr />
<p><strong>Steps:</strong></p>
<ol>
<li><p>freeCodeCamp: <a target="_blank" href="https://www.freecodecamp.org/learn/responsive-web-design/"><strong>Responsive Web Design Certification</strong></a>. Start by taking this free course so you can have a basic and general idea about HTML and CSS.</p>
</li>
<li><p>Book: <a target="_blank" href="https://www.amazon.com/Learning-Web-Design-Beginners-JavaScript/dp/1491960205/ref=sr_1_1?keywords=learning+web+design&amp;qid=1639425293&amp;sr=8-1"><strong>Learning Web Design: A Beginner's Guide to HTML, CSS, JavaScript, and Web Graphics, 5th Edition</strong></a>. After finishing the freeCodeCamp course, pick up this book. It is highly recommended because it will teach you important concepts such as how the Internet works, HTML, CSS, best practices, an introduction to JavaScript, and much more.</p>
</li>
<li><p>Udemy course: <a target="_blank" href="https://click.linksynergy.com/link?id=LO030NrbM0E&amp;offerid=507388.1026604&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fadvanced-css-and-sass%2F"><strong>Advanced CSS and Sass: Flexbox, Grid, Animations and More!</strong></a> . Only take this course after having covered freeCodeCamp course and the Learning Web Design book if you have spare time and want to dive deeper into CSS and SASS.</p>
</li>
</ol>
<hr />
<h3 id="heading-4th-step-javascript">4th step: JavaScript</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639470739764/5t_5ilWEO.png" alt="JavaScript" /></p>
<p>🧑‍💻 - I now know how to build a repository of my code, create an HTML document and use CSS to style it. What now?</p>
<p>🧙‍♂️ - The logical projection from here is learning <strong>JavaScript</strong>. It's the universal programming language for websites and it is supported by all main web browsers. This is where the core of your journey should be focused on, and the stepping stone that you'll use to learn libraries and frameworks in the future. <strong>You should take your time in learning JavaScript</strong>, and avoid jumping into a library or framework without feeling comfortable with JavaScript first.</p>
<p>🧑‍💻 - I couldn't agree more! I'm now working professionally with React but I find myself using JavaScript code and concepts learned in this stage of my studies all the time.</p>
<hr />
<p><strong>Steps:</strong></p>
<ol>
<li><p>freeCodeCamp: <a target="_blank" href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/"><strong>JavaScript Algorithms and Data Structures Certification</strong></a>. Start by taking this free course so you can have a basic and general idea about JavaScript.</p>
</li>
<li><p>Udemy course: <a target="_blank" href="https://click.linksynergy.com/link?id=LO030NrbM0E&amp;offerid=507388.851712&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fthe-complete-javascript-course%2F"><strong>The Complete JavaScript Course 2022: From Zero to Expert!</strong></a> . After finishing freeCodeCamp's course, take this one on Udemy. It's the best course I have ever taken on Udemy, and it will not only teach you JavaScript (in depth), but also programming concepts and best practices. This is a must-do!</p>
</li>
<li><p>Book: <a target="_blank" href="https://eloquentjavascript.net/">Eloquent JavaScript, 3rd edition</a>. You can read this book in digital format for free, or you can buy it in physical format from Amazon. It's a great book, but a bit too technical for beginners. If you still have spare time, read it; if you don't want to spend more time in this section, skeep it and revisit it in the future. Most of the concepts covered in the book are also covered in the previous Udemy course.</p>
</li>
</ol>
<hr />
<h3 id="heading-5th-step-react">5th step: React</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639470801892/c59KlGCA4.png" alt="React" /></p>
<p>🧑‍💻 - I feel like Neo when he said "I Know Kung Fu".</p>
<p>🧙‍♂️ - Unfortunately, chances are that by now you were too focused on learning by absorbing information. What you should be doing by now is putting that knowledge into practice. This step is ideal for that. Now you are going to learn JavaScript's libraries and frameworks. You have a bunch of them to choose from, and the one you select should depend on what is being used in your area (a quick job search will tell you that). The top three you can choose from are:</p>
<p>JavaScript libraries:</p>
<ul>
<li>React</li>
</ul>
<p>JavaScript frameworks:</p>
<ul>
<li><p>Vue</p>
</li>
<li><p>Angular</p>
</li>
</ul>
<p>This might help you to get an idea of how they compare among themselves in terms of interest:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1641419838271/m1LUOCbEQ.png" alt="React vs Vue vs Angular" /></p>
<p><a target="_blank" href="https://trends.google.com/trends/explore?date=today%205-y&amp;q=%2Fm%2F012l1vxv,%2Fg%2F11c0vmgx5d,%2Fg%2F11c6w0ddw9">Source</a>.</p>
<p>🧙‍♂️ - I recommend choosing React, as it is very used worldwide, and you can use it to design mobile or desktop applications in the future (using React Native) if that's something you are interested in.</p>
<hr />
<p><strong>Steps:</strong></p>
<ol>
<li><p>freeCodeCamp: <a target="_blank" href="https://www.freecodecamp.org/learn/front-end-development-libraries/">Front End Development Libraries Certification</a>. Start by taking this freeCodeCamp course to get a feel of React. You will learn how web applications are built professionally, in the real world.</p>
</li>
<li><p>Udemy course: <a target="_blank" href="https://click.linksynergy.com/link?id=LO030NrbM0E&amp;offerid=507388.1362070&amp;type=2&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Freact-the-complete-guide-incl-redux%2F">React - The Complete Guide (incl Hooks, React Router, Redux)</a>. Maximilian will teach you (and reinforce) programming concepts as well as React in depth. This is a very good, up to date, course, and I can recommend it.</p>
</li>
</ol>
<hr />
<h3 id="heading-6th-step-job-ready">6th step: Job Ready</h3>
<p>🧑‍💻 - OK, so, I have spent several months learning all of this and building many projects by myself (with Google's help). What should I do next?</p>
<p>🧙‍♂️ - Once you have finished all these courses and built some applications and projects of your own, you are now ready to start applying for Front-end Development jobs. Now you should be building your portfolio, writing a good resume and LinkedIn profile, and reviewing the most important concepts learned so far.</p>
<p>🧙‍♂️ - The whole path to get to this point will take you from 6 months to 1.5 years (or more), depending on your previous knowledge and how well you are learning the concepts you are presented with.</p>
<h3 id="heading-7th-step-going-back-end">7th step: Going Back-end</h3>
<p><img src="https://media.giphy.com/media/10es4gkhzGC6zu/giphy.gif" alt /></p>
<p>🧙‍♂️ - The Front End Developer path is far from over, but by now you should feel comfortable enough to jump into the Back-end. But that is a story for some other time.</p>
<p>🧑‍💻 - Thanks, coach Gandalf! I wish you were real so I could high-five you!</p>
<p>🧙‍♂️ - Remember this: you are the hero of your story. Ask yourself: what would a hero do in my situation? How does a hero endure these obstacles, slay these dragons?</p>
<hr />
<p>🗞️ <strong>NEWSLETTER -</strong> <em>If you want to hear about my latest articles and interesting software development content,</em> <a target="_blank" href="https://mailchi.mp/22b236f812b1/subscribe-to-newsletter"><em>subscribe to my newsletter</em></a><em>.</em></p>
<p>🐦 <strong>TWITTER -</strong> <em>Follow me on</em> <a target="_blank" href="https://twitter.com/DamianDemasi"><em>Twitter</em></a><em>.</em></p>
]]></content:encoded></item></channel></rss>