<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matheus Gomes 👨‍💻</title>
    <description>The latest articles on DEV Community by Matheus Gomes 👨‍💻 (@matheusgomes062).</description>
    <link>https://dev.to/matheusgomes062</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F295021%2F9d8da400-098f-44a3-865e-80e17844844a.jpg</url>
      <title>DEV Community: Matheus Gomes 👨‍💻</title>
      <link>https://dev.to/matheusgomes062</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/matheusgomes062"/>
    <language>en</language>
    <item>
      <title>🧠 System Design: Foundations, Scaling Strategies, and Resilience Patterns</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Mon, 20 Oct 2025 20:58:55 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/system-design-foundations-scaling-strategies-and-resilience-patterns-1b79</link>
      <guid>https://dev.to/matheusgomes062/system-design-foundations-scaling-strategies-and-resilience-patterns-1b79</guid>
      <description>&lt;h2&gt;
  
  
  💡 What Is System Design and Why It’s Valuable
&lt;/h2&gt;

&lt;p&gt;System design is the process of planning how different parts of a software system work together: the architecture, components, data flow, and how everything scales or recovers from failure.&lt;/p&gt;

&lt;p&gt;It aims to make sure your system:&lt;/p&gt;

&lt;p&gt;✅ Works correctly (meets functional requirements)&lt;/p&gt;

&lt;p&gt;⚙️ Performs efficiently and reliably (meets non-functional requirements like scalability, latency, and fault tolerance)&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 Why It’s Valuable
&lt;/h2&gt;

&lt;p&gt;👩💻 Team Growth: Clear boundaries let multiple teams develop without interfering.&lt;/p&gt;

&lt;p&gt;📈 Traffic Growth: Plan for scaling so your app doesn’t crash under load.&lt;/p&gt;

&lt;p&gt;🧰 Risk Reduction: Identify and eliminate bottlenecks or single points of failure.&lt;/p&gt;

&lt;p&gt;💰 Cost Efficiency: Optimize infrastructure to save money at scale.&lt;/p&gt;

&lt;p&gt;🛡️ Reliability: Design for uptime—your users expect it.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧱 Separating Out the Database
&lt;/h2&gt;

&lt;p&gt;When you begin, you might have your app and database all on one machine.&lt;/p&gt;

&lt;p&gt;But soon, as users grow, you’ll need to separate them.&lt;/p&gt;

&lt;p&gt;💬 Example&lt;/p&gt;

&lt;p&gt;Imagine a simple blog app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Your code runs on a web server (for example, Node.js or Python/Django).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It stores posts in a database (e.g., PostgreSQL).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By running the database separately, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Scale your web servers independently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Back up the database securely.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use different database technologies for different needs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🏗️ In production, databases often run on their own managed services, like Amazon RDS or Google Cloud SQL.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏋️ Vertical Scaling (Scaling Up)
&lt;/h2&gt;

&lt;p&gt;Vertical scaling means upgrading your current machine, adding more CPU, memory, or faster SSDs.&lt;/p&gt;

&lt;p&gt;🖥️ Example&lt;/p&gt;

&lt;p&gt;You start with:&lt;/p&gt;

&lt;p&gt;t2.micro: 1 CPU, 1 GB RAM&lt;/p&gt;

&lt;p&gt;Traffic grows, so you upgrade to:&lt;/p&gt;

&lt;p&gt;t2.large: 4 CPUs, 16 GB RAM&lt;/p&gt;

&lt;p&gt;✅ Pros&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simple to implement, often no code changes required.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Low latency and fast in-memory performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ Cons&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;💸 Costs rise quickly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🚫 Machine size has physical limits.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;❌ One failure can take down the whole system.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use vertical scaling when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You’re starting out.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Your app doesn’t yet need multiple servers.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔁 Horizontal Scaling (Scaling Out)
&lt;/h2&gt;

&lt;p&gt;Horizontal scaling means adding more machines instead of upgrading one.&lt;/p&gt;

&lt;p&gt;It’s like adding more waiters to a busy restaurant instead of hiring one superhuman waiter.&lt;/p&gt;

&lt;p&gt;💬 Example&lt;/p&gt;

&lt;p&gt;You start with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 web server handling all requests.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When traffic increases:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more servers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A load balancer will distribute requests among them.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚖️ Load Balancer
&lt;/h2&gt;

&lt;p&gt;A Load Balancer (LB) spreads requests evenly across several servers.&lt;/p&gt;

&lt;p&gt;🧩 How It Works&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Client → LB&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LB → Sends request to the least busy server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Server responds → LB → Client&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;⚙️ LB Responsibilities&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Distribute traffic 🕸️&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Check server health 💉&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Terminate SSL/TLS 🔐&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remove bad servers from rotation 🚫&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💬 Example&lt;/p&gt;

&lt;p&gt;AWS users might use Elastic Load Balancing (ELB).&lt;/p&gt;

&lt;p&gt;In local setups, you might try NGINX or HAProxy.&lt;/p&gt;

&lt;p&gt;✅ Benefits&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Seamless scaling by adding/removing servers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Zero-downtime updates using rolling deployments.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Stateless Services
&lt;/h2&gt;

&lt;p&gt;A stateless service means it doesn’t remember anything between requests.&lt;/p&gt;

&lt;p&gt;All data or sessions are stored elsewhere (like a database or cache).&lt;/p&gt;

&lt;p&gt;💬 Example&lt;/p&gt;

&lt;p&gt;Imagine a shopping cart:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;❌ Stateful: Stored in web server memory. If that server dies, cart is gone.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;✅ Stateless: Cart stored in a database or Redis. Any server can respond.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧭 Benefits&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🔄 Easy to scale horizontally.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;💪 Increased fault tolerance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🚀 Updates and deployments are simpler.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ☁️ Serverless
&lt;/h2&gt;

&lt;p&gt;Serverless computing means you write functions, not servers.&lt;/p&gt;

&lt;p&gt;Cloud providers run them on demand.&lt;/p&gt;

&lt;p&gt;💬 Example&lt;/p&gt;

&lt;p&gt;You upload a photo → this triggers a Lambda function that stores it in S3 and updates a database.&lt;/p&gt;

&lt;p&gt;You don’t manage infrastructure, you only pay per execution.&lt;/p&gt;

&lt;p&gt;✅ Pros&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Zero infrastructure management.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scales instantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You pay only when your code runs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ Cons&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Startup delay (cold starts).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Harder debugging and monitoring.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Time and memory limits.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🪄 Serverless is ideal for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Event-driven apps.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;APIs with unpredictable traffic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lightweight background jobs (e.g., sending emails).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🗃️ Scaling the Databases
&lt;/h2&gt;

&lt;p&gt;Databases are often the hardest to scale, since they hold state.&lt;/p&gt;

&lt;p&gt;⚙️ Strategies&lt;/p&gt;

&lt;h3&gt;
  
  
  📖 1. Read Replicas
&lt;/h3&gt;

&lt;p&gt;Use additional servers for read operations, so the main database focuses on writes.&lt;/p&gt;

&lt;p&gt;✅ Example:&lt;/p&gt;

&lt;p&gt;A news website can serve millions of readers using read replicas, while journalists write only to the primary database.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ 2. Caching
&lt;/h2&gt;

&lt;p&gt;Store frequently accessed data in memory.&lt;/p&gt;

&lt;p&gt;This reduces database load.&lt;/p&gt;

&lt;p&gt;💬 Example:&lt;br&gt;
Instead of repeatedly querying SELECT * FROM product WHERE id=123, cache it for 10 minutes.&lt;/p&gt;




&lt;h3&gt;
  
  
  🧩 3. Sharding (Partitioning)
&lt;/h3&gt;

&lt;p&gt;Split large datasets into smaller parts by a chosen key.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Shard 1: Users 1–1 million&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shard 2: Users 1–2 million&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Boosts throughput and storage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Avoids single DB bottlenecks.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⚠️ Challenges:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Harder migrations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Managing cross-shard queries.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🧮 4. Connection Pooling
&lt;/h3&gt;

&lt;p&gt;Limit DB connections by having a shared pool (e.g., pgbouncer).&lt;/p&gt;

&lt;p&gt;This avoids a DB overload when many app servers connect at once.&lt;/p&gt;




&lt;h3&gt;
  
  
  💡 5. CQRS (Command Query Responsibility Segregation)
&lt;/h3&gt;

&lt;p&gt;Separate read and write operations into different models:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Commands: Insert, update.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Queries: Fetch data, often denormalized.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This enables independent optimization and scaling.&lt;/p&gt;




&lt;h3&gt;
  
  
  🌍 6. Multi‑Region Setup
&lt;/h3&gt;

&lt;p&gt;Replicate data across regions to reduce latency and improve resilience.&lt;/p&gt;

&lt;p&gt;💬 Example:&lt;/p&gt;

&lt;p&gt;Users in Brazil read/write from the São Paulo region, while users in Germany use Frankfurt.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧯 Failover Strategies
&lt;/h2&gt;

&lt;p&gt;When something fails (and it will) your system must recover automatically.&lt;/p&gt;

&lt;p&gt;Below are standard failover patterns, from cheapest to most resilient:&lt;/p&gt;




&lt;h3&gt;
  
  
  🧊 Cold Standby
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Backup system exists but is turned off.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Restored manually from backups.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⏰ RTO: Hours&lt;/p&gt;

&lt;p&gt;💰 Cost: Low&lt;/p&gt;

&lt;p&gt;🧩 Example: Archive systems or staging environments.&lt;/p&gt;




&lt;h3&gt;
  
  
  🌤️ Warm Standby
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Partially active backup that receives continuous data updates.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Scaled up on demand during failure.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⏰ RTO: Minutes&lt;/p&gt;

&lt;p&gt;💰 Cost: Medium&lt;/p&gt;

&lt;p&gt;🧩 Example: E-commerce store backups.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔥 Hot Standby
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Fully provisioned clone, continuously updated and ready to take traffic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;⏰ RTO: Seconds&lt;/p&gt;

&lt;p&gt;💰 Cost: High&lt;/p&gt;

&lt;p&gt;🧩 Example: Critical financial or healthcare systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  🌎 Multi‑Primary (Active‑Active)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Multiple regions serve traffic simultaneously.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Requires bidirectional replication and conflict handling.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;✅ Fastest recovery and lowest latency&lt;/p&gt;

&lt;p&gt;⚠️ Hardest to manage due to data conflicts&lt;/p&gt;

&lt;p&gt;🧩 Example:&lt;/p&gt;

&lt;p&gt;A global chat app — EU users connect to the EU data center, US users to the US, both stay synchronized.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧭 Putting It All Together (A Growth Journey)
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;What You Add&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;🚀 Early Start&lt;/td&gt;
&lt;td&gt;Single server, vertical scaling&lt;/td&gt;
&lt;td&gt;Simple and low-cost setup&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚙️ Growth Stage&lt;/td&gt;
&lt;td&gt;Separate database, stateless app&lt;/td&gt;
&lt;td&gt;Better reliability and maintainability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🌐 Scaling Stage&lt;/td&gt;
&lt;td&gt;Load balancer with multiple servers&lt;/td&gt;
&lt;td&gt;Handles more traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🗂️ Data Scaling&lt;/td&gt;
&lt;td&gt;Caching, read replicas, sharding&lt;/td&gt;
&lt;td&gt;Reduces load on the main database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;🔁 Reliability&lt;/td&gt;
&lt;td&gt;Failover mechanisms, automation&lt;/td&gt;
&lt;td&gt;Increases uptime and resilience&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;⚡ Mature System&lt;/td&gt;
&lt;td&gt;Multi-region deployment, global monitoring&lt;/td&gt;
&lt;td&gt;Supports global traffic and quick recovery&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧩 Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🧠 System design = trade‑offs under constraints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🌱 Start small, evolve realistically — don’t over‑engineer early on.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🏗️ Stateless design + separate databases unlock horizontal scaling.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📊 Database scaling = replicas + caching + sharding + pooling.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;💪 Failover design ensures reliability during disasters.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📈 Evolve incrementally — track performance, failure rates, and cost.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>systemdesign</category>
      <category>programming</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Code Smells: Long Methods</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Tue, 23 Apr 2024 19:19:55 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/code-smells-long-methods-5f2p</link>
      <guid>https://dev.to/matheusgomes062/code-smells-long-methods-5f2p</guid>
      <description>&lt;h2&gt;
  
  
  ✅ TL;DR
&lt;/h2&gt;

&lt;p&gt;You should write like a good presenter, use your words wiselly. Follow this rules in your code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extract methods&lt;/li&gt;
&lt;li&gt;Reduce Local Variables and Parameters&lt;/li&gt;
&lt;li&gt;Decompose Conditionals&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkyfskz2y0swx1b04l3vw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkyfskz2y0swx1b04l3vw.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  👃 Code Smells
&lt;/h2&gt;

&lt;p&gt;What is a code smell? Code Smells are the traces in the code that indicates a deeper problem in the application or codebase. It's like the cough that you do when you are sick, it's a symptom. For code, the Code Smells are symptoms for a bad or spaghetti code.&lt;/p&gt;

&lt;p&gt;One of this symptom is the Long Method problem.&lt;/p&gt;

&lt;p&gt;Imagine that you find this code:&lt;/p&gt;




&lt;h2&gt;
  
  
  ✂️ Extracting Methods
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printOwing&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;printBanner&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Print details.&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"amount: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;getOutstanding&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For some, this is some ok code, but it attracts problems, and it smells bad. It says to me that everything that I need to print, I can just place it inside the &lt;code&gt;printOwing&lt;/code&gt; method. If you see it like it's telling a story, it's like being wordy, it's saying more than it needs.&lt;/p&gt;

&lt;p&gt;"When entering &lt;code&gt;printOwing&lt;/code&gt; you go to &lt;code&gt;printBanner&lt;/code&gt; AND print the name AND THEN print the amount + &lt;code&gt;getOutstading&lt;/code&gt; AND more things that you want to add."&lt;/p&gt;

&lt;p&gt;When telling a story, you want to be focused on the main acts, so a better way to do this would be writing the code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printOwing&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;printBanner&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
  &lt;span class="n"&gt;printDetails&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;getOutstanding&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printDetails&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;outstanding&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"amount: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;outstanding&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"When entering &lt;code&gt;printOwing&lt;/code&gt; you go to &lt;code&gt;printBanner&lt;/code&gt; AND &lt;code&gt;printDetails&lt;/code&gt;"&lt;/p&gt;

&lt;p&gt;If the listener wants to know what's in the &lt;code&gt;printBanner&lt;/code&gt; or &lt;code&gt;printDetails&lt;/code&gt;, he can ask!&lt;/p&gt;

&lt;p&gt;The main thing here is to &lt;strong&gt;extract the method&lt;/strong&gt;, much more like being succinct in a conversation.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4kzi4akq9i57vy1704y.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4kzi4akq9i57vy1704y.gif" width="298" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ♻️ Reduce Local Variables
&lt;/h2&gt;

&lt;p&gt;If your code requires some variable that's being reused, you should place it in a way it can be reused. It's almost like using synonyms or referencing things implicitly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;itemPrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.95&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.98&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's using here the same &lt;code&gt;basePrice&lt;/code&gt;, but it's being repetitive. One way to fix it is doing it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;calculateTotal&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basePrice&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;basePrice&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.95&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;basePrice&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.98&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;basePrice&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;itemPrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When writing like this, you have a great way to change the &lt;code&gt;basePrice&lt;/code&gt; if something is changes. It solidifies the code.&lt;/p&gt;

&lt;p&gt;It be applied to objects also, if you see things like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;amountInvoicedIn&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;start:&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;end:&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;amountReceivedIn&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;start:&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;end:&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;amountOverdueIn&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;start:&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;end:&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can change it to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;amountInvoicedIn&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;date:&lt;/span&gt; &lt;span class="nc"&gt;DateRange&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;amountReceivedIn&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;date:&lt;/span&gt; &lt;span class="nc"&gt;DateRange&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;amountOverdueIn&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nl"&gt;date:&lt;/span&gt; &lt;span class="nc"&gt;DateRange&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is by introducing a &lt;strong&gt;parameter object&lt;/strong&gt;. But you can also &lt;strong&gt;preserve a whole object&lt;/strong&gt;, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;daysTempRange&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getLow&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;daysTempRange&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getHigh&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;withinPlan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withinRange&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;withinPlan&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;withinRange&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daysTempRange&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, if you have this story that the facts are so intricate you can separate part of the story to a different section of you lore. Translating it to code would be like you can try moving the entire method to a separate object via &lt;strong&gt;replace method with method object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It would look like we have this code and we cannot extract the price method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;primaryBasePrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;secondaryBasePrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;tertiaryBasePrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Perform long computation.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One solution would be to turn it into this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;price&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PriceCalculator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;compute&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PriceCalculator&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;primaryBasePrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;secondaryBasePrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;tertiaryBasePrice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;PriceCalculator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Order&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Copy relevant information from the&lt;/span&gt;
    &lt;span class="c1"&gt;// order object.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;compute&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Perform long computation.&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As the refactoring guru tells: &lt;br&gt;
"Transform the method into a separate class so that the local variables become fields of the class. Then you can split the method into several methods within the same class."&lt;/p&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnj1q1gpbfllu02arbqq7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnj1q1gpbfllu02arbqq7.gif" width="250" height="200"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  💡 Decompose Conditional
&lt;/h2&gt;

&lt;p&gt;This feels like the person that talks a whole story to explain possibilities. Like, dude, I just want to know the possibilities, not the whole lore. That's why in the code when we have something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;before&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SUMMER_START&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;after&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;SUMMER_END&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;winterRate&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;winterServiceCharge&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;summerRate&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we change it to:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isSummer&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;summerCharge&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;winterCharge&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way we can be concise and more descriptive. So remember to decompose conditionals.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo9a5c9w1j5ec88fg0fc5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo9a5c9w1j5ec88fg0fc5.gif" width="480" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  📏👍 Rule of thumb
&lt;/h2&gt;

&lt;p&gt;Always remember that in object-oriented code, classes with short methods live longest. The longer a method or function is, the harder it becomes to understand and maintain it. Remember that writing code can be much closer to talking, I mean, so be intentional about your writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 References:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;refactoring.guru&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>cleancode</category>
      <category>programming</category>
      <category>java</category>
      <category>javascript</category>
    </item>
    <item>
      <title>TypeScript: An Introduction to the Statically Typed Superset of JavaScript</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Thu, 09 Feb 2023 14:33:09 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/typescript-an-introduction-to-the-statically-typed-superset-of-javascript-4hgo</link>
      <guid>https://dev.to/matheusgomes062/typescript-an-introduction-to-the-statically-typed-superset-of-javascript-4hgo</guid>
      <description>&lt;p&gt;🚀 &lt;strong&gt;TypeScript&lt;/strong&gt; is a statically typed, object-oriented, and open-source programming language that is a superset of JavaScript. It was developed and maintained by Microsoft and has become one of the most popular programming languages in recent years. TypeScript was designed to enhance JavaScript's functionality and make it easier to write large and complex applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frvl7bd6oegz6ilohwewk.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frvl7bd6oegz6ilohwewk.gif" alt="gif of monkey coding" width="320" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the key features of TypeScript is its static typing system. This means that when you write code in TypeScript, you declare the type of each variable, function, or object, making it easier to catch errors and prevent bugs. For example, you could specify that a particular variable is a number, a string, or an array, and TypeScript will enforce that type throughout the code. This makes the code more predictable and easier to understand, especially in large codebases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4l5bu2c5pr7nk65fx5i.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs4l5bu2c5pr7nk65fx5i.gif" alt="gif of bugs" width="500" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another key feature of TypeScript is its object-oriented programming (OOP) capabilities. TypeScript supports features like classes, interfaces, and inheritance, which make it easier to write organized, reusable code. This makes it a great choice for building complex applications, as you can define objects that encapsulate related data and behavior, and reuse them throughout your code.&lt;/p&gt;

&lt;p&gt;TypeScript also supports features like generics, which allow you to write reusable code that works with any data type, and decorators, which allow you to add additional behavior to your code at runtime. This makes it a versatile language that can be used for a wide range of applications, from small scripts to large-scale enterprise applications.&lt;/p&gt;

&lt;p&gt;In addition to its many features, TypeScript has a large and growing community of developers who contribute to the language, its libraries, and its development tools. There are also many resources available for learning TypeScript, including online tutorials, books, and video courses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F51f39vd2mutwror1n5wu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F51f39vd2mutwror1n5wu.gif" alt="gif of community" width="500" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TypeScript can be used with a variety of tools and frameworks, making it a great choice for developers who are already familiar with JavaScript and want to take their skills to the next level. For example, TypeScript can be used with React, Angular, and Vue, among other popular frameworks, making it a versatile and powerful language for building web applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32y048i30psqblmv3ura.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32y048i30psqblmv3ura.gif" alt="gif of internet browsing" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In conclusion, TypeScript is a statically typed superset of JavaScript that provides many benefits over its dynamically typed parent language. Its static typing system makes it easier to catch errors and prevent bugs, while its OOP capabilities make it easier to write organized and reusable code. With its growing community, wide range of tools and frameworks, and versatile features, TypeScript is a great choice for developers who want to write high-quality and maintainable code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhnjwg98epot9h9v3p2qe.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhnjwg98epot9h9v3p2qe.gif" alt="gif of computer god" width="400" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you like it and...&lt;/p&gt;

&lt;p&gt;See you next time!&lt;/p&gt;

&lt;p&gt;If you find this incredible, just know that this was made using chatGPT &amp;lt;3&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>career</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Vue.js Global Summit '22 - Senior Track Event Summary #1</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Fri, 27 May 2022 20:05:18 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/vuejs-global-summit-22-senior-track-event-summary-1-2f49</link>
      <guid>https://dev.to/matheusgomes062/vuejs-global-summit-22-senior-track-event-summary-1-2f49</guid>
      <description>&lt;p&gt;Hi!&lt;/p&gt;

&lt;p&gt;Vue.js Global Summit '22 just happened and I'm here to tell you everything that you need to know about how it went! There was a lot of information, so let's dive right in!&lt;/p&gt;

&lt;h2&gt;
  
  
  Vuenterprise
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Why big companies do not use vue.js?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flegvwv0f8q842hpc51eg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flegvwv0f8q842hpc51eg.gif" width="500" height="358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Speach made by Arpad Bajzath. He starts by asking why big companies do not use vue.js? The answer is, not clear, we can assume that big companies want something that's stable, reliable, and backed up by other big companies, this is why they tend to prefer to react (Facebook) or angular (google).&lt;/p&gt;

&lt;h3&gt;
  
  
  What do enterprises need?
&lt;/h3&gt;

&lt;p&gt;He explains that enterprises need very important things to adopt a new language like vue. He quotes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modularity: Easily switchable, easily replaceable, and easily movable.&lt;/li&gt;
&lt;li&gt;Reusability: Similar to modularity, reusability makes using the same component in another context easier.&lt;/li&gt;
&lt;li&gt;Screaming Architecture: Your architecture should tell readers about the system, not about the frameworks you used in your system.&lt;/li&gt;
&lt;li&gt;Performance: The app should be fast to use and easier to make changes.&lt;/li&gt;
&lt;li&gt;Maintainability: The technology should have great documentation and be widely adopted, that's something that corporate companies with no intent to risk are looking for. This also makes the code run for a long time, even if the teams change.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tip
&lt;/h3&gt;

&lt;p&gt;Keep the wheel as it is designed. What it means is that don't reinvent vuex or Vue router, study it more and you will see that for most of your cases, it will work just fine. It's easier to adapt to a new update than it's to change the wheel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building SEO friendly URL structure
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fli7c0jse0hyuxs5kpadh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fli7c0jse0hyuxs5kpadh.gif" width="397" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Talk by Łukasz Strączyński.&lt;/p&gt;

&lt;h3&gt;
  
  
  Language
&lt;/h3&gt;

&lt;p&gt;Imagine we are building a listing job offers site, presenting job offers from many cities. Notice that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We will use Nuxt.js&lt;/li&gt;
&lt;li&gt;Language stored in the cookie&lt;/li&gt;
&lt;li&gt;Page accessible on (&lt;a href="http://www.)example.com" rel="noopener noreferrer"&gt;www.)example.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;IDs in our system:

&lt;ul&gt;
&lt;li&gt;Category / Subcategory: integer&lt;/li&gt;
&lt;li&gt;Job offer: UUID&lt;/li&gt;
&lt;li&gt;City code: 3 uppercase letters&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhe8z0hv3tohymd07d4k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffhe8z0hv3tohymd07d4k.png" alt="image.png" width="672" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;City page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Path: &lt;code&gt;/city/:cityCode&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;/city/WAW&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34e41zsx1dgaef0zefs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F34e41zsx1dgaef0zefs3.png" alt="image.png" width="669" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Category page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Path: &lt;code&gt;/city/:cityCode/category/:categoryId&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;/city/WAW/category/1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke2jqq4huognsfw2z6qq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fke2jqq4huognsfw2z6qq.png" alt="image.png" width="673" height="459"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Subcategory page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Path: &lt;code&gt;/city/:cityCode/category/:categoryId/subcategory/:subcategoryId&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;/city/WAW/category/1/subcategory/873&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe8otjk0cj9wxgyzfb0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhe8otjk0cj9wxgyzfb0q.png" alt="image.png" width="669" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Job offer page&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When clicking on the title:&lt;/p&gt;

&lt;p&gt;Path: &lt;code&gt;/city/:cityCode/j/:offerId&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example: &lt;code&gt;/city/WAW/j/6d09c04d-69eb-4bb1-b204-b65de6c767d8&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkuq14d242ch66vzj894h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkuq14d242ch66vzj894h.png" alt="image.png" width="667" height="421"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the problems is the missing language in the URL. Imagine two tabs on the same page opened with 2 different languages, how to know which one is which?&lt;/p&gt;

&lt;p&gt;This is important because Google Search tries to find pages that match the language of the searcher. So it's recommended to use different URLs for each language.&lt;/p&gt;

&lt;p&gt;Like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;example.com/pl&lt;/li&gt;
&lt;li&gt;example.pl&lt;/li&gt;
&lt;li&gt;pl.example.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's &lt;strong&gt;NOT&lt;/strong&gt; recommended storing language information in cookies!&lt;/p&gt;

&lt;h3&gt;
  
  
  Lack of human-readable URLs
&lt;/h3&gt;

&lt;p&gt;Placing a UUID at the URL it's not readable, it's not self-explanatory.&lt;/p&gt;

&lt;p&gt;This is important because if the URL is too "technical" we can't be sure what we will find on the page. Google will try to present the best URL in the searches, so it's better to place words instead of codes, this way you include keywords in your URL.&lt;/p&gt;

&lt;h3&gt;
  
  
  Too complex URL Structure
&lt;/h3&gt;

&lt;p&gt;We have 3 keywords at the URL, also, 5 path segments ("folders") before the actual page.&lt;/p&gt;

&lt;p&gt;This is bad for SEO because pages that are closer to your "home", are more important in respective to SEO.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Whenever possible, shorten URLs by trimming unnecessary parameters.&lt;/li&gt;
&lt;li&gt;Important pages on your site should have no more than 3 "folders"&lt;/li&gt;
&lt;li&gt;Pages that are placed closer to your home page will gain more SEO equity.&lt;/li&gt;
&lt;li&gt;Keyword stuffing is not the best practice in terms of SEO.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Untranslated keywords
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy05e9br33ykfvoysfjae.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy05e9br33ykfvoysfjae.gif" width="480" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should place URL keywords accordingly to the place language you are in, so when using a Polish version of the site, it doesn't show English words in the URL.&lt;/p&gt;

&lt;p&gt;Translated URLs can enhance the user experience by making it more coherent, engaging, and personal. Also, search results show your translated URLs, which indicates to the user that your website is available in their language.&lt;/p&gt;

&lt;p&gt;Google encourages to use of translated URLs.&lt;/p&gt;

&lt;h3&gt;
  
  
  www and non-www domains at the same time.
&lt;/h3&gt;

&lt;p&gt;Serving content from both domains might cause duplicate content issues. It doesn't matter if you pick www or non-www domain, just pick one. Remember to add 301 redirects from one to another.&lt;/p&gt;

&lt;p&gt;The speaker implemented some code to fix some of these issues, but this is not the article for that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bye bye
&lt;/h2&gt;

&lt;p&gt;This is the first article about this event, hope to publish more in the future, since it's almost 20 hours of content!&lt;/p&gt;

&lt;p&gt;Thank you for reading this far! Hope it was informative!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fizlc1eu6lqe918j7tyme.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fizlc1eu6lqe918j7tyme.gif" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>vue</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>TDD e seus fundamentos</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Mon, 09 May 2022 15:48:57 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/tdd-e-seus-fundamentos-4i5e</link>
      <guid>https://dev.to/matheusgomes062/tdd-e-seus-fundamentos-4i5e</guid>
      <description>&lt;p&gt;Saiba o que são testes, seus valores, benefícios e como utilizá-los.&lt;/p&gt;

&lt;p&gt;Olá! Imagino que você tenha ouvido falar bastante sobre TDD e esteja interessado em aprender e praticar os famosos testes de desenvolvimento. Esse texto tem o objetivo de te ajudar nisso!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2ea37as1tbw6dd87ciw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk2ea37as1tbw6dd87ciw.gif" width="265" height="199"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Primeiramente começamos com,&lt;/p&gt;

&lt;h1&gt;
  
  
  O que é TDD?
&lt;/h1&gt;

&lt;p&gt;TDD é um acrônimo para &lt;strong&gt;Test-Driven Development&lt;/strong&gt;, ou seja, &lt;strong&gt;Desenvolvimento Guiado por Testes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;No contexto de programação temos os desenvolvedores, encarregados de solucionar problemas com soluções que funcionam, e os testers, encarregados de realizarem testes próximos aos do consumidor final.&lt;/p&gt;

&lt;p&gt;Porém, apesar dos testers estarem encarregados de realizar testes sobre o código dos desenvolvedores, os desenvolvedores ainda devem realizar testes próprios. Isso porque é improdutivo enviar e receber correções para testers, pois isso toma tempo e esforço de muitas pessoas, atrasando o desenvolvimento.&lt;/p&gt;

&lt;p&gt;Pensando nisso, os desenvolvedores então passaram a criar testes para suas aplicações de forma a assegurar que seus códigos funcionam minimamente de acordo com o planejado, sem bugs. Eles seguiam a ordem de desenvolver a funcionalidade e então aplicar testes em cima.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91773cjaasyd1sk07gol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F91773cjaasyd1sk07gol.png" alt=" " width="500" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;O problema acontece no ponto em que testar algo que você construiu atrapalha na perspectiva de encontrar problemas, pois você vai estar enviesado pelo seu desenvolvimento. Nesse sentido, os desenvolvedores começaram a realizar os testes **antes **do desenvolvimento da funcionalidade&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkfus9qlm0j0c158h7q1u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkfus9qlm0j0c158h7q1u.png" alt=" " width="500" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;É aí que entra o TDD.&lt;/p&gt;

&lt;h2&gt;
  
  
  O que TDD não é:
&lt;/h2&gt;

&lt;p&gt;TDD não é&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Método de testes / Técnica de QA&lt;/li&gt;
&lt;li&gt;Substituto de QA/Testers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  O que TDD é:
&lt;/h2&gt;

&lt;p&gt;TDD é&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uma "&lt;em&gt;técnica de design&lt;/em&gt;" para "&lt;em&gt;designs emergentes&lt;/em&gt;"&lt;/li&gt;
&lt;li&gt;Testar antes de desenvolver&lt;/li&gt;
&lt;li&gt;Exemplos sobre o que o "Sistema deve fazer"&lt;/li&gt;
&lt;li&gt;Especificações vivas&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Origem do TDD
&lt;/h2&gt;

&lt;p&gt;Sua origem data de 1990 quando Kent Beck desenvolveu essa técnica de desenvolvimento de softwares onde o teste era feito antes do desenvolvimento como parte do eXtreme Programming (XP).&lt;/p&gt;

&lt;p&gt;eXtreme Programming é um framework ágil de desenvolvimento de software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pessoas importantes que apoiam o TDD
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.kentbeck.com/" rel="noopener noreferrer"&gt;Kent Beck&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://martinfowler.com/" rel="noopener noreferrer"&gt;Martin Fowler&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/egamma" rel="noopener noreferrer"&gt;Erich Gamma&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdwwiiazcduas0nl5f3y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdwwiiazcduas0nl5f3y.png" alt=" " width="500" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Ciclo de desenvolvimento de TDD
&lt;/h1&gt;

&lt;p&gt;Iniciamos com uma lista de requerimentos, geralmente as funcionalidades requisitadas. Depois, escrevemos os testes para cada item da lista, partindo do mais básico. Por exemplo, se determinado método existe. Você irá então rodar o teste e fazer ele &lt;strong&gt;falhar&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Após, você irá escrever o código mais simples para fazer o teste passar. Escreveremos apenas o necessário para fazer o teste passar, nada mais, nada menos.&lt;/p&gt;

&lt;p&gt;Então rodamos o teste novamente e fazemos ele &lt;strong&gt;passar&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;Por fim, &lt;strong&gt;refatoramos&lt;/strong&gt; o código para verificar o que podemos melhorar no código sem modificar a funcionalidade, e então repetimos o ciclo novamente de pensar em um novo teste para a funcionalidade.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo80wkgsafdokbdk766uo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo80wkgsafdokbdk766uo.png" alt=" " width="250" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;E aqui temos o famoso "Red, Green, Blue"!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Red&lt;/strong&gt; - Faça ele falhar&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Código é testável&lt;/li&gt;
&lt;li&gt;Escrevemos e especificamos a validação&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Green&lt;/strong&gt; - Faça ele passar&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Código de acordo com o requerimento&lt;/li&gt;
&lt;li&gt;Solução mais simples que funciona&lt;/li&gt;
&lt;li&gt;Feito para passar no teste&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Blue&lt;/strong&gt; - Refatore&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Limpeza do código&lt;/li&gt;
&lt;li&gt;Identação&lt;/li&gt;
&lt;li&gt;Remove &lt;em&gt;code smells&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Repensa o design&lt;/li&gt;
&lt;li&gt;Deleta código desnecessário.&lt;/li&gt;
&lt;li&gt;Boas práticas!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Benefícios do TDD
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Redução de bugs: reduz o tempo de testes de QA&lt;/li&gt;
&lt;li&gt;Melhor design de código: Código melhor reutilizado, Não redundante, Coeso, Sem acoplamento e limpo!&lt;/li&gt;
&lt;li&gt;Trabalho em equipe: O time passa a entender melhor o código pela implementação dos testes e a se comunicar melhor para implementar os testes corretos.&lt;/li&gt;
&lt;li&gt;Documentação: Os testes passam a ser uma documentação viva do código.&lt;/li&gt;
&lt;li&gt;Eficiência: Os próximos códigos serão mais eficientes, visto que os testes fundamentais para que o projeto funcione bem estão presentes. Não haverá necessidade de perder tempo pensando se outra parte do projeto irá quebrar.&lt;/li&gt;
&lt;li&gt;Manutenção: Como já existem testes implementados, qualquer mudança não passará despercebida. O número de bugs é bem menor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Dificuldades com TDD
&lt;/h2&gt;

&lt;p&gt;Algumas das dificuldades envolvem:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uso de Testes de Integração&lt;/li&gt;
&lt;li&gt;Testar certos casos como: UI, DB, Network, Sistemas externos, Arquivos, Código legado&lt;/li&gt;
&lt;li&gt;Investimento de tempo&lt;/li&gt;
&lt;li&gt;Falso senso de segurança. Como TDD não substitui QA, nós temos uma falsa sensação de segurança.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Testes antes do desenvolvimento VS Testes depois do desenvolvimento
&lt;/h2&gt;

&lt;p&gt;Podemos ver no gráfico do livro "&lt;a href="https://www.amazon.com.br/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627" rel="noopener noreferrer"&gt;Growing Object-Oriented Software, Guided by Tests&lt;/a&gt;" uma explicação simples sobre a utilização de testes antes vs testes após o desenvolvimento.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg931x9m0wtecwa1s0p2d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg931x9m0wtecwa1s0p2d.png" alt="graph.png" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Quanto desenvolvemos primeiro, temos que o início é tranquilo, estamos entregando e fazendo novas funcionalidades com tranquilidade. Porém quando nos aproximamos da deadline, temos que o caos/estresse aumenta exponencialmente. Isto porque ao adicionar novas funcionalidades o projeto passa a ficar instável, alguns bugs passam despercebidos, ou até retornam do QA, o que toma mais tempo para serem solucionados. As funcionalidades novas passam a quebrar as antigas, e corrigir as novas com gambiarras passa a ser mais fácil do que corrigir ambas. Temos uma bomba relógio.&lt;/p&gt;

&lt;p&gt;Quando utilizamos testes antes, temos que inicialmente o desenvolvimento é estressante, visto que demora para progredir, porém ao avançarmos no tempo, as novas funcionalidades se tornam tranquilas para implementar. Não existem tantos bugs, e poucas coisas retornam do QA. Como novas funcionalidades não podem quebrar as antigas, o código avança com fluidez. O código se mantém claro e documentado!&lt;/p&gt;

&lt;h2&gt;
  
  
  A técnica AAA
&lt;/h2&gt;

&lt;p&gt;Para estruturar os testes, nós utilizamos a técnica AAA:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Arrange&lt;/strong&gt;: Inicializar os objetos e declarar as variáveis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Act&lt;/strong&gt;: Chamar os métodos de testes utilizando os parâmetros criados no primeiro passo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assert&lt;/strong&gt;: Verificar os resultados. Comparar os resultados com suas respectivas expectativas.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tipos de testes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Unitários
&lt;/h3&gt;

&lt;p&gt;Testes unitários são implementações de códigos que tem por objetivo testar unidades isoladas de funcionalidades. Ou seja, testes de unidade de código isolados. Para realizar testes unitários é necessário o acesso ao código que está sendo testado. Estes são os testes mais básicos, rápidos e fundamentais de serem feitos.&lt;/p&gt;

&lt;h3&gt;
  
  
  Integração
&lt;/h3&gt;

&lt;p&gt;Testes de integração são importantes para verificar se as unidades funcionam juntas. Por mais que as unidades de código funcionem de forma correta, é necessário verificar se elas funcionam em conjunto.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97rjedypq0yr2mrucexj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97rjedypq0yr2mrucexj.gif" width="280" height="204"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  End to End
&lt;/h3&gt;

&lt;p&gt;Testes end to end, ou testes de sistema, são testes que verificam o comportamento e capacidades do produto ou sistema como um todo. São os testes mais próximos do que o usuário vai encontrar na utilização final. São testes que raramente são feitos por serem lentos e complexos.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddyq0k15oqohooh0fqp5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fddyq0k15oqohooh0fqp5.gif" width="500" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Dublês de testes
&lt;/h2&gt;

&lt;p&gt;Os testes unitários necessitam de dados para utilizar como exemplos para alguns métodos. Assim, devemos simular dados para enviar para os métodos nos testes.&lt;/p&gt;

&lt;p&gt;Dublês de teste são utilizados para realizar uma simulação das dependências da unidade que será testada. Martin Fowler, &lt;a href="https://martinfowler.com/bliki/TestDouble.html" rel="noopener noreferrer"&gt;lista os seguintes dublês de teste no seu artigo sobre TestDouble&lt;/a&gt;: Dummy, Fake, Stubs, Spies e Mocks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dummy
&lt;/h3&gt;

&lt;p&gt;Este tipo de dublê é usado apenas para que a execução do teste seja possível, ou seja, não interage com a unidade testada, mas precisa existir para que o teste seja bem sucedido. A grande vantagem de utilizar este tipo de dublê é não precisar criar uma série de objetos que não serão testados.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fake
&lt;/h3&gt;

&lt;p&gt;Objetos que possuem implementação, porém com o objetivo de diminuir a complexidade e/ou tempo de execução de alguns processos para acelerar os testes, porém nunca usado em produção.&lt;/p&gt;

&lt;h3&gt;
  
  
  Stubs
&lt;/h3&gt;

&lt;p&gt;Fornecem respostas prontas para as chamadas feitas durante o teste, geralmente não responde a nada fora do que está programado.&lt;/p&gt;

&lt;h3&gt;
  
  
  Spies
&lt;/h3&gt;

&lt;p&gt;São mocks que também registram algumas informações com base em como eles foram chamados. Uma forma disso pode ser um serviço de e-mail que registra quantas mensagens foram enviadas, ou apenas para identificar se determinado método foi chamado, ou não. Geralmente é programado para capturar o método chamado e repassar para o objeto espionado. Sendo assim o método é efetivamente chamado.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mocks
&lt;/h3&gt;

&lt;p&gt;São objetos pré-programados com expectativa e forma como as chamadas são feitas, e o que espera receber. Os mocks verificam o contrato entre as classes. Se algo estiver fora do programado, geralmente lança exceção caso não esteja configurado. A ideia por trás dos mocks é de abstrair a lógica da classe dependente, ao mesmo tempo que garante que as interações ocorrem dentro do esperado.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fim
&lt;/h2&gt;

&lt;p&gt;Espero que este artigo tenha deixado claro os principais conceitos sobre TDD!&lt;/p&gt;

&lt;p&gt;Te vejo na próxima!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpc1habjvmh9xxtjblc00.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpc1habjvmh9xxtjblc00.gif" width="380" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Referências
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.udemy.com/course/test-driven-development-tdd-essentials-training-course/" rel="noopener noreferrer"&gt;https://www.udemy.com/course/test-driven-development-tdd-essentials-training-course/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/livtavares/tdd-create-tests-that-make-sense-3mj8"&gt;https://dev.to/livtavares/tdd-create-tests-that-make-sense-3mj8&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@felippeduarte/dubl%C3%AAs-de-teste-mock-stub-dummy-fake-e-spy-80a5cb5fc3c2" rel="noopener noreferrer"&gt;https://medium.com/@felippeduarte/dubl%C3%AAs-de-teste-mock-stub-dummy-fake-e-spy-80a5cb5fc3c2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/henriquepalote/vamos-falar-de-dubles-de-teste-test-double-para-testes-unitarios-2725"&gt;https://dev.to/henriquepalote/vamos-falar-de-dubles-de-teste-test-double-para-testes-unitarios-2725&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Aulas do &lt;a href="https://www.linkedin.com/in/otavio-lemos-0271399/" rel="noopener noreferrer"&gt;Otávio Lemos&lt;/a&gt; e seu curso de &lt;a href="https://www.otaviolemos.com.br/" rel="noopener noreferrer"&gt;TDD&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>testing</category>
      <category>beginners</category>
      <category>todayilearned</category>
      <category>tdd</category>
    </item>
    <item>
      <title>5 types of decision-makers</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Thu, 28 Apr 2022 16:01:47 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/5-types-of-decision-makers-221b</link>
      <guid>https://dev.to/matheusgomes062/5-types-of-decision-makers-221b</guid>
      <description>&lt;p&gt;I’m taking a course on &lt;a href="https://www.udemy.com/course/communication-fundamentals-how-to-communicate-better" rel="noopener noreferrer"&gt;Communication Fundamentals&lt;/a&gt; and just learned the 5 types of decision-makers. I will be writing down all that I learned.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F030ig299dg54tm2wv69p.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F030ig299dg54tm2wv69p.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The 5 types are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;The Charismatics&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Thinkers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Skeptics&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Followers&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The Controllers&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🫀🧠The Charismatics:
&lt;/h2&gt;

&lt;p&gt;These are the most easily intrigued by new ideas. They love novel and new ways of thinking, their experience has led them to explore these new ideas. In that way, they will be readily willing to listen to your ideas, but rest assured that they will use their experience to balance their decision-making around facts and emotion. So you want to appeal to their head 🧠 and their heart 🫀 .&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠📚The Thinkers:
&lt;/h2&gt;

&lt;p&gt;Hard people to convince, since they want an argument that’s very well supported by data. They want to take the time to make the decision, even if it takes a lot of time. So you might be in a situation where you have to present the data more than once, or in different ways in order to get that decision from that style of decision-maker.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤷🤔The Skeptics:
&lt;/h2&gt;

&lt;p&gt;They will always look at things from a “half empty” perspective. They are suspicious of new ways of thinking, particularly if it challenges their mental models and their way of thinking, and their view of the world. That’s why they will always find a reason why not. Usually seen as an aggressive and difficult person to deal with when regards to decisions. Provide them with enough information so that their assumptions are challenged.&lt;/p&gt;

&lt;h2&gt;
  
  
  🐹🕵️The Followers:
&lt;/h2&gt;

&lt;p&gt;They want to know that somebody else has already done it. They are always the last to come on board in terms of new trends and new ways of doing things. It’s like they will never be the guinea pig in an experiment. Which experts have used it? Which people support it? How many? How many companies use it? Which companies? So come with expert opinions and facts to get your favorable decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠📊The Controllers:
&lt;/h2&gt;

&lt;p&gt;100% mind-focused when it comes to decision-making. This group of people wants to focus on the data, and solely on the data. They are not going to become emotionally involved in any decision. They cannot stand ambiguity and uncertainty.&lt;/p&gt;

&lt;p&gt;Hope this article helps you understand more about communication!&lt;/p&gt;

&lt;p&gt;See you guys later!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn4pnhlw46qkhmxqqdz5k.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn4pnhlw46qkhmxqqdz5k.gif" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softskills</category>
      <category>communication</category>
      <category>decisionmakers</category>
    </item>
    <item>
      <title>3 Secret Vue Patterns for Productivity Boost!</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Thu, 10 Mar 2022 22:34:54 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/3-secret-vue-patterns-for-productivity-boost-5hhm</link>
      <guid>https://dev.to/matheusgomes062/3-secret-vue-patterns-for-productivity-boost-5hhm</guid>
      <description>&lt;h2&gt;
  
  
  Productivity Boosts
&lt;/h2&gt;

&lt;p&gt;Hello World! 👋&lt;/p&gt;

&lt;p&gt;I was watching this lecture about &lt;a href="https://www.youtube.com/watch?v=7lpemgMhi0k" rel="noopener noreferrer"&gt;Secret Vue Patterns&lt;/a&gt; and I thought about sharing with you people some vue patterns that I learned! This time it will be only about productivity and how to improve it!&lt;/p&gt;

&lt;p&gt;Hope you like it!&lt;/p&gt;

&lt;p&gt;Let's start with...&lt;/p&gt;

&lt;h3&gt;
  
  
  🔵Smarter watchers
&lt;/h3&gt;

&lt;p&gt;Imagine we are working in a search input component, so let's say we want to fetch on created, then watch the input.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;created&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchUserList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;searchText&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchUserList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can improve this code by making the watcher accept method names as strings making it look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;created&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fetchUserList&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;searchText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetchUserList&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reduces a few lines and makes the code cleaner. 🤗&lt;/p&gt;

&lt;p&gt;The next improvement we can make is by making the watcher call themselves on created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;searchText&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetchUserList&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;immediate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that now the searchText was a string and now is an object!&lt;/p&gt;

&lt;p&gt;Let's analyze some topics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;handler: Is the function (or string that has the name of the method) that we want to call.&lt;/li&gt;
&lt;li&gt;immediate: When true means that we don't need to use created hook anymore because the handler will be called as soon as the component is ready, it will be immediately.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, since everything is in a watcher now you can reduce the surface area for bugs in your code. Writing this way makes your code cleaner.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔵Component Registration
&lt;/h3&gt;

&lt;p&gt;We see in almost every project the following pattern in component registration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BaseButton&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./base-button&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BaseIcon&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./base-icon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BaseInput&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./base-input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;components&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;BaseButton&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;BaseIcon&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;BaseInput&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It might be a lot of code at first, but we can make it cleaner and more productivity-focused using it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Can be used on main.js or in a components/_globals.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Vue&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;upperFirst&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash/upperFirst&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;camelCase&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash/camelCase&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// Requeire in a base component context&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;requireComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sr"&gt;/base-&lt;/span&gt;&lt;span class="se"&gt;[\w&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;vue$/&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;requireComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get component config&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;requireComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Get PascalCase name of component&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;componentName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;upperFirst&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\.\/&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.\w&lt;/span&gt;&lt;span class="sr"&gt;+$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// Register component globally&lt;/span&gt;
    &lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;component&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;componentName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First: This code we usually place in the main.js file, but we can also create a file called '_globals.js' and place it at our components directory.&lt;/p&gt;

&lt;p&gt;Second: The following part gets all the files with the 'base' prefix and is a '.vue' file, which is commonly used to create custom vue components that are used everywhere. But hey, you can change it if you want to.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;requireComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sr"&gt;/base-&lt;/span&gt;&lt;span class="se"&gt;[\w&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;]&lt;/span&gt;&lt;span class="sr"&gt;+&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;vue$/&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that, we need to get the component config and the pascal case version of that component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;requireComponent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Get component config&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;requireComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// Get PascalCase name of component&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;componentName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;upperFirst&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;\.\/&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.\w&lt;/span&gt;&lt;span class="sr"&gt;+$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then we register the component at the bottom:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;component&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;componentName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a global registration, which means it will be available to the whole app.&lt;/p&gt;

&lt;p&gt;Also, I need to say that this tip only works with webpack&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra advanced webpack tip:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this part of the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Vue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;component&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;componentName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;componentConfig&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If in your .vue component you export default that means your component options will be under &lt;code&gt;component.config.default&lt;/code&gt;, which means it will be under the default option at the exported module.&lt;/p&gt;

&lt;p&gt;If you are importing using the ES6 syntax (import something from 'something'), that automatically will look for a default. When you are using required tho, it doesn't.&lt;/p&gt;

&lt;p&gt;So we have to specify that we want the default or, if you never exported default in your .vue component (&lt;code&gt;module.exports =&lt;/code&gt;), then your component options will be under componentConfig.&lt;/p&gt;

&lt;p&gt;Also, if your vue component doesn't have a script tag, then your component will also be under &lt;code&gt;componentConfig.default&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After all, using that pattern, we don't need to import any 'base' component, just use it when needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But why not then import all the components like that?&lt;/strong&gt;&lt;br&gt;
Well, there's a reason, when you import everything globally, the components that you are not using will be in the distribution bundle when building using webpack. So, imagine that you make a specific navbar for a specific category of the user since every component is imported globally, even if you are not showing it to the final user, it's at the webpack bundle.&lt;/p&gt;

&lt;p&gt;That's bad because your bundle will be big and over time will be difficult to maintain.&lt;/p&gt;
&lt;h3&gt;
  
  
  🔵Module Registration
&lt;/h3&gt;

&lt;p&gt;A bit similar to the previous tip, but this time is for modules.&lt;br&gt;
For those who don't know, vuex modules are little pieces of state management that you can bring to your application.&lt;/p&gt;

&lt;p&gt;PS: this isn't a pattern exclusive to vuex, you can find it in redux for example.&lt;/p&gt;

&lt;p&gt;You will find it in projects like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./modules/auth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;posts&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./modules/posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;comments&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./modules/comments&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Vuex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;posts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;comments&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's one way to improve the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// index.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;camelCase&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash/camelCase&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;requireModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;js$/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;modules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="nx"&gt;requireModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Don't register this file as a Vuex module&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;moduleName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;(\.\/&lt;/span&gt;&lt;span class="sr"&gt;|&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;js&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;moduleName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;requireModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;modules&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First: &lt;br&gt;
We are requiring all of the js files, inside the current folder and we are going through each of those files, and if the file name is index.js we jump it. It's the only thing in that folder that won't be a module.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// modules/index.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;camelCase&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash/camelCase&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;requireModule&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;context&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;js$/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;modules&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then camel case the file name and add it to a modules hash, or modules object. Requiring the module by its file name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;requireModule&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Don't register this file as a Vuex module&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./index.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;moduleName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;camelCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;(\.\/&lt;/span&gt;&lt;span class="sr"&gt;|&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;js&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;moduleName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;requireModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we just export all those modules:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;modules&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Extra tip&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to use namespaced modules, you can change them to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// [...]&lt;/span&gt;
    &lt;span class="nx"&gt;modules&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;moduleName&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;namespaced&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nf"&gt;requireModule&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileName&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now our store file will look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;modules&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./modules&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Vuex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Store&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="nx"&gt;modules&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Much better.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed the reading! Any tips or mistakes I committed, please feel free to write them down below!&lt;/p&gt;

&lt;p&gt;See ya next time!🤠&lt;/p&gt;

</description>
      <category>vue</category>
      <category>pattern</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Easy fix for a simple problem</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Sat, 26 Feb 2022 15:29:26 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/easy-fix-for-a-simple-problem-j2o</link>
      <guid>https://dev.to/matheusgomes062/easy-fix-for-a-simple-problem-j2o</guid>
      <description>&lt;h2&gt;
  
  
  Introducion 💻
&lt;/h2&gt;

&lt;p&gt;Hi, I'm writing this after almost 30 minutes looking into this problems, just to know it was an easy fix.&lt;/p&gt;

&lt;p&gt;So... Let's go!&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem 💾
&lt;/h2&gt;

&lt;p&gt;The problem was when learning about creating a &lt;a href="https://www.youtube.com/watch?v=-iwjiiCGiO0" rel="noopener noreferrer"&gt;back-end server&lt;/a&gt;, at some point it says to create a new database with the name that you used in the orm. The command used in the video to create was &lt;code&gt;createdb server_name&lt;/code&gt;, but it gave a problem about password in my windows 10 machine. &lt;/p&gt;

&lt;p&gt;The problema was the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;createdb testdatabase 

createdb: error: connection to server at &lt;span class="s2"&gt;"localhost"&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;::1&lt;span class="o"&gt;)&lt;/span&gt;, port 5432 failed:
FATAL:  password authentication failed &lt;span class="k"&gt;for &lt;/span&gt;user &lt;span class="s2"&gt;"&amp;lt;username_placeholder&amp;gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So after around 30 minutes investigating I discovered that was symply about the command used.&lt;/p&gt;

&lt;p&gt;The right command is the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;createdb &lt;span class="nt"&gt;-U&lt;/span&gt; postgres testdatabase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope it answer your search to solve it. Also, hope you don't lost 30 minutes searching!&lt;/p&gt;

&lt;p&gt;See ya!&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>windows</category>
      <category>cmd</category>
      <category>problem</category>
    </item>
    <item>
      <title>Git Workflow para times e empresas!</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Mon, 14 Jun 2021 19:35:47 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/git-workflow-para-times-e-empresas-4dae</link>
      <guid>https://dev.to/matheusgomes062/git-workflow-para-times-e-empresas-4dae</guid>
      <description>&lt;h2&gt;
  
  
  Introdução
&lt;/h2&gt;

&lt;p&gt;Esse artigo tem como objetivo introduzir o Git WorkFlow de uma forma genérica, assim como estabelecer um padrão para mensagens utilizadas no versionamento. É de extrema importância que as orientações descritas neste documento sejam seguidas de forma &lt;strong&gt;rígida&lt;/strong&gt; e &lt;strong&gt;comprometida&lt;/strong&gt; pela equipe para um melhor funcionamento do projeto como um todo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Considerações iniciais
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Utilizamos o Git como nosso sistema de controle de versão;&lt;/li&gt;
&lt;li&gt;Nosso WorkFlow do repositório é baseado na ideia do &lt;a href="https://www.atlassian.com/br/git/tutorials/comparing-workflows/gitflow-workflow" rel="noopener noreferrer"&gt;GitFlow&lt;/a&gt;;&lt;/li&gt;
&lt;li&gt;Nosso fluxo de desenvolvimento envolve três branches que podem ser abstraídas como quatro etapas do desenvolvimento de uma atividade;&lt;/li&gt;
&lt;li&gt;Cada uma dessas branches tem o papel de refletir um ambiente de desenvolvimento.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5wf8j5slc6yndij8bz0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs5wf8j5slc6yndij8bz0.gif" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Git WorkFlow - Getting Started
&lt;/h2&gt;

&lt;p&gt;Passo-a-passo das tecnologias e ferramentas necessárias para fluxo de desenvolvimento com Git:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Ter o Git instalado na sua máquina:
Para saber se esta instalado, abra o CMD (tecla Win+R depois escreva CMD), execute o comando &lt;code&gt;git --version&lt;/code&gt;, caso apareça a mensagem semelhante a esta:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nu2kd6xrjr0oz5uq502.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nu2kd6xrjr0oz5uq502.png" width="604" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;✔ Você pode prosseguir&lt;/p&gt;

&lt;p&gt;Se não, procure instalar o &lt;a href="https://git-scm.com/book/pt-br/v2/Come%C3%A7ando-Instalando-o-Git" rel="noopener noreferrer"&gt;git&lt;/a&gt; ou procure a equipe de Infra do seu serviço.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum072pu0luimyaoty8a9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fum072pu0luimyaoty8a9.gif" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Por que devemos usar o Git?
&lt;/h2&gt;

&lt;p&gt;Antes de iniciar com o Git Flow, precisamos entender o "por quê?" da necessidade de se utilizar Git para controle de versões em um projeto. &lt;/p&gt;

&lt;p&gt;Primeiro iremos pensar em um projeto sem qualquer tipo de controle de versão (como SVN, Mercurial e etc.). Para que um desenvolvedor possa fazer alguma alteração no projeto que está em produção, ele irá precisar modificar diretamente o projeto principal ou fazer uma cópia do mesmo e, mais tarde, sobrescrever os arquivos antigos deste projeto. Neste caso, se duas pessoas (A e B) copiarem o projeto principal e depois ambas fizerem suas modificações em um mesmo arquivo, mais tarde, quando a pessoa A atualizar suas modificações no projeto principal, essas serão excluídas pelas modificações da pessoa B, pois ele irá sobrescrever as modificações de A, sem ao menos saber que haviam sido feitas. &lt;/p&gt;

&lt;p&gt;Em suma, não existe controle de versão e mesmo que, de alguma forma, se adotassem estratégias com os desenvolvedores em conjunto, o risco de se perder dados é muito grande! &lt;/p&gt;

&lt;p&gt;Quando utilizamos o Git a situação é melhorada exponencialmente, uma vez que o projeto está sendo versionado. Numa mesma realidade acima, em que A e B modificam um mesmo arquivo (que agora deve se encontrar em um repositório), agora com Git, quando a pessoa A inserir suas atualizações no projeto, estas serão aceitas sem problemas, mas quando a pessoa B for fazer a mesma coisa, ele deverá primeiramente baixar as atualizações do projeto, antes de realizar as suas modificações. Desta forma, nenhuma modificação realizada anteriormente será perdida e todos os desenvolvedores terão que adotar este processo. Existem casos em que será necessária a resolução de conflitos. Eles ocorrerão quando o desenvolvedor B, do caso acima, modificar a mesma linha do desenvolvedor A. O Git irá identificar que uma mesma linha foi modificada e ele não consegue interpretar qual seria linha correta, então antes de "subir" suas alterações, o desenvolvedor B deverá ver qual linha deve ser mantida, a sua, a de A, ou uma combinação das duas linhas, resolvendo assim o conflito gerado.&lt;/p&gt;

&lt;p&gt;Ainda assim o projeto está sujeito a erros, podendo estes conflitos serem resolvidos erroneamente, sem o devido cuidado e códigos produzidos de maneira equivocada. Erros estes que poderão ser evitados se existir uma cultura de versionamento bem implementada. &lt;/p&gt;

&lt;p&gt;Todos os desenvolvedores que tiverem permissão para executar modificações nos códigos devem, obrigatoriamente, ter conhecimento de Git, para que não ocorram falhas. Este artigo irá abordar os padrões adotados para um versionamento de melhor qualidade atendendo as necessidades requisitadas pelo sistema da sua empresa.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F96l095miqzj86p3qmcy9.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F96l095miqzj86p3qmcy9.gif" width="480" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  O que é um Git WorkFlow ❓
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwac-cdn.atlassian.com%2Fdam%2Fjcr%3Acc0b526e-adb7-4d45-874e-9bcea9898b4a%2F04%2520Hotfix%2520branches.svg%3FcdnVersion%3D1652" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwac-cdn.atlassian.com%2Fdam%2Fjcr%3Acc0b526e-adb7-4d45-874e-9bcea9898b4a%2F04%2520Hotfix%2520branches.svg%3FcdnVersion%3D1652" width="800" height="574"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;O sistema de controle de versão Git trabalha com branches, que nada mais são do que ramificações (linhas independentes) de desenvolvimento nas quais podem se realizar modificações sem que isso afete a branch principal.&lt;/p&gt;

&lt;p&gt;Um Git WorkFlow se trata de um padrão estabelecido para definição das interações necessárias entre diferentes branches em um projeto e bem como o seu gerenciamento.&lt;/p&gt;

&lt;p&gt;Existem diversos modelos de Git WorkFlow como o GitLab Flow, GitHub Flow, GitFlow e etc. O Git Workflow adotado pelo versionamento deste texto é inspirado nos principais fluxos acima citados, sendo organizado da seguinte forma:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;master&lt;/strong&gt;: É a nossa branch principal! Tenha CUIDADO ao se fazer modificações na mesma! Procure evitar qualquer modificação direta. É a
branch que contém a versão mais estável do sistema, assim as modificações inseridas nessa branch poderão ser visualizadas no ambiente de produção. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;homolog&lt;/strong&gt;: Ambiente de validação para os clientes. Aqui temos as modificações que os clientes poderão validar e que já passaram pela validação dos devs. Qualquer sugestão de modificação deve então ser redirecionada aos gestores que então devem fazer um chamado para ser alterado na develop e então subido para homolog.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;develop&lt;/strong&gt;: A branch de homolog abrigará todas as modificações que já foram testadas internamente pela empresa. Nesse caso, essa branch ainda pode conter modificações que ainda não foram validadas pelo cliente. As alterações que são inseridas nessa branch poderão ser visualizadas no ambiente de develop; Uma das branchs mais importantes, os desenvolvedores sempre trabalham em cima dessa branch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;feature&lt;/strong&gt;: A maior parte das branches serão criadas a partir da branch de &lt;strong&gt;develop&lt;/strong&gt; e terão o nome de feature. A branch de feature deverá abrigar todas as modificações específicas da task. É a branch que contém as modificações que deverão ir para o ambiente de homolog.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;test&lt;/strong&gt;: Existem algumas empresas que trabalham com testes, e muitas delas adotam uma branch única para esses casos, dividindo assim o serviço com um ambiente específico para testes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzb6avriohcownr3izwn1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzb6avriohcownr3izwn1.gif" width="400" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Comandos básicos do Git ✒️
&lt;/h2&gt;

&lt;p&gt;Listando todas as branches contidas no seu repositório local:  &lt;code&gt;git branch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewp03fln0w9b3fn58jgi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fewp03fln0w9b3fn58jgi.png" alt="image-20201110163503614" width="502" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Verificar a branch atual selecionada e o status da sua working copy:  &lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4rm2eoairxb0oy0zfa3l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4rm2eoairxb0oy0zfa3l.png" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Atualizar as referências do repositório para as versões contidas no servidor:  &lt;code&gt;git fetch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Trocar a Branch atual para outra: &lt;code&gt;git checkout &amp;lt;nome_branch&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OBS&lt;/strong&gt;: Sempre que for necessário selecionar uma branch que está apenas no servidor do repositório deverá ser executado anteriormente o comando: &lt;code&gt;git fetch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Atualizando o conteúdo de uma branch para o conteúdo do repositório remoto: &lt;code&gt;git pull&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Enviando o conteúdo de uma branch parar o repositório remoto: &lt;code&gt;git push origin &amp;lt;nome_branch_atual&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Resetando o conteúdo de uma branch para o seu conteúdo do repositório remoto: &lt;code&gt;git reset --hard origin/&amp;lt;nome_branch_atual&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Nomenclatura de branches
&lt;/h2&gt;

&lt;p&gt;As branches são nomeadas contendo os seguintes parâmetros:&lt;/p&gt;

&lt;p&gt;Tipo da Tarefa / Número da sprint / Identificação do Work Item&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Tipo da Tarefa
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;feature&lt;/strong&gt;: indica que a branch criada deverá implementar alguma funcionalidade nova no sistema. &lt;/p&gt;

&lt;p&gt;Ex.: ferramenta nova, adição de uma funcionalidade em alguma ferramenta. feature/S202104-1/ABC-1&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;fix&lt;/strong&gt;: indica que a branch que deverá corrigir algum bug no sistema. &lt;/p&gt;

&lt;p&gt;Ex.: problema na busca da ferramenta X. fix/S202104-1/ABC-1&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;hotfix&lt;/strong&gt;: indica que a branch criada é uma branch que deverá corrigir algum bug rapidamente e que deve ser inserida no ambiente de produção o mais rápido possível. &lt;/p&gt;

&lt;p&gt;Ex.: CSS que subiu errado para produção. hotfix/ABC-1&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Número da Sprint
&lt;/h3&gt;

&lt;p&gt;Indica o número da Sprint do Work Item &lt;/p&gt;

&lt;p&gt;Ex.: feature/S202004-1/ABC-1&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Identificação do Work Item
&lt;/h3&gt;

&lt;p&gt;Identificação do código do Work Item &lt;/p&gt;

&lt;p&gt;Ex.: feature/S202004-1/ABC-1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv20qui2zc5or9jyd6nck.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv20qui2zc5or9jyd6nck.gif" width="360" height="202"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Padrão de mensagens (commits/merges)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Especificação para commits
&lt;/h3&gt;

&lt;p&gt;Para uma melhor organização e posterior manutenção do sistema, adotaremos a padronização de mensagens de commit com base no &lt;a href="https://www.conventionalcommits.org/en/v1.0.0/" rel="noopener noreferrer"&gt;Conventional Commits&lt;/a&gt; . A estrutura da mensagem de commit deve seguir o seguinte formato:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;tipo&amp;gt; (escopo): &amp;lt;descrição&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;tipo&lt;/strong&gt;: o tipo do commit segue a mesma lógica do tipo da tarefa descrito no tópico acima. Os tipos podem ser então: &lt;strong&gt;feat&lt;/strong&gt;, &lt;strong&gt;fix&lt;/strong&gt; e &lt;strong&gt;hotfix&lt;/strong&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;escopo&lt;/strong&gt;: o escopo indica o local onde foi feita a alteração. No caso da Empresa Fictícia ABC, será a ferramenta alterada. Caso seja mais de uma ferramenta poderão ser indicadas através de "/" e caso a ferramenta afetada possua sub ferramentas deverão ser indicadas através de "&amp;gt;";&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;descrição&lt;/strong&gt;: a descrição deve indicar qual foi a alteração feita no commit. Deve estar no tempo presente e descrever de forma objetiva a alteração feita.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exemplos &lt;/p&gt;

&lt;p&gt;&lt;code&gt;feat(configuracaoInstituicao): adicionado botão que exibe detalhes da instituição&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Especificação para Merges/Pull Requests
&lt;/h3&gt;

&lt;p&gt;Para o preenchimento das mensagens de merge entre duas branches, por exemplo, entre sua feature branch e a branch test ou do título de criação de Pull Requests, é necessário que mensagem siga o padrão estabelecido:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;merge: &amp;lt;nome_branch&amp;gt; em &amp;lt;branch_de_destino&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Exemplos:&lt;br&gt;
 &lt;code&gt;merge: fix/S202002-1/ABC-254 em homolog&lt;/code&gt;&lt;br&gt;
 &lt;code&gt;merge: hotfix/support/ABC-3154 em test&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;![]&lt;a href="https://media.giphy.com/media/kH6CqYiquZawmU1HI6/giphy.gif()" rel="noopener noreferrer"&gt;https://media.giphy.com/media/kH6CqYiquZawmU1HI6/giphy.gif()&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Mãos a obra!
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Configurando suas credenciais no git
&lt;/h2&gt;

&lt;p&gt;Para trabalhar no projeto é necessário configurar o email utilizado no git como o seu email da Empresa fictícia ABC.&lt;br&gt;
&lt;code&gt;git config --global user.email &amp;lt;seu_email_abc_aqui&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Substitua o  pelo seu  email&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2wenbnjpwde2eu1p1qye.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2wenbnjpwde2eu1p1qye.gif" width="640" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Clonando o repositório
&lt;/h2&gt;

&lt;p&gt;Para trabalhar no projeto deverá ser criada uma cópia local do repositório que se encontra no servidor. Para isto deverá ser executado o comando git clone , no nosso caso:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git clone https://git.empresaabc.com.br/apps/app-abc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;OBS: A partir do momento em que o repositório estiver na sua máquina não será mais necessário repetir este processo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Criando uma nova Branch
&lt;/h2&gt;

&lt;p&gt;Criaremos uma nova branch para iniciar uma task, para isso, devemos cria-la acessando o site do seu gerenciador de tasks preferido ou utilizando o próprio github:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Para cada task deverá ser criada uma branch, através do Work Item do Jira/AzureDevops ou outra plataforma de monitoramento de tarefas para que o desenvolvimento seja realizado apenas nesta branch. Crie uma branch atrelada a esse card.&lt;/li&gt;
&lt;li&gt;Preencha o campo name conforme o tópico citado acima e preencha informações relevantes para que o card seja ligado a branch sem falta de informação e de forma muito clara.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Branches fix e feature
&lt;/h3&gt;

&lt;p&gt;Caso a atividade seja independente de outras atividades em andamento, deverão ser criadas a partir da branch develop, seguindo o Fluxo descrito no tópico seguinte. Caso contrário, deverão ser criadas a partir da branch da atividade pai.&lt;/p&gt;

&lt;h3&gt;
  
  
  Branches hotfix
&lt;/h3&gt;

&lt;p&gt;Deverão ser criadas sempre a partir da branch master.&lt;/p&gt;

&lt;h3&gt;
  
  
  Vamos lá!
&lt;/h3&gt;

&lt;p&gt;Lembre-se sempre de clonar o repositório e confirmar se você está realizando o desenvolvimento na branch certa antes de começar a fazer modificações.&lt;/p&gt;

&lt;p&gt;Agora que voce já clonou o repositório na pasta selecionada, vamos verificar se estamos na branch correta com o comando &lt;code&gt;git status&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;Caso não estejamos na branch correta, vamos nos mover para essa branch utilizando os comandos &lt;code&gt;git branch -a&lt;/code&gt; para listar as branches existentes &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdobvulyx615yn47cqfm9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdobvulyx615yn47cqfm9.png" width="654" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;e o comando &lt;code&gt;git fetch&lt;/code&gt; para baixar os objetos e referências que possam ter sido alterados do repositório. &lt;/p&gt;

&lt;p&gt;Por fim utilizaremos o comando &lt;code&gt;git checkout &amp;lt;nome_branch&amp;gt;&lt;/code&gt; para trocar de branch, lembrando que o nome deverá ser trocado pelo nome da branch criada na sua plataforma de gerenciador de atividades.&lt;/p&gt;

&lt;p&gt;Vamos checar mais uma vez em qual branch estamos:&lt;br&gt;
&lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffc9vmwpfeiyto5vhnufw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffc9vmwpfeiyto5vhnufw.png" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Está na branch certa? Se sim! Mãos à obra !&lt;/p&gt;

&lt;p&gt;...&lt;/p&gt;

&lt;p&gt;Depois de codificar, mesmo que seja um pouco ou a task inteira, você deve "comitar" o que fez e enviar ao servidor, seguindo os comandos abaixo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;add&lt;/strong&gt; - adiciona os arquivos ou alterações que você fez no código para prepará-los para o commit. Utilize omando &lt;code&gt;git status&lt;/code&gt; para verificar os arquivos alterados, &lt;code&gt;git add &amp;lt;nome do arquivo&amp;gt;&lt;/code&gt; para adicionar um arquivo específico ou &lt;code&gt;git add .&lt;/code&gt; para adicionar todos os arquivos alterados.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;code&gt;git status&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffc9vmwpfeiyto5vhnufw.png" width="800" height="410"&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqlai34hobghhf4g6nz8.png" width="452" height="408"&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;commit - Após adicionar os arquivos modificados, necessitamos "comitar" os arquivos adicionados anteriormente, seguindo o padrão de mensagens&lt;br&gt;&lt;br&gt;
de commit já descrito:&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;code&gt;git commit -m "&amp;lt;mensagem_commit&amp;gt;"&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl76y55qfkp6d0nbj07vj.png" width="800" height="341"&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;OBS: procure realizar commits em blocos menores para que a descrição seja a mais breve e detalhada o possível.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;push - Pronto, estamos seguros e com todas as modificações adicionadas e "comitadas", agora precisamos enviar nossas modificações ao servidor,  com o comando &lt;code&gt;git push origin &amp;lt;nome_branch&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frvymdtb92dag04vjlfm0.png" width="800" height="400"&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Exemplo&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git push origin feat/S202102-1/ABC-254&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Após a finalização do desenvolvimento deverá ser seguido o respectivo fluxo relacionado a atividade finalizada.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefwxa8fmy80sv2yf6tum.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefwxa8fmy80sv2yf6tum.gif" width="200" height="112"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Fluxo - feature/fix
&lt;/h2&gt;

&lt;p&gt;Após o término do desenvolvimento, sua atividade deverá ser testada, aprovada e disponibilizada em produção. Para tal deverá ser seguido cada passo descrito abaixo:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Para disponibilização da modificação no ambiente de testes, será necessário fazer o merge da sua branch na branch de test (caso exista, se não será feita na develop mesmo).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git checkout test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git pull origin test&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;git merge nome_branch --no-ff&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git push origin test&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;&lt;p&gt;Após feito o merge, será solicitado o preenchimento da mensagem do merge commit, utilizando o editor padrão do Git, que deverá ser preenchida conforme o tópico 2 da seção "&lt;strong&gt;Padrão de mensagens (commits/merges)&lt;/strong&gt;". O editor padrão do Git é o &lt;a href="https://e-tinet.com/linux/editor-texto-vim/" rel="noopener noreferrer"&gt;Vim&lt;/a&gt;, logo caso não seja alterado o seu editor padrão, após o termino do merge será aberta uma janela do Vim, nela será mostrada um texto semelhante à &lt;code&gt;merge: feature/S10/TMX4 into test&lt;/code&gt;, para alterar é necessário apertar o botão &lt;code&gt;i&lt;/code&gt; e então alterar, para sair e salvar é necessário apertar &lt;code&gt;esc&lt;/code&gt; e então &lt;code&gt;:wq&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Após a atividade ter sido testada e o work item ser movimentado para "DONE", será necessário criar um Pull Request (PR) dessa branch para a&lt;br&gt;
branch de homologação. O PR deverá ser criado para algum reviewer validar o código e aceitar o merge na branch de homolog.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ao abrir o PR, o title deverá ser preenchido conforme o tópico 2 da seção &lt;strong&gt;"Padrão de mensagens (commits/merges)&lt;/strong&gt;"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Preencha a descrição do seu PR com algo informativo e claro sobre o que será modificado.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Para finalizar a criação do PR, clique no botão &lt;strong&gt;Create&lt;/strong&gt;. (Ou similar)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Nesse momento, quando o reviewer validar o código, deverá ser sinalizado se a atividade em questão é uma atividade que precisa da validação do cliente. Caso seja necessário que o cliente valide essa alteração, o PR será aceito na branch de develop. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Os PRs abertos para a homolog serão validados por pessoas específicas. Quando houver a necessidade de subir as modificações já validadas para a master, essas mesmas pessoas deverão abrir um PR da homolog para a develop.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;OBS: A cada PR aceito para homolog, a branch feature/fix será deletada.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flrmzqfk5ldw7kmtcefvs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flrmzqfk5ldw7kmtcefvs.gif" width="80" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Parabéns ❗ &lt;/p&gt;

&lt;p&gt;Concluímos os fluxos do Git WorkFlow&lt;/p&gt;

&lt;p&gt;Se você ficou se perguntando &lt;strong&gt;Como vejo os commits contidaos na minha&lt;/strong&gt; &lt;strong&gt;branch?&lt;/strong&gt; é simples, basta utilizar o comando &lt;code&gt;git log&lt;/code&gt;, este comando te mostrará em ordem cronológica descrescente os commits contidos na sua branch atual.&lt;/p&gt;

&lt;p&gt;Para sair da visualização, aperte a tecla q reproduzindo o comando "quit".&lt;/p&gt;

&lt;p&gt;Para acompanhar os commits e alterações de todo projeto, será mais fácil utilizar uma interface gráfica (IDE) ou utilizar o Azure DevOps na seção de Repositórios do projeto (Repos).&lt;/p&gt;

&lt;h2&gt;
  
  
  Comandos para resolução de conflito
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Abortar um processo de merge:
&lt;code&gt;git merge --abort&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Resetar a branch para ficar idêntica ao do servidor e remover suas
modificações:
&lt;code&gt;git reset --hard origin/&amp;lt;nome da branch&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Resetar a branch para ficar idêntica ao do servidor e não remover suas
modificações:
`&lt;code&gt;git reset --soft origin/&amp;lt;nome da branch&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Resetar a branch para o seu último commit e remover suas modificações:
&lt;code&gt;git reset --hard HEAD&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Resetar a branch para o seu último commit e não remover suas
modificações:
&lt;code&gt;git reset --soft HEAD&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resetar a branch para o seu penúltimo commit e remover suas&lt;br&gt;
modificações:&lt;br&gt;
&lt;code&gt;git reset --hard HEAD^&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resetar a branch para o seu N-ésimo commit e remover suas modificações:&lt;br&gt;
&lt;code&gt;git reset --hard HEAD~N&lt;/code&gt; (insira um valor para N, se for 2 por exemplo, ele irá resetar dois commits anteriores ao último)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa5elhw6nz9y9s464xsam.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa5elhw6nz9y9s464xsam.gif" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Considerações
&lt;/h2&gt;

&lt;p&gt;Não hesite em perguntar para o seu colega caso tenha alguma dúvida, depende somente de nós para seguir o padrão e termos um ambiente de&lt;br&gt;
trabalho limpo e organizado!&lt;/p&gt;

</description>
      <category>github</category>
      <category>workflow</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to increase your rendering performance by 70% in Vue.js</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Sat, 20 Feb 2021 03:53:42 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/how-to-increase-your-rendering-performance-by-70-in-vue-js-4dia</link>
      <guid>https://dev.to/matheusgomes062/how-to-increase-your-rendering-performance-by-70-in-vue-js-4dia</guid>
      <description>&lt;p&gt;Hello everyone! 😜&lt;/p&gt;

&lt;p&gt;How you are guys doing? Hope you are fine and well!&lt;/p&gt;

&lt;p&gt;So, today I will teach you about functional components and it's an application in the vue.js framework. And most important, how to increase your rendering performance!&lt;/p&gt;

&lt;p&gt;Let's begin with an explanation on ...&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a functional component? 🤨
&lt;/h2&gt;

&lt;p&gt;A functional component is a component that holds no state (stateless - no reactive data) and no instance (instanceless - no &lt;code&gt;this&lt;/code&gt; context).&lt;/p&gt;

&lt;p&gt;We can mark components as &lt;code&gt;functional&lt;/code&gt; to use them as a functional component. It will look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkjradw4p5gydcnimnrh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkjradw4p5gydcnimnrh.png" width="654" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let's use it in a real case, something like a GitHub card with a profile pic and a tech section, where the person writes a summary about their learning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4n72aloyjn2568o9aci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4n72aloyjn2568o9aci.png" width="800" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How we can turn it into a functional component?&lt;/p&gt;

&lt;p&gt;First we add the &lt;code&gt;functional&lt;/code&gt; mark:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhra6v0mr14bs2oq2im3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvhra6v0mr14bs2oq2im3.png" width="800" height="570"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now comes the tricky part, we would see errors if we run this code, it happens because we do not have the Vue instance, so we cannot use the keyword &lt;code&gt;this&lt;/code&gt; and it's auto bindings. But how we can solve this then? Well, as a functional component we have access to the "context" parameter. In this case, context will give us access to the props key, so we can use it in the code:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7lhld7ofy0uu0d7qjyp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb7lhld7ofy0uu0d7qjyp.png" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations, you just have created your first vue functional component! A step further to optimizing your project!🎉🎉🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Diving deep into the context 😎
&lt;/h2&gt;

&lt;p&gt;The context argument is an object with the following properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;props&lt;/strong&gt;: Object of props&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;children&lt;/strong&gt;: An array of the VNode children&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;slots&lt;/strong&gt;: A function returning a slots object&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;scopedSlots&lt;/strong&gt;: (v2.6.0+) An object that exposes passed-in scoped slots. Also exposes normal slots as functions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;data&lt;/strong&gt;: The entire data object, passed to the component as the 2nd argument of createElement.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;parent&lt;/strong&gt;: A reference to the parent component&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;listeners&lt;/strong&gt;: (v2.3.0+) An object containing parent-registered event listeners. This is an alias to data.on&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;injections&lt;/strong&gt;: (v2.3.0+) if using the inject option, this will contain resolved injections.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Another example 🦖
&lt;/h2&gt;

&lt;p&gt;Now that we know the fundamentals, let's put them into practice!&lt;/p&gt;

&lt;p&gt;I'm going to show you how we can use the click event with a functional component:&lt;/p&gt;

&lt;p&gt;Ou parent component is calling our component like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbr4sacohbhqs6kj0jw3i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbr4sacohbhqs6kj0jw3i.png" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use this click event at the functional component we need to make some changes:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4tx4rg2mo035js6cq13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4tx4rg2mo035js6cq13.png" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We added the &lt;code&gt;@click="listeners.click"&lt;/code&gt; so the functional component could "listen" to the parent "click", as we don't have the &lt;code&gt;this&lt;/code&gt; keyword.&lt;/p&gt;

&lt;p&gt;A better way to do this is to use &lt;code&gt;v-on="listeners"&lt;/code&gt;, because click events (and keypress) are integrated in such a way that we don't need to bind them manually. But if a component has a custom caller, we need to bind them manually and explicitly, like &lt;code&gt;@click.stop="listeners.contact"&lt;/code&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  70% more performance 🏎
&lt;/h2&gt;

&lt;p&gt;Why? Why this works so much better than the normal components? And why hassle to work with something so strict?&lt;/p&gt;

&lt;p&gt;Well, the answer is basically...&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Speed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because functional components do not have a state, they do not require extra initialization for things like Vue’s reactivity system.&lt;/p&gt;

&lt;p&gt;Functional components will still react to changes like new props being passed in, but within the component itself, there is no way for it to know when its data has changed because it does not maintain its own state.&lt;/p&gt;

&lt;p&gt;I have seen benchmarks pointing to something between 40% and 70% increase in performance using functional components.&lt;/p&gt;

&lt;p&gt;We can see a benchmark test here: &lt;a href="https://codesandbox.io/s/vue-template-yterr?fontsize=14" rel="noopener noreferrer"&gt;https://codesandbox.io/s/vue-template-yterr?fontsize=14&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  When to use it? 🥸
&lt;/h2&gt;

&lt;p&gt;Well, let's put it in this way:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When you are using v-for, maybe the items inside the loop are a great fit to be a functional component.&lt;/li&gt;
&lt;li&gt;A component which is simply presentational is also a great candidate to be a functional component because it doesn't need a state.&lt;/li&gt;
&lt;li&gt;A “higher-order component” is used to wrap markup or basic functionality around another component.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  ENDING 🥳
&lt;/h1&gt;

&lt;p&gt;Well, that's it for today, I think that functional components are something to be used on a great scale. I, myself will be using it right now!&lt;/p&gt;

&lt;p&gt;Thank you for reading and have a great day!&lt;/p&gt;

&lt;h1&gt;
  
  
  EDIT
&lt;/h1&gt;

&lt;p&gt;Performance gains from 2.x for functional components are now negligible in 3.x, so it's recommend just using stateful components...&lt;/p&gt;

&lt;p&gt;v3.vuejs.org/guide/migration/funct...&lt;/p&gt;

&lt;p&gt;Links and articles:&lt;br&gt;
&lt;a href="https://www.digitalocean.com/community/tutorials/vuejs-functional-components" rel="noopener noreferrer"&gt;https://www.digitalocean.com/community/tutorials/vuejs-functional-components&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.twilio.com/blog/react-choose-functional-components" rel="noopener noreferrer"&gt;https://www.twilio.com/blog/react-choose-functional-components&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.freecodecamp.org/news/functional-components-vs-class-components-in-react/#:%7E:text=Functional%20components%20are%20basic%20JavaScript,mainly%20responsible%20for%20rendering%20UI" rel="noopener noreferrer"&gt;https://www.freecodecamp.org/news/functional-components-vs-class-components-in-react/#:~:text=Functional%20components%20are%20basic%20JavaScript,mainly%20responsible%20for%20rendering%20UI&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://medium.com/js-dojo/vue-js-functional-components-what-why-and-when-439cfaa08713" rel="noopener noreferrer"&gt;https://medium.com/js-dojo/vue-js-functional-components-what-why-and-when-439cfaa08713&lt;/a&gt;&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>vue</category>
      <category>performance</category>
      <category>functional</category>
    </item>
    <item>
      <title>Food review, refactoring a long method</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Thu, 14 Jan 2021 20:04:33 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/food-review-refactoring-a-long-method-4in5</link>
      <guid>https://dev.to/matheusgomes062/food-review-refactoring-a-long-method-4in5</guid>
      <description>&lt;h1&gt;
  
  
  Refactoring
&lt;/h1&gt;

&lt;p&gt;Let`s think about code as food when we prepare our food we make it delicious at the beginning, we make it shine and we are proud of it, but, when we receive guests, we try to use different ingredients so everyone can enjoy it. So we add some spice here and there, some oil and other things. We finish the preparation and serve the food, when our guests are eating they realize something is not right, what started as a lasagna ended up being spaghetti and isn't smelling good, actually, is smelling pretty bad. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4p1bmvz4gauh2wu43igw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4p1bmvz4gauh2wu43igw.gif" width="570" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comparing to our code, we call that a &lt;strong&gt;code smell&lt;/strong&gt;, it's when we have &lt;strong&gt;bloaters&lt;/strong&gt;, which are code, methods, and classes that increased to such gargantuan proportions that they are hard to work with. &lt;/p&gt;

&lt;p&gt;Usually, these smells do not crop up right away, rather they accumulate over time as the program evolves (and especially when nobody makes an effort to eradicate them). We solve this problem by refactoring the code, or, in food terms, removing some ingredients of the dish. This refactoring makes the code run faster and more efficiently, making it easier to adapt and add features.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcjxjk0kw3vxsqvkgz5mm.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcjxjk0kw3vxsqvkgz5mm.gif" width="500" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, let`s see some methods to refactor. Starting up with the problem of a...&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Long Method&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A long method is when a method contains too many lines of code. A good method usually contains less than 10 lines (in most cases).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;How to solve?&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Solution #1 - Extract method
&lt;/h3&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;You have a code fragment that can be grouped together&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;PrintOwing&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PrintBanner&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Print details.&lt;/span&gt;
  &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name: "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"amount: "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetOutstanding&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Move this code to a separate new method (or function) and replace the old code with a call to the method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;PrintOwing&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PrintBanner&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;PrintDetails&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name: "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"amount: "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetOutstanding&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This makes the code more readable and makes a method specific to one action, being possible to re-utilize it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution #2 - Reduce Local Variables and Parameters Before Extracting a Method
&lt;/h3&gt;

&lt;p&gt;If local variables and parameters interfere with extracting a method, use &lt;strong&gt;Replace Temp with Query&lt;/strong&gt;, &lt;strong&gt;Introduce Parameter Object&lt;/strong&gt;, or &lt;strong&gt;Preserve Whole Object&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Replace Temp with Query
&lt;/h3&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;You place the result of an expression in a local variable for later use in your code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;CalculateTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;itemPrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.95&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;basePrice&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.98&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Move the entire expression to a separate method and return the result from it. Query the method instead of using a variable. Incorporate the new method in other methods, if necessary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;CalculateTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;BasePrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;BasePrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.95&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;BasePrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.98&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;BasePrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;itemPrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost the same principle as before, it sure makes the code looks clean and more readable despite adding more lines to it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Introduce Parameter Object
&lt;/h3&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;Your methods contain a repeating group of parameters.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSomething&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;firstValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;secondValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;thirdValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSomethingMore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;firstValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;secondValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;thirdValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateAnything&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;firstValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;secondValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;thirdValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Replace these parameters with an object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSomething&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;valuesObj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateSomethingMore&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;valuesObj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;CalculateAnything&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;valuesObj&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way we don't need to understand what it does in the call, we leave this description to the method!&lt;/p&gt;

&lt;h3&gt;
  
  
  Preserve Whole Object
&lt;/h3&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;You get several values from an object and then pass them as parameters to a method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;low&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;daysTempRange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetLow&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;daysTempRange&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetHigh&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;withinPlan&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WithinRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;low&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;high&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Instead, try passing the whole object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;withinPlan&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;plan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WithinRange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;daysTempRange&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same as before, we need to leave the description and handling to the method inside, not the caller.&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution #3 - Replace Method with Method Object
&lt;/h3&gt;

&lt;p&gt;If none of the previous recipes help, try moving the entire method to a separate object via &lt;strong&gt;Replace Method with Method Object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;You have a long method in which the local variables are so intertwined that you can't apply &lt;em&gt;Extract Method&lt;/em&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;primaryBasePrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;secondaryBasePrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;tertiaryBasePrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Perform long computation.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Transform the method into a separate class so that the local variables become fields of the class. Then you can split the method into several methods within the same class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;Price&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;PriceCalculator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;Compute&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PriceCalculator&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;primaryBasePrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;secondaryBasePrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;tertiaryBasePrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;PriceCalculator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Order&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Copy relevant information from the&lt;/span&gt;
    &lt;span class="c1"&gt;// order object.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;Compute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Perform long computation.&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Solution #4 - Conditionals and Loops
&lt;/h3&gt;

&lt;p&gt;Conditional operators and loops are a good clue that code can be moved to a separate method. For conditionals, use &lt;strong&gt;Decompose Conditional&lt;/strong&gt;. If loops are in the way, try &lt;strong&gt;Extract Method&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Decompose Conditional
&lt;/h3&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;You have a complex conditional (&lt;code&gt;if-then&lt;/code&gt;/&lt;code&gt;else&lt;/code&gt; or &lt;code&gt;switch&lt;/code&gt;).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;SUMMER_START&lt;/span&gt; &lt;span class="p"&gt;||&lt;/span&gt; &lt;span class="n"&gt;date&lt;/span&gt; &lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;SUMMER_END&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;winterRate&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;winterServiceCharge&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;summerRate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Decompose the complicated parts of the conditional into separate methods: the condition, &lt;code&gt;then&lt;/code&gt; and &lt;code&gt;else&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;isSummer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;SummerCharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;charge&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;WinterCharge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract Method
&lt;/h3&gt;

&lt;p&gt;Conditional operators and loops are a good clue that code can be moved to a separate method. For conditionals, use &lt;strong&gt;Decompose Conditional&lt;/strong&gt;. If loops are in the way, try &lt;strong&gt;Extract Method&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;❌Problem&lt;/p&gt;

&lt;p&gt;You have a code fragment that can be grouped together.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printProperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IList&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;size&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;getAge&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✔Solution&lt;/p&gt;

&lt;p&gt;Move this code to a separate new method (or function) and replace the old code with a call to the method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;printProperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IList&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;getProperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

    &lt;span class="c1"&gt;// ...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="nf"&gt;getProperties&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;User&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" "&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAge&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So remember, make your food as Gordon is watching you, same with code, imagine Uncle Bob is watching you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsedvc5taepewphgnamw6.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsedvc5taepewphgnamw6.gif" width="500" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That`s it, folks, I guess this is some solutions to solve problems with long methods. This article was made after I started a course about refactoring in the &lt;a href="https://refactoring.guru/" rel="noopener noreferrer"&gt;refactoring.guru&lt;/a&gt; which is a great course, so go check it out to learn more!&lt;/p&gt;

</description>
      <category>refactorit</category>
      <category>food</category>
      <category>csharp</category>
      <category>programming</category>
    </item>
    <item>
      <title>Monolithic Architecture? Good or bad?</title>
      <dc:creator>Matheus Gomes 👨‍💻</dc:creator>
      <pubDate>Thu, 10 Sep 2020 00:03:42 +0000</pubDate>
      <link>https://dev.to/matheusgomes062/monolithic-architecture-good-or-bad-1k58</link>
      <guid>https://dev.to/matheusgomes062/monolithic-architecture-good-or-bad-1k58</guid>
      <description>&lt;p&gt;If you are in the developer world you must have heard something about the monolithic project, or even monolithic architecture, if you never heard of it, maybe it's time to join us and know why we should know this architecture type and what implications it has on our project.&lt;/p&gt;

&lt;p&gt;Also, this post was heavily inspired by these contents:&lt;br&gt;
&lt;a href="https://www.youtube.com/watch?v=IwT_pBcDmSI" rel="noopener noreferrer"&gt;video&lt;/a&gt;&lt;br&gt;
&lt;a href="https://microservices.io/patterns/monolithic.html" rel="noopener noreferrer"&gt;article&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's start with the problem...&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Develop a server-side enterprise application.&lt;/li&gt;
&lt;li&gt;It must support a variety of different clients including desktop browsers, mobile browsers, and native mobile applications.&lt;/li&gt;
&lt;li&gt;It might also integrate with other applications via either web services or a message broker like payment gateways and notification services&lt;/li&gt;
&lt;li&gt;The application handles requests (HTTP requests and messages) by executing business logic, accessing a database, exchanging messages with other systems, and returning a JSON response.&lt;/li&gt;
&lt;li&gt;The application handles requests (HTTP requests and messages) by executing business logic, accessing a database, exchanging messages with other systems, and returning a JSON response.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgestaocont.com.br%2Fsite%2Fuploads%2F2020%2F06%2Fecommerce-seo-tips.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgestaocont.com.br%2Fsite%2Fuploads%2F2020%2F06%2Fecommerce-seo-tips.jpg" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem
&lt;/h2&gt;

&lt;p&gt;What’s the application’s deployment architecture?&lt;/p&gt;

&lt;h2&gt;
  
  
  Forces
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;There is a team of developers working on the application&lt;/li&gt;
&lt;li&gt;New team members must quickly become productive&lt;/li&gt;
&lt;li&gt;The application must be easy to understand and modify&lt;/li&gt;
&lt;li&gt;You want to practice continuous deployment of the application&lt;/li&gt;
&lt;li&gt;You must run multiple instances of the application on multiple machines in order to satisfy scalability and availability requirements&lt;/li&gt;
&lt;li&gt;You want to take advantage of emerging technologies (frameworks, programming languages, etc)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Build an application with a monolithic architecture. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a single Java WAR file.&lt;/li&gt;
&lt;li&gt;a single directory hierarchy of Rails or NodeJS code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Traditional Server-Side App
&lt;/h2&gt;

&lt;p&gt;In a traditional server-side app, we have a basic Server-Side app, as it shows below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Felmprogramming.com%2Fimages%2Fchapter-7%2F7.2-what-is-a-single-page-app%2Fserver-side-rendering.svg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Felmprogramming.com%2Fimages%2Fchapter-7%2F7.2-what-is-a-single-page-app%2Fserver-side-rendering.svg" width="1306" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here we have the following, a Client-Side, where the user makes the inputs and requests. These requests are then sent to the said Server Side, where they are treated accordingly.&lt;/p&gt;

&lt;p&gt;After the presentation layer (front-end), we make a request to the back-end side, where the logic is present (business), and where we can send the request made by the back-end to the data layer, where then they catch the requested data from the database.&lt;/p&gt;

&lt;p&gt;This is a monolith, this is because the logic is all contained in a single file, in a way that it only accesses the single database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Taxi booking Server-Side App
&lt;/h2&gt;

&lt;p&gt;Some places might reference this as the "Uber architecture", which is not, but is very similar. This will be your first version of your application, where we have the internal modules and the external modules.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffetpyc3txq17djogxhnz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffetpyc3txq17djogxhnz.png" width="741" height="781"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The internal are those like billing and notifications or payments when those services need to connect to the outside world we reach the outside modules. We reach than by the adapters, or converters, which convert the data from the outside world and send it to the user.&lt;/p&gt;

&lt;p&gt;This is considered a monolith because all of your business logic resides within a single application and you only have a single database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs2.glbimg.com%2Fb2YW3rWsCUOzCcx4FVjiiV4maW4%3D%2F0x0%3A1920x1080%2F984x0%2Fsmart%2Ffilters%3Astrip_icc%28%29%2Fi.s3.glbimg.com%2Fv1%2FAUTH_08fbf48bc0524877943fe86e43087e7a%2Finternal_photos%2Fbs%2F2020%2FM%2Fn%2F0VMYGXSruTpHzpxswNFA%2Fxbox.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fs2.glbimg.com%2Fb2YW3rWsCUOzCcx4FVjiiV4maW4%3D%2F0x0%3A1920x1080%2F984x0%2Fsmart%2Ffilters%3Astrip_icc%28%29%2Fi.s3.glbimg.com%2Fv1%2FAUTH_08fbf48bc0524877943fe86e43087e7a%2Finternal_photos%2Fbs%2F2020%2FM%2Fn%2F0VMYGXSruTpHzpxswNFA%2Fxbox.jpg" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Result Context
&lt;/h2&gt;

&lt;p&gt;This solution has a number of benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simple to develop - the goal of current development tools and IDEs is to support the development of monolithic applications&lt;/li&gt;
&lt;li&gt;Simple to deploy - you simply need to deploy the WAR file (or directory hierarchy) on the appropriate runtime&lt;/li&gt;
&lt;li&gt;Simple to scale - you can scale the application by running multiple copies of the application behind a load balancer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, it has some disadvantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As the monolithic grows, the complexity also grows, and as result, it becomes impossible to sustain. It intimidates developers who are new and can be difficult to modify, as result the development slows down. Also, because there are not hard module boundaries, modularity breaks down over time. &lt;/li&gt;
&lt;li&gt;Overloaded IDE and Start - the larger the codebase the slower the IDE and the less productive developers are. Think about 5 minutes or even 20 minutes to load a file and a few minutes to search for a file.&lt;/li&gt;
&lt;li&gt;Continuous deployment is difficult - a large monolithic application is also an obstacle to frequent deployments. In order to update one component, you have to redeploy the entire application. This will interrupt background tasks (e.g. Quartz jobs in a Java application), regardless of whether they are impacted by the change, and possibly cause problems. There is also the chance that components that haven’t been updated will fail to start correctly. As a result, the risk associated with redeployment increases, which discourages frequent updates. This is especially a problem for user interface developers since they usually need to iterative rapidly and redeploy frequently.&lt;/li&gt;
&lt;li&gt;Scaling the application can be difficult - a monolithic architecture is that it can only scale in one dimension. On the one hand, it can scale with an increased transaction volume by running more copies of the application. Some clouds can even adjust the number of instances dynamically based on load. But on the other hand, this architecture can’t scale with an increasing data volume. Each copy of the application instance will access all of the data, which makes caching less effective and increases memory consumption and I/O traffic. Also, different application components have different resource requirements - one might be CPU intensive while another might memory intensive. With a monolithic architecture we cannot scale each component independently&lt;/li&gt;
&lt;li&gt;The obstacle to scaling development - A monolithic application is also an obstacle to scaling development. Once the application gets to a certain size it's useful to divide up the engineering organization into teams that focus on specific functional areas. For example, we might want to have the UI team, accounting team, inventory team, etc. The trouble with a monolithic application is that it prevents the teams from working independently. The teams must coordinate their development efforts and redeployments. It is much more difficult for a team to make a change and update production.&lt;/li&gt;
&lt;li&gt;Requires a long-term commitment to a technology stack - a monolithic architecture forces you to be married to the technology stack (and in some cases, to a particular version of that technology) you chose at the start of development. With a monolithic application, can be difficult to incrementally adopt newer technology. For example, let’s imagine that you chose the JVM. You have some language choices since as well as Java you can use other JVM languages that inter-operate nicely with Java such as Groovy and Scala. But components written in non-JVM languages do not have a place within your monolithic architecture. Also, if your application uses a platform framework that subsequently becomes obsolete then it can be challenging to incrementally migrate the application to a newer and better framework. It’s possible that in order to adopt a newer platform framework you have to rewrite the entire application, which is a risky undertaking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Finally
&lt;/h2&gt;

&lt;p&gt;A monolith is something you want to avoid. It's like a black void, where every code goes to never be found. It's a project where a very few developers understand, it's written using obsolete and unproductive technology that makes hiring talented developers a difficult task because no one wants to work on a monolith. Also, the application is difficult to scale up and your costumers are always reporting bugs that if someone doesn't fix it upright and fast it breaks all the applications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F64.media.tumblr.com%2Ftumblr_ls18yqbO1W1qg6rkio1_500.gifv" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2F64.media.tumblr.com%2Ftumblr_ls18yqbO1W1qg6rkio1_500.gifv" width="500" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>todayisearched</category>
      <category>architecture</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
