<?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: Kevin Hicks</title>
    <description>The latest articles on DEV Community by Kevin Hicks (@kevinhickssw).</description>
    <link>https://dev.to/kevinhickssw</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%2F465329%2F443e1d8f-3150-43ff-9e83-d8fcfae1dd8b.jpeg</url>
      <title>DEV Community: Kevin Hicks</title>
      <link>https://dev.to/kevinhickssw</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kevinhickssw"/>
    <language>en</language>
    <item>
      <title>How To Use Your Manager’s Help To Get Promoted as a Software Engineer</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Sun, 09 Oct 2022 17:36:35 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/how-to-use-your-managers-help-to-get-promoted-as-a-software-engineer-101n</link>
      <guid>https://dev.to/kevinhickssw/how-to-use-your-managers-help-to-get-promoted-as-a-software-engineer-101n</guid>
      <description>&lt;p&gt;Many software developers I chat with don’t take advantage of the assistance their manager can provide to help them advance in their career.&lt;/p&gt;

&lt;p&gt;Being promoted as a software engineer can be a challenge. Even if you are the most talented developer and hardest worker on your team, there are no guarantees that you will be promoted. A big blocker to being promoted is not letting your manager know you want to be promoted and getting their advice and feedback.&lt;/p&gt;

&lt;p&gt;Moving up the software engineer’s career ladder isn’t only about your coding abilities.&lt;/p&gt;

&lt;p&gt;Other talents, such as mentoring, teaching, planning, and explaining technical concepts to nontechnical individuals, come into play. Or you may need to complete some projects or duties that aren’t part of your regular responsibilities. Unfortunately, reading books, asking for advice online, and other general advice might not help you get promoted where you work, as every company has different requirements.&lt;/p&gt;

&lt;p&gt;Working closely with your manager is one of the best ways to learn what you need to do to advance to the next level.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first step is to talk with your manager about your career goals.
&lt;/h2&gt;

&lt;p&gt;Be upfront and honest about what you want and where you see yourself in the next few years. Being open with your manager will give them a better sense of where you want to go and how they can help you get there.&lt;/p&gt;

&lt;p&gt;Your manager may be able to give you specific assignments that will help you develop the skills you still need.&lt;/p&gt;

&lt;p&gt;For example, if a requirement for promotion to senior software engineer is you need to be able to lead teams but lack experience leading a team, your manager may assign you to lead a small project. This will allow you to prove that you have the skills to take on a leadership role.&lt;/p&gt;

&lt;p&gt;Additionally, your manager may be able to help make sure you are aiming for the correct position for you.&lt;/p&gt;

&lt;p&gt;I always thought I would want to be a manager, which would be the best way for me to move up. Talking with my manager about my career goals, he was able to help me realize that I may not like being a manager. He knew how much I liked to code and that I may not like the day-to-day life of a manager.&lt;/p&gt;

&lt;p&gt;Now settled into a software architect role and seeing more of what managers do every day, I know he was 100% right. I would have regretted being a manager.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ask for feedback and then act on it.
&lt;/h2&gt;

&lt;p&gt;Feedback can be difficult to hear, but it is essential if you want to grow and develop in your career. It is not enough to ask for feedback from your manager; you also need to take that feedback and use it to improve your performance. Remember, your manager wants you to succeed and will only give constructive criticism to help you reach your potential.&lt;/p&gt;

&lt;p&gt;If you are doing a good job, your manager may not give you anything but positive feedback if you don’t ask for more.&lt;/p&gt;

&lt;p&gt;Many managers are always keeping team morale in mind. They don’t want to upset a good developer with constructive feedback (which is sometimes taken negatively) if the developer is doing a good enough job for their current role. The feedback they are willing to give will change if you ask for it.&lt;/p&gt;

&lt;p&gt;I made asking for feedback a normal part of my check-ins with my manager for my entire career.&lt;/p&gt;

&lt;p&gt;During my bi-weekly check-ins, I would ask what I could do better and what I needed to do or improve to get to the next rung of the career ladder. Over the years, my feedback changed based on my experience, skills, and the next position I was shooting for. Whether it be to do more of something I already did, to improve a skill, or start doing new tasks he always had something specific to help me go to the next level.&lt;/p&gt;

&lt;p&gt;I don’t believe I would be where I am if I didn’t regularly ask for this feedback.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start and share a brag sheet with your manager.
&lt;/h2&gt;

&lt;p&gt;A brag sheet is simply a document that lists out all of your accomplishments. Julia Evans has an excellent article about them you should read to learn how to write one. You aren’t going to remember your accomplishments as time goes on. Even worse some of your accomplishments might go unnoticed by your manager. Your manager is also unlikely to remember your accomplishments come review time with everything else on their plate and an entire team to evaluate.&lt;/p&gt;

&lt;p&gt;A brag sheet is a way to keep track of everything you have done, so when it comes time for performance reviews you have a reference to why you should be promoted.&lt;/p&gt;

&lt;p&gt;The brag sheet should include both your small and big accomplishments. It can include the times you helped a peer overcome a problematic bug, the extensive rewrite you led over the finish line, or the small lunch and learn you did to teach your team a new concept. You don’t want to leave small, or team accomplishments out as those may be the crucial things for you to get promoted.&lt;/p&gt;

&lt;p&gt;Your manager can also use brag sheets to help them push for you to be promoted.&lt;/p&gt;

&lt;p&gt;At many companies, a manager can’t move you to a new position without approval from other managers or their manager. Committees approving promotions become more common as most developers become more senior. A brag sheet is one way your manager can make a case for you to get promoted to these committees.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It is never too late to start a brag sheet and you should maintain it throughout your entire career.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I started mine after over a decade in the field, and it was difficult to remember even the biggest accomplishments that happened just a few years ago.&lt;/p&gt;

&lt;h2&gt;
  
  
  It may not be easy to talk to your manager about your career goals and ask them for feedback.
&lt;/h2&gt;

&lt;p&gt;Many people may feel it may come off as asking for a promotion. Your manager will appreciate the initiative. Many managers are always looking to help their employees reach their career goals and are happy to hear employees want to move up in their current company.&lt;/p&gt;

&lt;p&gt;Taking the steps to get your manager’s help will only help you move up quicker.&lt;/p&gt;

</description>
      <category>career</category>
      <category>management</category>
      <category>beginners</category>
    </item>
    <item>
      <title>4 Reasons Why You Need Code Reviews</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Fri, 24 Dec 2021 14:46:45 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/4-reasons-why-you-need-code-reviews-24ci</link>
      <guid>https://dev.to/kevinhickssw/4-reasons-why-you-need-code-reviews-24ci</guid>
      <description>&lt;p&gt;&lt;em&gt;Our code works after a middle-of-the-night hotfix…do you still need reviews?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you are newer to programming or work for companies that don’t do reviews, you may be wondering why code reviews are so critical.&lt;/p&gt;

&lt;p&gt;This question is more likely if you already have automated testing or a QA (Quality Assurance) team. Code reviews are necessary as they offer multiple benefits that help improve your code and your team. These benefits include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helping reduce bugs and logic errors&lt;/li&gt;
&lt;li&gt;Providing an opportunity for training&lt;/li&gt;
&lt;li&gt;Spreading knowledge across areas and teams&lt;/li&gt;
&lt;li&gt;Revealing new ideas and techniques&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s take a closer look at each of these.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code reviews help reduce bugs and logic errors.
&lt;/h2&gt;

&lt;p&gt;One of the main things a reviewer should be looking for when reviewing code is that the code does the right thing without any errors.&lt;/p&gt;

&lt;p&gt;I can’t tell you how many times a reviewer saved me the headache of debugging an issue by pointing out bugs they found during a review. I was very thankful to them.&lt;/p&gt;

&lt;p&gt;It may seem like it would be hard to find bugs while reading code, but as developers become more experienced reviewing code, issues will start to stand out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Even with QA and automated testing, finding bugs during a code review is helpful.&lt;/strong&gt;&lt;br&gt;
Take a second to think about a project with automated testing but no code reviews. How do you know a test is correct if you do not review the code? It is all too easy to make the same mistakes in automated tests as actual code.&lt;/p&gt;

&lt;p&gt;Reviews help verify the code and tests are both correct.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A code review can direct the developer to the exact area of the problem, making it easier to debug and fix.&lt;/strong&gt;&lt;br&gt;
Would you rather have to work through a vague bug report to reproduce a bug or a reviewer point you to the exact line of code that is an issue? It is harder to debug off of a bug report. When we get a bug report, a user is already affected by the problem. I don’t know any developers who like fixing urgent user bugs.&lt;/p&gt;

&lt;p&gt;Reviews are just one more step we can use to help avoid stressful after hour bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reviews offer opportunities for training.
&lt;/h2&gt;

&lt;p&gt;We all know how quickly the technology around us changes. It isn’t that much of a stretch to say that there is a new language, tool, or framework every day. We also learn new best practices, standards, and ways to do things as we gain more experience.&lt;/p&gt;

&lt;p&gt;There is always something new to learn.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do you keep all the developers on your team up to date with these changes?&lt;/strong&gt;&lt;br&gt;
Of course, there are courses, tutorials, blogs, your team wikis, and guides out there. Developers should continue to use these resources and learn from them. But do you have time for every developer on your team to always go through a course?&lt;/p&gt;

&lt;p&gt;Are they going to remember everything from them?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I can honestly say the most I have ever learned about writing good code has come from code reviews.&lt;/strong&gt;&lt;br&gt;
I have taken many great courses, got a computer science degree, and stayed up to date with many blogs and resources. However, none of these resources have come close to what I learned by working with my team and having my code reviewed.&lt;/p&gt;

&lt;p&gt;I have to credit my team’s reviews for any high-quality code I write today.&lt;/p&gt;

&lt;p&gt;I honestly learned more in a few months from code reviews than I did through years of courses. There are a lot of fantastic resources that do a great job of teaching software development. But they have to cater to a massive audience and can’t cater their lessons to your project, code, and your skills.&lt;/p&gt;

&lt;p&gt;Code reviews are excellent at addressing these flaws.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code reviews will focus on your team’s code and workflows while naturally raising areas you need to improve.&lt;/strong&gt;&lt;br&gt;
You will get feedback on your code for specific things you may need to practice or research more. When I notice the same comments coming up in reviews, I’ll read more about the topic or work with one of my peers that I know are experts on that topic. Other times the comments are enough to learn what I need to without additional resources.&lt;/p&gt;

&lt;p&gt;Learning from code reviews is a natural result of effective review comments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In addition to learning from comments on your code, just reading another developer’s code is a great way to learn.&lt;/strong&gt;&lt;br&gt;
Reviewing another developer’s code will show you new ways of approaching problems, how different developers architect and design features, and expose you to various packages, tools, and technologies.&lt;/p&gt;

&lt;p&gt;Seeing how other developers code is one of my favorite things about performing code reviews. I’m often inspired to go back and use things I see developers doing in reviews in my code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code reviews spread knowledge across areas and teams.
&lt;/h2&gt;

&lt;p&gt;If you had two teams of developers who always worked together and reviewed each other’s code versus two groups of developers who never reviewed the other team’s code, who do you think will have better code in the long run?&lt;/p&gt;

&lt;p&gt;It probably will be the teams that review each other’s code. Those two teams will be passing knowledge back and forth about their specific areas and the best way to do things. They will be learning from different experiences and projects.&lt;/p&gt;

&lt;p&gt;It’s essential someone familiar with the project still reviews the code, but getting someone from outside the team as a reviewer only helps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-team reviews are a great way to expose all team members to these different areas and spread specific learnings across all teams.&lt;/strong&gt;&lt;br&gt;
Depending on the size of your company, you may have many different teams and applications. Or maybe you have a complex application with a team that not everyone gets a chance to work in every application area. Developers across different projects don’t always get to work together.&lt;/p&gt;

&lt;p&gt;If someone on team A introduces a better way to do things or experiments with a different design pattern, team B usually doesn’t get this knowledge.&lt;/p&gt;

&lt;p&gt;Even if team A announces their new way of doing things, team B may not adopt it or realize its value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When team B can review the code, they can see exactly how it works and the value it can bring.&lt;/strong&gt;&lt;br&gt;
Or maybe they would get other ideas and be inspired to try something else or help improve team A’s design. Plus, no one from Team A has to realize this should be shared or remember to make an announcement.&lt;/p&gt;

&lt;p&gt;Team B will naturally see it during its code review.&lt;/p&gt;

&lt;p&gt;Code reviews are one of the only ways to share knowledge naturally across multiple teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code reviews also reveal new ideas and techniques.
&lt;/h2&gt;

&lt;p&gt;Reviews will teach the same team new things the same way they will teach multiple teams. But new ideas and techniques often come up in code reviews even among the same team members.&lt;/p&gt;

&lt;p&gt;Think about most of the code you write. How often do you research different design patterns, consider different architectures or attempt multiple solutions before deploying code? If you are anything like me and many of the developers I work with, I’m guessing this isn’t that often.&lt;/p&gt;

&lt;p&gt;We do an excellent job of going through these steps for more complex features and new projects but don’t often feel the need to do this for our standard everyday features.&lt;/p&gt;

&lt;p&gt;At most places, we don’t have the time to pair program on everything or always meet about how to code every feature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You can get some of these same benefits from code reviews.&lt;/strong&gt;&lt;br&gt;
The reviewer may suggest an improved design or ask a question that leads to a better plan. They make these suggestions without taking the time to pair program or schedule a meeting. Once a team implements a review process, these suggestions happen without extra steps.&lt;/p&gt;

&lt;p&gt;Code reviews make some of the benefits of pair programming, and design meetings naturally occur for every piece of code without special steps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Putting up small and focused PRs help get this feedback quicker.&lt;/strong&gt;&lt;br&gt;
You can ensure everyone can move quickly by getting feedback in small iterations. Small and quick reviews let the author know they are on the right path early and often. When reviews are practical and efficient, developers can often avoid massive rewrites.&lt;/p&gt;

&lt;p&gt;Think like running your code reviews like your agile sprints.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you care about code quality, you need code reviews.
&lt;/h2&gt;

&lt;p&gt;It doesn’t matter what processes you already have in place. QA, automated testing, or acceptance testing is not a replacement for another developer reviewing your code. Code reviews are not a replacement for the other processes either.&lt;/p&gt;

&lt;p&gt;For high-quality, bug-free code, we need all these processes.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If you liked this and would like to see other tips, advice, and articles from me, you can find me on most social media under &lt;a class="mentioned-user" href="https://dev.to/kevinhickssw"&gt;@kevinhickssw&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>codereview</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Why You Need a Coding Scratch File</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Mon, 13 Dec 2021 01:16:22 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/why-you-need-a-coding-scratch-file-h06</link>
      <guid>https://dev.to/kevinhickssw/why-you-need-a-coding-scratch-file-h06</guid>
      <description>&lt;p&gt;Sometimes the best place to write code for your project is outside it.&lt;/p&gt;

&lt;p&gt;This may sound like a lie. How could writing code outside of a project be the best place for the project's code? How can it even help the project at all?&lt;/p&gt;

&lt;p&gt;Working within a project, especially a large and complex one, other code can get in the way of what you are writing.&lt;/p&gt;

&lt;h2&gt;
  
  
  By removing the distraction of unrelated code, you can focus on your task.
&lt;/h2&gt;

&lt;p&gt;When experimenting with designs or figuring out a tricky issue, it's quicker and easier to focus on the smallest amount of code needed. You don't have to worry about passing arguments around, multiple software layers, and other complexities. You also won't need as many manual steps or automated tests to test your code.&lt;/p&gt;

&lt;p&gt;Sometimes you will need the rest of the project code, but removing it can be a huge productivity boost when you don't.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does a scratch file help?
&lt;/h2&gt;

&lt;p&gt;A scratch file allows you to write code that can be compiled, ran and debugged without the rest of your project or setting up a new one. You can copy the code to your project and delete the file when you finish. Scratch files also help avoid accidentally committing temporary code.&lt;/p&gt;

&lt;p&gt;It's like a sticky note for the code you throw out when done with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create your first scratch file.
&lt;/h2&gt;

&lt;p&gt;Scratch files can usually be created inside your IDE. The process is different between IDEs, so search for "your IDE name + scratch file" to get started. It's also helpful to read everything your IDE can do with scratch files when you look this up.&lt;/p&gt;

&lt;p&gt;Once you create the file, start writing code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are also options outside of IDEs for scratch files.&lt;/strong&gt;&lt;br&gt;
You could use a fiddle site (like &lt;a href="https://jsfiddle.net/"&gt;jsfiddle&lt;/a&gt;) for your language. Some languages and frameworks have tools for this, such as &lt;a href="https://laravel.com/docs/8.x/artisan"&gt;artisan tinker&lt;/a&gt; for Laravel and &lt;a href="https://www.linqpad.net/"&gt;LinqPad&lt;/a&gt; for C#. A default project for your language or framework could also serve as a scratch file if you need to work across multiple layers with no other custom code.&lt;/p&gt;

&lt;p&gt;Learn about the scratch file options for your project and use what you prefer.&lt;/p&gt;

&lt;p&gt;While not suitable for every situation, scratch files are a fantastic tool when focusing on a small amount of stand-alone code.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>When are you a developer?</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Mon, 06 Dec 2021 20:25:44 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/when-are-you-a-developer-4ii0</link>
      <guid>https://dev.to/kevinhickssw/when-are-you-a-developer-4ii0</guid>
      <description>&lt;p&gt;Once you write any code to solve a problem&lt;/p&gt;

&lt;p&gt;The answer really is that simple.&lt;/p&gt;

&lt;p&gt;It doesn't matter what programming language you used. Or if you wrote code for mobile phones, a website, or a desktop application.&lt;/p&gt;

&lt;p&gt;Even if you wrote the tiniest amount of code, as long as you solved something with code, you are a developer. Any experienced developer knows we spend way more time thinking about how to solve problems than actually writing code.&lt;/p&gt;

&lt;p&gt;You don't need to solve hundreds of problems to call yourself a developer either. The first time you write code, you are a developer. Sure, you are a beginner developer, but you aren't any less a developer than anyone else.&lt;/p&gt;

&lt;p&gt;Whether you wrote code for yourself or were paid also doesn't matter.&lt;/p&gt;

&lt;p&gt;Ignore the trolls that say you aren't a developer if you didn't use X language or work on Y platform. These people are insecure and trying to validate that their work is better than everyone else's. They forget what makes someone a developer.&lt;/p&gt;

&lt;p&gt;If you wrote code to solve a problem, go ahead and call yourself a developer.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Should You Specialize?</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Sat, 27 Nov 2021 15:00:14 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/should-you-specialize-26o2</link>
      <guid>https://dev.to/kevinhickssw/should-you-specialize-26o2</guid>
      <description>&lt;p&gt;&lt;strong&gt;It's no secret that experts that specialize in a particular niche tend to make more money.&lt;/strong&gt; It can be easy to think of how you pick a specialization and your career takes off.&lt;/p&gt;

&lt;p&gt;But before you can choose a specialization, you need to decide if you should specialize or how much you should specialize.&lt;/p&gt;

&lt;p&gt;The first step is figuring out if you want to specialize.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Will you like doing the same type of work for the same industry every day?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Specialists do not have as much variety between the types of clients or projects they take on.&lt;/p&gt;

&lt;p&gt;With the limited variety of jobs, there won't be as many job opportunities compared to the prospects for a generalist. However, the generalist also competes against many others for the job, including specialists.&lt;/p&gt;

&lt;p&gt;Along with fewer opportunities, sometimes specialists are brought on to solve a specific problem only, leading to shorter projects. Yes, specialists can make more money for these smaller jobs than a generalist working on a long-term project.&lt;/p&gt;

&lt;p&gt;But they need to be an expert to demand that higher rate. &lt;strong&gt;Waking up one day and deciding you now specialize in X won't magically make you more money.&lt;/strong&gt; First, you have to build your experience and reputation within the specialization.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The good news about choosing to specialize is you can also decide how niche your specialization is.&lt;/strong&gt; The more niche your specialization, the more chances you have to make money and become a top expert for a specific area. The broader you keep your specialization, the closer you are to the benefits and drawbacks of being a generalist.&lt;/p&gt;

&lt;p&gt;It is up to you to decide just how far you may want to specialize.&lt;/p&gt;

</description>
      <category>career</category>
    </item>
    <item>
      <title>How To Find A Bug Without Pulling Your Hair Out</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Wed, 24 Nov 2021 11:07:59 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/how-to-find-a-bug-without-pulling-your-hair-out-5fc9</link>
      <guid>https://dev.to/kevinhickssw/how-to-find-a-bug-without-pulling-your-hair-out-5fc9</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Working with code you're unclear about is like wading through a swamp. You should attempt to get yourself on solid ground as quickly as possible&lt;/p&gt;

&lt;p&gt;– Jon Skeet&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One of the most frustrating things about bugs with computer software is you get a bug report, someone is breathing down your neck to get it fixed, customers are upset, and everyone thinks it should be easy to find and fix.&lt;/p&gt;

&lt;p&gt;We're lucky if the problem is precisely where the error says or the user's bug report has enough details. Often we are stuck having to dig into the code while trying things ourselves to figure out where the problem is. It's never as easy as just jumping to a code line everything points to and changing something. We need to find the "root cause" to make sure we aren't fixing the symptoms of another bug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;root cause&lt;/strong&gt; - A root cause is an initiating cause of a bug&lt;/p&gt;

&lt;p&gt;Debugging is just like investigating a case. There are some initial steps you need to take. You can't investigate a crime if you don't know what it is and where it occurred. The same thing applies to fixing a bug.&lt;/p&gt;

&lt;p&gt;Time to put on our detective hats to find the root cause.&lt;/p&gt;




&lt;h2&gt;
  
  
  Gather Details
&lt;/h2&gt;

&lt;p&gt;Before trying anything, before changing any code, you need to gather as many details as possible. Review the bug report or error, then start asking questions to uncover missing details. If it is a bug report, you can ask the user, QA tester, or whoever submitted it. If it's an automated error report, you may need to ask yourself these questions by digging in the code, your systems, and online.&lt;/p&gt;

&lt;p&gt;Here are some of the questions you should ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is it easily reproduced?

&lt;ul&gt;
&lt;li&gt;If so, what are the exact steps to reproduce it?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Have others run into this issue?&lt;/li&gt;
&lt;li&gt;What is the device and system info the error occurred on?&lt;/li&gt;
&lt;li&gt;What changed recently? Any code deployments, configuration, or hardware changes?&lt;/li&gt;
&lt;li&gt;What should the code do when it works successfully?

&lt;ul&gt;
&lt;li&gt;Is there any validation, error handling, etc., in place that should be running?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to asking questions, you also want to make sure to research any additional information that could help you.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check logs and error reporting software for related errors and events that happened around the same time.&lt;/li&gt;
&lt;li&gt;Google any error messages. Google both to make sure you understand it and to see if others have solutions.&lt;/li&gt;
&lt;li&gt;Check git logs for recent deployments, hardware, or configuration changes. Keep in mind any recent changes, even if they seem unrelated.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Reproduce The Problem
&lt;/h2&gt;

&lt;p&gt;After you learn everything you can about the error, the next step is to reproduce it yourself. Ideally, you will reproduce this in the local environment you usually code in. The fewer chances you have to break other things while debugging, the better.&lt;/p&gt;

&lt;p&gt;One of the worst things we can do when debugging is changing things or fixing a bug when we couldn't reproduce the problem ourselves. This is why if we can't reproduce it locally, we want to try to reproduce it in production safely.&lt;/p&gt;

&lt;p&gt;We need to be careful of the potential issues and requirements we need to maintain in production, but sometimes the only choice is to debug in production. I'll write another article soon giving tips to limit needing to debug in production and how to do it successfully.&lt;/p&gt;

&lt;p&gt;Reproducing the bug is easy if you have steps from a bug report or error reporting tool. If you don't have the steps, you will need some trial and error until you figure out the exact steps to reproduce the bug. Reproducing bugs gets easier as you learn more about a system.&lt;/p&gt;

&lt;p&gt;Once you know the required steps to reproduce a bug, try to reduce the steps to the absolute minimum number of steps. The fewer steps needed to reproduce a bug, the quicker fixes can be tested. This is also a significant benefit for writing automated tests (if you have automated tests) to test the changes. Fewer steps mean less setup and easier to write automated tests.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you don't have automated tests, I highly recommend investing in the time to set up and add tests for all your code. There are plenty of resources for each platform and language to get started with automated testing. Automated testing offers many benefits, including speeding up debugging and ensuring bugs don't come back later.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Ask Someone Else
&lt;/h2&gt;

&lt;p&gt;One of the first steps should always be to ask if someone else ran into this bug before. Don't be afraid to ask QA testers, other developers, and sometimes even users about the bug. Asking can be the quickest way to fix a tricky bug if someone is already familiar with it.&lt;/p&gt;

&lt;p&gt;You never know who may have run into the problem before. There is a chance this person will know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How to fix it.&lt;/li&gt;
&lt;li&gt;They may have a workaround that can be used for now.&lt;/li&gt;
&lt;li&gt;They may also know if a permanent solution is filed to fix it.&lt;/li&gt;
&lt;li&gt;They could already have completed research to help speed up debugging.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By tackling each of these steps first, you will find fixing bugs to be less stressful. When you know the root cause and how to reproduce a bug, fixing it becomes a quick and painless process.&lt;/p&gt;

&lt;p&gt;If you would like more tips and tricks to level up your debugging and make fixing bugs less stressful, my book &lt;em&gt;Level Up Your Debugging&lt;/em&gt; is up for &lt;a href="https://kevinhickssw.gumroad.com/l/LevelUpYourDebugging"&gt;early access pre-orders on Gumroad&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>When Are You Ready To Freelance?</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Tue, 23 Nov 2021 00:09:21 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/when-are-you-ready-to-freelance-11m6</link>
      <guid>https://dev.to/kevinhickssw/when-are-you-ready-to-freelance-11m6</guid>
      <description>&lt;p&gt;Many people dream of the freedom being a freelancer brings. However, it can be a difficult journey, especially if you aren't ready for it.&lt;/p&gt;

&lt;p&gt;How do you know if you are ready?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Do you have the experience and can work on your own?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Clients expect freelancers to be able to hit the ground running, so make sure you know your job well enough to work on your own.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Do you have a portfolio?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Clients need proof you can complete the job. Having a portfolio also helps you answer #1 correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Are you able to manage yourself?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Freelancers need excellent time and project management skills. You won't have the structure a typical job provides to help keep you accountable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Are your people and communication skills strong?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will need to market and sell yourself, solve disagreements, and handle all communications yourself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Do you have a plan to get clients and get paid?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before starting, you need to know how you are going to make money. Decide if you will use a freelance marketplace, referral, cold calls/emails, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Are you ready to deal with the up and downs?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Freelancing can be fantastic, but it can also be stressful. Like any job, there will be bad days and good days. You may have to be ready to deal with a drop in income at times too.&lt;/p&gt;

&lt;p&gt;The great thing about freelancing is all the skills you need; you can learn and practice until you are ready to jump into the freelancing pool.&lt;/p&gt;

</description>
      <category>freelance</category>
      <category>career</category>
    </item>
    <item>
      <title>Avoid The Pain of Repeated Database Queries With Laravel Query Scopes</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Sun, 12 Sep 2021 15:11:50 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/avoid-the-pain-of-repeated-database-queries-with-laravel-query-scopes-1b13</link>
      <guid>https://dev.to/kevinhickssw/avoid-the-pain-of-repeated-database-queries-with-laravel-query-scopes-1b13</guid>
      <description>&lt;p&gt;As you continue building out Laravel apps, you will notice spots that you need to perform the same queries. If your project is like most projects I've worked on, you will start with just repeating the query code in many places.&lt;/p&gt;

&lt;p&gt;This works great until you need to change the query. Because the query is repeated throughout your code, you now need to change it everywhere. And you might forget to change it somewhere 🤦🏻. This is an enormous maintenance headache. I can't even count how many bugs I've encountered (and written myself) from forgetting to update code in multiple places.Luckily there are a few easy solutions to reduce duplicate queries.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can move all database code to stored procedures and only interact with the database through stored procedures.&lt;/li&gt;
&lt;li&gt;Create repository, service, builder, or other classes for your queries.&lt;/li&gt;
&lt;li&gt;Add methods to the Eloquent model to perform the queries.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these solutions will work and have their pros and cons. One solution that is built into Laravel that works well for this is &lt;a href="https://laravel.com/docs/8.x/eloquent#query-scopes"&gt;Eloquent Query Scopes&lt;/a&gt;. Query scopes provide some advantages over the other methods I mentioned. Three of the most significant benefits are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It is a first-class citizen of Laravel and built into how Eloquent works&lt;/li&gt;
&lt;li&gt;It can be easier to create smaller, reusable query scopes that can be combined in larger query scopes or one-off queries.&lt;/li&gt;
&lt;li&gt;They can be automatically applied to all queries on a model&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  So what exactly is a query scope?
&lt;/h2&gt;

&lt;p&gt;A query scope is a method that works on a model's query builder to modify the default query that would be run. What makes a query scope different from any other method you would write is that it is built into Laravel's Eloquent and meant to be a set of common constraints you would run instead of the entire query. Here is a typical method you might write to tasks that are not complete yet and assigned to a user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;GetActiveTasksForUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'assigned_to_user_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'isComplete'&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="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&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, if you think about the typical queries, you might need for a task. It isn't hard to imagine needing to query both for all tasks for a user and another for their tasks that aren't complete. Let's add a second method to only get the tasks assigned to a user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;GetAllTasksForUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'assigned_to_user_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&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 how the first half of this method is the same as the previous one. We are already duplicating code after just two different queries. It should be easy to see how this could get out of control pretty quickly. Let's convert the two constraints (tasks assigned to the user and incomplete tasks) to query scopes to see how that would help these methods.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In the task model (Task.php)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;scopeAssignedToUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Builder&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'assignedtouser_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;scopeIncomplete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Builder&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;void&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'isComplete'&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The two methods from before can be updated to use the new query scopes and avoid the duplicated query where clause.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;GetActiveTasksForUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;assignedToUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;incomplete&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&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="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;GetAllTasksForUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Collection&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; 
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;assignedToUser&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&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;The best thing about this approach is that we call simple methods whenever we need a new query that either gets tasks assigned to a specific user or incomplete.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to create a query scope?
&lt;/h3&gt;

&lt;p&gt;Creating query scopes is pretty similar to creating any method. There are just three main requirements to make the method a query scope.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Local scopes need to be on the model they apply to. Global scopes need to implement &lt;code&gt;Illuminate\Database\Eloquent\Scope;&lt;/code&gt; We'll get into local vs. global scopes in a little bit.&lt;/li&gt;
&lt;li&gt;Local scopes need to start with scope. For local scopes, everything after the word &lt;code&gt;scope&lt;/code&gt; becomes the method name to call to use the scope using &lt;code&gt;camelCasing&lt;/code&gt;. Ex: &lt;code&gt;scopeAssignedToUser()&lt;/code&gt; is called with &lt;code&gt;assignedToUser&lt;/code&gt;. Global scopes don't have any special naming requirements.&lt;/li&gt;
&lt;li&gt;The first argument should be an instance of &lt;code&gt;Illuminate\Database\Eloquent\Builder&lt;/code&gt;. For global scopes, the second argument should be an instance of Illuminate\Database\Eloquent\Model.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Local scopes can have no additional arguments or can have any arguments after the builder argument. Arguments in a local scope are used to change the query that runs. For example, in &lt;code&gt;scopeAssignedToUser&lt;/code&gt; we passed in an &lt;code&gt;$userId&lt;/code&gt; argument to change what user the query was checking tasks were assigned to.&lt;/p&gt;

&lt;h3&gt;
  
  
  But queries don't belong in the model.
&lt;/h3&gt;

&lt;p&gt;Depending on the size and complexity of your app or your coding standards, you might think that query scopes don't belong in the model. It is true that with Eloquent, it can be very easy to make your models bloated and full of logic that doesn't belong in it. If you aren't careful, the model can become a mixture of business logic, persistence layer, and other logic.&lt;/p&gt;

&lt;p&gt;Don't write off query scopes just yet. There is an easy way to take advantage of query scopes without bloating the model. Since query scopes are just methods that work on the model's query builder, you can extend the query builder and include your query scopes on the extended class. This puts all query scopes for each model in its own dedicated class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In TaskQueryBuilder.php&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;Illuminate\Database\Eloquent\Builder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;TaskQueryBuilder&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;extends&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;Builder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt;  &lt;/span&gt;&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;assignedToUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;int&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'assigned_to_user_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&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;// In Task.php&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;newEloquentBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;TaskQueryBuilder&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nf"&gt;TaskQueryBuilder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Still can be called the same way as before&lt;/span&gt;
&lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;assignedToUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$userId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Local Scopes vs. Global Scopes
&lt;/h2&gt;

&lt;p&gt;The main difference between a local scope and global scope is local scopes have to be called and are meant for repeated database constraints you may not need all the time. Global scopes, on the other hand, will run automatically for every query on a model. They are meant for things you are almost always going to want to run and don't want to forget when querying for that model. For global scopes, think of things like not loading soft deleted records (Laravel's SoftDeletes trait uses global scopes) or checking if a record belongs to a company for multi-tenant apps (apps that serve multiple different companies each with their own dataset).&lt;/p&gt;

&lt;p&gt;The scopes we created above were local scopes. The following examples will be global scopes that have a few differences in how they are made and used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They need their own dedicated class and to be registered in the model's booted method.&lt;/li&gt;
&lt;li&gt;The method names are not prefixed with scope.&lt;/li&gt;
&lt;li&gt;They can not have arguments that easily change for each query in the same request. Any arguments for global scopes will require some type of global state.&lt;/li&gt;
&lt;li&gt;They run without calling them explicitly. To avoid running them for a query, the &lt;code&gt;withoutGlobalScope&lt;/code&gt; method needs to be used.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's create an example Global scope for checking if a record belongs to a company.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Database\Eloquent\Builder&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Database\Eloquent\Model&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Database\Eloquent\Scope&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BelongsToCompanyScope&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Scope&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;protected&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;CompanyResolver&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nv"&gt;$resolver&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;__construct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;CompanyResolver&lt;/span&gt; &lt;span class="nv"&gt;$resolver&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;resolver&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$resolver&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="cd"&gt;/**
     * Apply the scope to a given Eloquent query builder.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $builder
     * @param  \Illuminate\Database\Eloquent\Model  $model
     *
     * @return void
     */&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;Builder&lt;/span&gt; &lt;span class="nv"&gt;$builder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;Model&lt;/span&gt; &lt;span class="nv"&gt;$model&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt; &lt;span class="nv"&gt;$builder&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'company_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;resolver&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getCurrentCompanyId&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&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;This example shows how we can use a resolver passed into the global scope to change what company we are loading records for. The resolver could be any class that tracks the current company for the current user. Maybe it is stored in the session, cache, or querying the user's database table.&lt;/p&gt;

&lt;p&gt;This is one of the easiest ways to get global scopes to work with arguments that could change based on the current user or session. However, it does have its downsides that we are now introducing some type of global state into the scope, and the model will also have to know about the &lt;code&gt;CompanyResolver&lt;/code&gt; too. This can make fixing bugs and changing features in the future harder. For this reason, I'm not a big fan of doing this on larger projects or for anything that doesn't rely on a global user or session state the entire app needs to know about anyways.&lt;/p&gt;

&lt;p&gt;To use this BelongsToCompany scope, it needs to be registered in the model class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// In Task.php&lt;/span&gt;
&lt;span class="cd"&gt;/**
 * The "booted" method of the model.
 *
 * @return void
 */&lt;/span&gt;
&lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;booted&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="err"&gt;    &lt;/span&gt;&lt;span class="k"&gt;static&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;addGlobalScope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;BelongsToCompanyScope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nc"&gt;CompanyResolver&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 every time we query for a task, it will automatically add &lt;code&gt;where company_id = $someCompanyId&lt;/code&gt; to the query. However, if we don't want the global scope to run, excluding them for specific queries is also easy. For example, maybe we want to get all tasks for all companies. In this case, we need to exclude the &lt;code&gt;BelongsToCompanyScope&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nc"&gt;Task&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;withoutGlobalScope&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;BelongsToCompanyScope&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;class&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we wanted to exclude multiple scopes or all scopes, we could use &lt;code&gt;withoutGlobalScopes&lt;/code&gt;. When called with no arguments, it removes all scopes. When called with an array, it will remove all scopes in the array.&lt;/p&gt;

&lt;h2&gt;
  
  
  Query scopes are just one way to reduce duplicate query code
&lt;/h2&gt;

&lt;p&gt;As mentioned earlier in the article, query scopes are just one way to reduce duplicate code. They might not be the best for every situation or project, but they should be another tool in your belt. It is up to you and your team to decide what patterns and practices you want to follow for your project.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Becoming A Senior Developer Is Not About Your Code</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Thu, 25 Feb 2021 13:37:01 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/becoming-a-senior-developer-is-not-about-your-code-3ok3</link>
      <guid>https://dev.to/kevinhickssw/becoming-a-senior-developer-is-not-about-your-code-3ok3</guid>
      <description>&lt;p&gt;I have talked to several great developers who write fantastic code with years of experience who were confused about why they were not a senior developer yet. Maybe you have had some of the same thoughts. Perhaps you think you are ready to be promoted, but it doesn't seem to be coming any time soon.&lt;/p&gt;

&lt;p&gt;If you look at the requirements for most senior developer positions, it seems like all the requirements are you need 5+ years of experience with language X and technology Y. So when you see this, you start thinking I write great code. I have the experience, I should be a senior developer.&lt;/p&gt;

&lt;p&gt;In reality, being a senior developer is more about your skills outside of coding. A senior developer is also a leader. If you pay attention, you will see most senior developers perform many tasks outside of coding. They also seem to possess some of the same skills and quantities. Senior developers often are great leaders, manage projects, the go-to person for help, and help everyone around them grow. Now don't get me wrong, some senior developers don't lead teams, or their greatest skill might be their code. However, in my experience, these senior developers take longer to get there, might be passed up for other opportunities, and aren't looked at with the same type of respect as seniors who can excel at both coding, and being a leader. It's often these other skills that lead to being promoted, not the quality of code.&lt;/p&gt;

&lt;h1&gt;
  
  
  How do you improve these other skills?
&lt;/h1&gt;

&lt;p&gt;First, you want to focus on yourself. Become an expert at managing and leading yourself before you attempt to lead anyone else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know how to plan and manage your tasks and projects.
&lt;/h2&gt;

&lt;p&gt;Estimates for software projects are rarely correct. It's tough to account for all the unknowns and get it right. We still need to try to do our best at estimating, though, so other features, teams, and marketing efforts can be planned around our features. When you first start out trying to manage your projects, first learn how long it takes you to do specific tasks. Once you have a good baseline for how longs things take you, you can start using that to estimate similar features. You should double any estimate you come up with to play it safe.&lt;/p&gt;

&lt;p&gt;Once you are comfortable estimating your tasks, start learning how long your teammates take for their tasks. You should get comfortable being able to estimate for your team and judge how long a developer of specific skill levels may take. One important thing to remember for this is developers should never be solely assessed on their speed. Everyone will work at different paces, even at the same skill level. Two of the best developers I ever worked with were on complete opposite ends of the speed scale. Speed is not a comprehensive measurement of a developer's skill.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn the best ways to get unstuck and help yourself.
&lt;/h2&gt;

&lt;p&gt;To be clear, I don't mean to spend hours stuck on a problem without asking for help. If you are stuck on something for longer than 15 - 30 minutes and have the resources to ask for help, you should. I can't tell you how many times I spent hours trying to figure out an issue for someone else to tell me how to fix it in 5 minutes. However, it would help if you started learning the best ways to debug problems, look up information, and troubleshooting in general. This is important as senior developers have to figure out challenging issues no one else may have the answer to and guide others on fixing their bugs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Identify weaknesses.
&lt;/h2&gt;

&lt;p&gt;A large part of being a leader is being able to admit what you aren't good at. You can't be the best at everything. You also can't complete everything yourself. Senior developers recognize this and learn when it's best to ask for help and rely on their team. It is about maximizing the team's potential and leading them to success, not your success.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practice empathy.
&lt;/h2&gt;

&lt;p&gt;Think back to some of your favorite bosses or teachers. One of the reasons you liked them likely was you felt like you could relate to them and be comfortable around them. We feel this way around people that practice empathy. They can put themselves in other people's shoes to see what they are going through and understand their viewpoint. Doing this can help people relax, help connect to them, and guide them on the correct path.&lt;/p&gt;

&lt;p&gt;Even before being a senior developer, you can start to practice this. Learn to recognize when a team member may be having an off day, struggling with an issue. Don't jump to judge them if they have been seeming slow or running into problems. They may be going through something you don't know about or frustrated from being stuck. Again think back to some of your previous favorite bosses. When you had a rough time, they probably weren't rough on you. They probably cut you some slack. Maybe they let you work on something that they knew you would enjoy, offered to talk, or just took a step back. Being able to step into someone's shoes to understand them and then react accordingly may be one of the most critical skills a leader needs. It's hard to be a leader people want to work with, but great leaders are people others want to follow.&lt;/p&gt;

&lt;h1&gt;
  
  
  It will take time.
&lt;/h1&gt;

&lt;p&gt;It is easy to be so excited about moving up that you forget that it will take time. There is a reason all those job requirements list years of experience for senior developers. Becoming a great developer takes a long time. Improving all the skills outside of coding takes years of practice. Even after you are a great developer and have nailed down all the other skills, it can still take even more years to be promoted. First, there has to be an opening for a senior-level position to fill. If a job is open, your manager and team also need to see a proven track record of you using the required skills. They need to see you in situations where you can prove that you have what it takes to be a senior developer.&lt;/p&gt;

&lt;p&gt;Don't give up. Don't lose excitement over moving up. Just keep practicing and improving your skills, and eventually, you will be a senior developer.&lt;/p&gt;

</description>
      <category>career</category>
      <category>leadership</category>
    </item>
    <item>
      <title>Did you break your code today?</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Wed, 17 Feb 2021 17:07:21 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/did-you-break-your-code-today-3h0c</link>
      <guid>https://dev.to/kevinhickssw/did-you-break-your-code-today-3h0c</guid>
      <description>&lt;p&gt;I broke my code today. And I'm glad I did.&lt;/p&gt;

&lt;p&gt;You might be wondering why I would be glad I broke my code? Wouldn't I want it to work? Am I crazy?&lt;/p&gt;

&lt;p&gt;I'm happy that I broke my code before anyone else broke it. I found the issue before it caused problems for users and before I spent QA's (quality assurance) and a peer reviewer's time. We should all be aiming to do this. It's easy to get code that works  90% of the time. But that other 10% of the time, all those annoying edge cases can be hard to even think of, let alone make sure your code handles them correctly. So how do you think of these edge cases we need to handle?&lt;/p&gt;

&lt;h1&gt;
  
  
  Think about your code like QA
&lt;/h1&gt;

&lt;p&gt;Now I don't mean you need to do everything QA does or replace your QA person. You don't even need to write the test cases and test plans if QA normally handles that, but you need to think about breaking your code the same way they think about it.&lt;/p&gt;

&lt;p&gt;So how does QA think about breaking your code?&lt;/p&gt;

&lt;h2&gt;
  
  
  Understand what your code should do
&lt;/h2&gt;

&lt;p&gt;The first thing you can do to make sure your code works correctly is to understand what it should do. This might seem like common sense, but it is common for bugs to be caused by misunderstandings between project managers, stakeholders, and developers.&lt;/p&gt;

&lt;p&gt;If you have any doubts, questions, or concerns, they need to be discussed before the code goes live. Don't worry about this coming off as pushing back or asking dumb questions. If something isn't clear to you, it probably isn't clear to someone else. I've even seen stakeholders realize they don't understand their own requirements when I asked for clarification. Think you have a better idea, bring it up. Your stakeholders and users will thank you if it improves things. If it doesn't improve things, they will still appreciate you trying to improve the product.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test for the success cases
&lt;/h2&gt;

&lt;p&gt;Now that you know what the code should do, you should test that it actually does what it should. At this time, give the program the exact input it expects and don't do anything that may risk breaking it. We will get into trying to break it later. For now, we want to make sure we have a good starting point to test for failures and edge cases.&lt;/p&gt;

&lt;p&gt;If your project has automated tests, this would be the time to write the automated tests for all the success cases. Automated tests will allow us to ensure the success path still works without manual testing as we address failures and edge cases. I highly recommend writing automated tests. Yes, automated testing can be a pain to learn and get right, but it will save you in the future. I can't count how many times I broke code with changes that shouldn't have affected anything because of not having tests. If you aren't ready to learn automated testing or can't add it to your project, no big deal, but you will need to revisit this step later to test it again manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test for known failures
&lt;/h2&gt;

&lt;p&gt;You know what the code should do. You know the code does it successfully. Now it's time to test for failures you know are going to happen. Maybe these failures are spelled out in the requirements. For example, it might say, "When clicking on a link, it goes to the product page. If the product is not found, redirect to a product listing page." This is easy to test for as your stakeholders tell you what to do when it fails.&lt;/p&gt;

&lt;p&gt;Other known failures would include things you realize may happen while working on the success case. Going back to the product page example, if the stakeholders didn't mention how to handle a not found product, you might think about this issue yourself. You may decide it should return a 404 error or redirect to a product listing on your own. Better yet, ask the stakeholders which one it should do. Or you may be working on a search and realize you need to throw a validation error if no search term is provided.&lt;/p&gt;

&lt;p&gt;At this stage, think of anything you can that may go wrong and test your code to see what happens in those situations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make foolish mistakes; do the wrong thing on purpose
&lt;/h2&gt;

&lt;p&gt;The amazing thing about users is they will always do what you don't expect. They will break things in a way you can't think of. They will also make things work in unexpected ways and cause outcomes you didn't believe were possible. This is the part I find fun about testing code. It's an excuse to go crazy and make dumb mistakes on purpose to see how your code reacts. This is precisely how a great QA person will test your code.&lt;/p&gt;

&lt;p&gt;Even if we are going crazy with making mistakes, we still need to follow a process. If you just test for random things and don't pay attention to what you are doing, you won't know how to recreate the issue to test your fix. Instead, you want to make sure you are paying attention to exactly what you click on, what you type in, and what happens as a result. You also want to make sure that you remember what you have tested and haven't tested even though your testing may be random. Make a list of the tests you have run and put a mark next to those that require a fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what are some good foolish mistakes to make?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Push validation to the limit
&lt;/h3&gt;

&lt;p&gt;What happens if you don't include inputs? What happens if you use an excessively long string or a large number? What about a negative number or passing a string for a number?&lt;/p&gt;

&lt;p&gt;To test validation, you want to do everything wrong with all of your inputs you can think of. You know what each input should do; now do the opposite and other silly things to see if your code can handle it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do the opposite of what you expect users to do
&lt;/h3&gt;

&lt;p&gt;Literally do the opposite of what you expect users to do.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do things out of order.&lt;/li&gt;
&lt;li&gt;Click out of pages in the middle of a process.&lt;/li&gt;
&lt;li&gt;Hit the cancel button in a modal, reopen the modal and try to submit again.&lt;/li&gt;
&lt;li&gt;Anything else you can think of that doesn't make sense for the feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This type of testing could be anything and will vary depending on what feature you are working on.  The point is to make sure you aren't doing what you tested for during the success cases. A great way to do this may be to act like you don't know how to use a computer or website.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hack your code
&lt;/h3&gt;

&lt;p&gt;It is your turn to be the hacker. Can you find any security issues in your code? Have you tried a SQL injection, XSS (Cross-Site Scripting), CSRF (Cross-Site Forgery Request) attack, etc.?&lt;/p&gt;

&lt;p&gt;Security is a big topic that has its own articles, books, and courses. It's also going to vary based on platform, language, devices, etc., so I won't go into details on specific security threats. Make sure you become familiar with common threats for what you are working on so you can test for them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Make it so slow you get bored
&lt;/h3&gt;

&lt;p&gt;You don't want to make your code inefficient on purpose, but you should test features with a ton of data. Have the option to change the number of records on a page? What happens if you make that number 10,000? Is it still fast? Can you upload a file with 10,000+ records without getting bored waiting for it to complete?&lt;/p&gt;

&lt;p&gt;It's easy to fill in 5 dummy records and start testing a feature. We often forget that real users may try to work with enormous amounts of data at once. It's usually after our first power user hits 10,000+ records, and we have an urgent bug fix because the page won't load; we realize performance is a problem. Find the limit of how much data your code can handle, then try to optimize it. Once you can't optimize it anymore, make sure your users can't go past that limit or provide a way to offload the process to a background job so the user can be alerted when it's done instead of making them wait.&lt;/p&gt;

&lt;h2&gt;
  
  
  You broke your code; now its time to fix it
&lt;/h2&gt;

&lt;p&gt;Each of the issues you find is probably going to require different fixes. You might need to add validation checks and messages, add additional alerts for the user, prevent actions from happening, or optimize queries. The important thing is to refer back to the steps you took and what went wrong when performing them. Ideally, you would write automated tests for each issue you fixed, so you can be sure it won't happen again. If you don't have automated tests, then it just means you have more manual testing to do for all these issues every time you touch this code.&lt;/p&gt;

&lt;p&gt;As a final note, it is essential to realize you won't find every issue every time. There is a reason QA is a vast profession and necessary in our industry. A developer doing this type of testing aims to eliminate back and forth between developers and QA and save time, not find and fix all issues.&lt;/p&gt;

&lt;p&gt;Have any other tips or suggestions on how to test your code for edge cases? Please share in the comments or on &lt;a href="https://twitter.com/KevinHicksSW"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now have fun and break your code, so no one else has to know it was broken.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>webdev</category>
      <category>testing</category>
      <category>programming</category>
    </item>
    <item>
      <title>How do you deploy your database changes?</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Tue, 16 Feb 2021 15:17:05 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/how-do-you-deploy-your-database-changes-2j64</link>
      <guid>https://dev.to/kevinhickssw/how-do-you-deploy-your-database-changes-2j64</guid>
      <description>&lt;p&gt;When working with websites that are likely to have active users at any time and you can't have downtime, deploying database changes with your code changes can be an issue. You need to either deploy changes in a way that they can go out at different times without causing issues or deploy database changes that take effect at the same time as the code changes.&lt;/p&gt;

&lt;h1&gt;
  
  
  Concerns during database deploys
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;No downtime&lt;/li&gt;
&lt;li&gt;Possible bugs&lt;/li&gt;
&lt;li&gt;Rolling back code&lt;/li&gt;
&lt;li&gt;Data changes&lt;/li&gt;
&lt;li&gt;Possible long-running tasks (import data, big data updates, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Possible deployment solutions
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Deploy with the code as part of the code CI (Continous Integration process) using something like migrations or deploy scripts&lt;/li&gt;
&lt;li&gt;Deploy database changes ahead of time in a way that won't break existing code.&lt;/li&gt;
&lt;li&gt;Deploy database changes with their own CI&lt;/li&gt;
&lt;li&gt;Manually deploy database changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How do you handle your database deployments? Do you use one of the above solutions or something else?&lt;/p&gt;

&lt;p&gt;Do you have any tips or tricks for database deployment or handling issues that may arise?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>healthydebate</category>
      <category>webdev</category>
      <category>database</category>
    </item>
    <item>
      <title>Even Senior Developers Have Imposter Syndrome</title>
      <dc:creator>Kevin Hicks</dc:creator>
      <pubDate>Sat, 13 Feb 2021 14:05:08 +0000</pubDate>
      <link>https://dev.to/kevinhickssw/even-senior-developers-have-imposter-syndrome-4e8f</link>
      <guid>https://dev.to/kevinhickssw/even-senior-developers-have-imposter-syndrome-4e8f</guid>
      <description>&lt;p&gt;If I told you I spent all day trying to figure out how to design the solution to a problem in a language I worked in every day and made absolutely no progress, would you think I was a new or junior developer? What if I also told you that nothing I tried worked at all and that I felt like I was "faking" being a developer? Many of you may think I'm a relatively new developer with only maybe a year or two of experience if this was the only thing you knew about me. The truth is I am an experienced developer with several accomplishments, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Over ten years of professional experience&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I've been programming since childhood&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spoken at a conference and meetups&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Became a Senior Software Engineer at a company with a large and very talented developer group&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run a successful digital agency doing both consulting and development for startups and enterprises.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even with these accomplishments and knowing that I am some developers' mentor (some of them paying for the coaching), I still felt like I wasn't a real developer today. I felt as if I wasn't good enough or smart enough to be a good developer. This feeling of faking it or better known as imposter syndrome that I want to focus on.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is imposter syndrome?
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;A psychological condition that is characterized by persistent doubt concerning one's abilities or accomplishments accompanied by the fear of being exposed as a fraud despite evidence of one's ongoing success. - &lt;a href="https://www.merriam-webster.com/dictionary/impostor%20syndrome"&gt;Merriam Webster&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We may not like to admit it, but most developers will go through imposter syndrome at some point in their career. It can be hard to recognize and deal with when it happens, as you may genuinely think you are a failure and do not belong when going through it. Not enough developers are willing to talk about their experience with it, or many will laugh off their feelings about it. Imposter syndrome can be scary and hold you back. It wouldn't be surprising if it has driven people away from the industry who would have been great developers. It is essential to recognize not only when you are going through it but also that everyone else has or will go through it.&lt;/p&gt;

&lt;h1&gt;
  
  
  A senior developer with imposter syndrome
&lt;/h1&gt;

&lt;p&gt;I personally still struggle with imposter syndrome. It is weird to admit this with my experience and accomplishments. Yet, there are days that I feel like I don't have a clue what I am doing or that I am the worst developer in the world compared to someone else. I have a long list of setbacks that my imposter syndrome has directly caused.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Unfinished side projects&lt;/strong&gt; - I have a long list of unfinished side projects. These are a mixture of personal projects and products I wanted to launch for my agency. Every time I get close to releasing something, I start feeling ashamed of the project. I compare it to competitors or just other things I see other developers put out there and start to feel embarrassed of what I worked on and like it won't go anywhere. I have now restarted my passion side project three times after it was almost done due to imposter syndrome.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Deleted and restarted my blog&lt;/strong&gt; - I used to have a blog going where I would write off and on. I never really wrote anything in-depth and even stayed away from some technical topics to avoid sounding like I didn't know what I was talking about. Eventually, I just deleted it and now I have to start from scratch again.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoiding goals&lt;/strong&gt; - I have some goals that I have had for many years. These are goals that are part of my dream of where I want to be as a developer and where I want my agency to go. I have always wanted to write books and courses. I love teaching and helping other developers grow but am often held back by feeling like I don't know enough to be the right person to help.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In addition to these more significant setbacks, imposter syndrome has affected my productivity, made me anxious when submitting work for review, and made me upset and feeling down on a day to day basis almost any time I struggled with coding. If you have been writing code long enough, you realize it doesn't take many days to end up on a day you are struggling with a problem.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to handle imposter syndrome?
&lt;/h1&gt;

&lt;p&gt;Handling imposter syndrome is probably a little different for everyone. Everyone will have different things that will help them calm down, recognize the truth, and help build their confidence. There are a few tips that may work for you and that I have found to help with my imposter syndrome personally.&lt;/p&gt;

&lt;h2&gt;
  
  
  Talk to someone
&lt;/h2&gt;

&lt;p&gt;Find someone who you trust and is supportive to talk through your feelings. This could be anyone that can help you see your accomplishments, what you have learned and what you know. However, it can be a bonus if this could be another developer who may entirely understand what you are going through and can speak directly to your programming accomplishments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make a list of your accomplishments
&lt;/h2&gt;

&lt;p&gt;Make a list of any programming accomplishments you have up to this point. When you start feeling imposter syndrome come on, go back and review this list. This list should remind you of what you have learned and the problems you already overcame. If you learned a language, you are a developer. If you solved a complex coding problem, you are a developer. If you completed a project, you are a developer. This list should contain many of these things that will remind you that you can do this and are not faking it. Even if you are struggling with a problem and feel lost, this list is a powerful reminder of everything you grappled with before and learned how to overcome.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stop comparing yourself to others
&lt;/h2&gt;

&lt;p&gt;One of the worse things you can do when dealing with imposter syndrome is to compare yourself to others. Everyone is unique and each person is going to be better at something than someone else. Even the best C# developer could feel like the worse developer if they compared themselves to the best JavaScript developer thinking they should be just as good (feel free to replace these examples with any technologies or languages). Many times I hear developers I am working with comparing themselves to other developers or me. They are always wishing they knew as much, wrote code as fast, and had as good of designs. In these situations, the developers hoping they were like the other developers had also taught the other developers or myself many things without even realizing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't worry about what you don't know
&lt;/h2&gt;

&lt;p&gt;As a developer, you are never going to know everything. There truly is a new language, framework, best practice, etc. every day. We need to acknowledge there isn't enough time to learn everything. Instead of worrying about what you don't know, pick things you want to learn about or improve to focus on those. Let these things be a way to grow your list of accomplishments, enhance your skills and expand your knowledge. Keep in mind you won't know everything while remembering you can learn anything you need or want to the same way you have before.&lt;/p&gt;

&lt;h2&gt;
  
  
  No matter your language, you are a real developer
&lt;/h2&gt;

&lt;p&gt;Unfortunately, there is some toxicity in our industry. You probably have seen all the arguments about language X, framework Y, or technology Z is the best, and the rest suck. Or that if you work with language X, you aren't a real developer. This is just toxic behavior, and there isn't any truth to these statements. Every language, framework, and technology have their pros and cons. I defended web programming in &lt;a href="https://www.quora.com/Why-is-web-programming-looked-down-amongst-programmers/answer/Kevin-Hicks-24"&gt;my quora answer&lt;/a&gt; by pointing out how all the reasons to list why web programming was "looked down on" could be applied to other types of development. If you approach these arguments with this analysis, it's easy to see how no language, framework, or technology is better than another in all cases. If you work with any of them, congratulations, you are a real developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get a coach (or a therapist)
&lt;/h2&gt;

&lt;p&gt;There is nothing wrong with getting professional help like a coach or therapist to help with imposter syndrome. There can still be a bit of a negative response to working with a therapist, but it honestly can be the best thing for both your professional and personal life. There are also starting to be blurred lines between coaches and therapists, with some people able to feel both roles. This blending does make it harder to find someone who is appropriately qualified and can provide the help you need, but it also removes some of the negative reactions since having a coach may be seen as a positive or smart move. Honestly, working with a therapist should be viewed the same way as working with a coach. Nothing has to be wrong with someone to see a therapist. Many therapists work with people to help them improve and be the best version of themselves. This last tip may not be necessary, or it may be the one that finally enables you to overcome your imposter syndrome completely.&lt;/p&gt;

&lt;p&gt;Personally, taking the step of working with a professional is what allowed me to start getting over my imposter syndrome. I have heard of and tried the other tips but found myself still struggling with it. I kept finding my emotions overpowering the logical sense of the above tips. Working with someone helped me figure out why I thought that way and how to take steps to improve my confidence to reduce the imposter syndrome. Since working with them, I have made progress on my side projects, releasing bits to the public, started writing &lt;a href="https://leanpub.com/you-need-code-reviews/"&gt;a book on code reviews&lt;/a&gt;, and finally started my blog again.&lt;/p&gt;

&lt;h1&gt;
  
  
  You are not an imposter
&lt;/h1&gt;

&lt;p&gt;Just remember, once you have written your first piece of code, you are a developer. Whether you feel it now or go through imposter syndrome in the future, remember you are a developer. You are not alone when you feel like you are faking it, and even us senior developers go through it too. Hopefully, this provided you with some new tips to help overcome it, or just knowing everyone else goes through it will give some comfort.&lt;/p&gt;

</description>
      <category>career</category>
      <category>beginners</category>
      <category>mentalhealth</category>
    </item>
  </channel>
</rss>
