<?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: scottshipp</title>
    <description>The latest articles on DEV Community by scottshipp (@scottshipp).</description>
    <link>https://dev.to/scottshipp</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%2F38444%2Fd59c5288-49e2-45aa-9dd1-7c80deab3b89.jpg</url>
      <title>DEV Community: scottshipp</title>
      <link>https://dev.to/scottshipp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/scottshipp"/>
    <language>en</language>
    <item>
      <title>What's so bad about four-week sprints?</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Mon, 07 Nov 2022 22:19:25 +0000</pubDate>
      <link>https://dev.to/scottshipp/whats-so-bad-about-four-week-sprints-m1l</link>
      <guid>https://dev.to/scottshipp/whats-so-bad-about-four-week-sprints-m1l</guid>
      <description>&lt;p&gt;I've worked in various software teams that use scrum for the past ten years. Some of these teams use two-week sprints and some use four-week sprints. Most software teams I've talked to implicitly believe that shorter sprints are a sign of health and scrum "maturity." Four-week-long sprints are for software teams that are still "children" at practicing scrum. The dominant belief is that those teams should get better one day and move to two-week sprints.&lt;/p&gt;

&lt;p&gt;My personal experience, though, is that teams with two-week sprints carry over more work, experience higher deadline pressure from management, and, worst of all, spend a higher ratio of their time in sprint ceremonies rather than implementing and deploying code. Two-week sprints involve three long meetings (sprint demo, sprint retro, and sprint planning) every other week, which is twice as much time spent in meetings as those who only have those meetings every four weeks.&lt;/p&gt;

&lt;p&gt;Finally, I have observed that the ability to deliver sprint commitments more directly depends on how much of a team's work is dependent on other teams as opposed to being independently deliverable. The larger driver of the ability for work to be "independently deliverable" is the overall organization of the engineering department. Teams that can complete their work independently are just inherently able to deliver smaller batches of work more often, and it has nothing to do with their scrum "maturity." So my takeaway is that engineering departments who have teams experiencing "trouble" with two-week sprints should probably re-org their teams, rather than flog the "you aren't agile enough" horse.&lt;/p&gt;

&lt;p&gt;So, what do &lt;em&gt;you&lt;/em&gt; think about sprint length? &lt;/p&gt;

&lt;p&gt;What's so bad about four-week sprints? &lt;/p&gt;

</description>
      <category>discuss</category>
      <category>watercooler</category>
      <category>agile</category>
    </item>
    <item>
      <title>How to write an effective email as a software engineer</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Fri, 04 Nov 2022 21:57:10 +0000</pubDate>
      <link>https://dev.to/scottshipp/how-to-write-an-effective-email-as-a-software-engineer-504j</link>
      <guid>https://dev.to/scottshipp/how-to-write-an-effective-email-as-a-software-engineer-504j</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note: this article was originally published on LinkedIN&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You may think most software engineers know how to write effective email but you'd be wrong. Email was invented by software engineers, but it is still a difficult tool to use to communicate technical content.&lt;/p&gt;

&lt;p&gt;So what can software engineers do to write better email?&lt;/p&gt;

&lt;h2&gt;
  
  
  Provide one clear takeaway
&lt;/h2&gt;

&lt;p&gt;The first rule of email is that each email should have one clear takeaway.&lt;/p&gt;

&lt;p&gt;If this is the only takeaway you get from this article, then I've done a great job. (See what I did there?)&lt;/p&gt;

&lt;p&gt;Before you sit down to write an email, think of a simple, clear, and short sentence that sums up the email. Does the reader need to take an action? Is there a vital piece of information that you need the reader to know? What is the one thing they need to take away when they get up and walk away from the screen? I learned this tip from a Harvard Business School book on business communication.&lt;/p&gt;

&lt;p&gt;If you can't summarize in a single clear sentence what you want the reader to know or do as a result of reading the email, grab some tea or coffee while you think about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the takeaway in the subject line
&lt;/h2&gt;

&lt;p&gt;When you have that one clear sentence straight in your head, come back and write it down in the subject line.&lt;/p&gt;

&lt;p&gt;(Skip the recipient lines (to, cc, and bcc) at the top for now. You can enter recipients later after you're sure you have written an effective email.)&lt;/p&gt;

&lt;p&gt;Now improve your subject. Remember that it will appear in the middle of a list of dozens of others, so you should make it great. With a great subject line, you can rest assured that if the recipient reads nothing else, they still get the message.&lt;/p&gt;

&lt;p&gt;Consider that many people now read email on smartphones and tablets. This usually truncates most subject lines after four to seven words.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Subject line examples
&lt;/h2&gt;

&lt;p&gt;Here are some example subject lines for technical email:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Please update: InternalLib 4.0 is now available&lt;/li&gt;
&lt;li&gt;Last chance: Submit feedback on draft Go coding guidelines&lt;/li&gt;
&lt;li&gt;Signup now if you want to teach a March brownbag session&lt;/li&gt;
&lt;li&gt;New coffee blends now available in the breakroom&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Aim for five sentences or less
&lt;/h2&gt;

&lt;p&gt;What about the body? Is it a place to make further points than the one made in the subject line?&lt;/p&gt;

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

&lt;p&gt;The body of the email is for a few additional details about the subject only. Keep in mind that the reader probably has 40 other emails to read, besides meetings to attend and sprint commitments to deliver. They have made their valuable attention available to read your email, so make it count.&lt;/p&gt;

&lt;p&gt;As a general rule of thumb, try to limit the body to less than five sentences. Five sentences is not an arbitrary number. There is actually a movement online to reduce email length. Visit &lt;a href="http://five.sentenc.es/" rel="noopener noreferrer"&gt;http://five.sentenc.es/&lt;/a&gt; to find out more.&lt;/p&gt;

&lt;p&gt;An email's body should spur the reader to action. It should not cover other points outside the subject. If you need to convey another, separate message—even if it's related—send a separate email or link to a document after conveying the more important primary point.&lt;/p&gt;

&lt;p&gt;This can be counter-intuitive. Once you have made your point in the subject line, you may feel that the other party should have as much context as possible. Resist this urge. If you absolutely feel that more context is necessary, attach a document or leave a link to a web page with that information instead.&lt;/p&gt;

&lt;p&gt;But how do you choose what context someone needs immediately versus what can be linked? Especially considering that attached or linked content may never be opened by a busy recipient?&lt;/p&gt;

&lt;h2&gt;
  
  
  Providing context
&lt;/h2&gt;

&lt;p&gt;In the case of an action-oriented email, consider if the recipient will need to make a decision in order to choose the right action, and give them the context they need to make that decision. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;From: Hamilton, Margaret &amp;lt;mhamilton@example.org&amp;gt;
Date: Monday, January 27, 2022 at 11:53 AM
To: Lovelace, Ada &amp;lt;alovelace@example.org&amp;gt;, Hopper, Grace &amp;lt;ghopper@example.org&amp;gt;
Subject: ACTION: Update log4j in your applications immediately

A critical vulnerability in the log4j library has been discovered. Please update to version 2.15.0 immediately.

- Link: How to find out if your application uses log4j
- Link: Log4Shell FAQ
- Link: Security team support page

Thanks,

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

&lt;/div&gt;



&lt;p&gt;Here, the action is clearly expressed in the subject. The first two lines of the email provide context for that action including why its necessary and what version to use in the update. The following three bullets are all links to further context some recipients may need in order to perform the action.&lt;/p&gt;

&lt;h2&gt;
  
  
  The non-email option
&lt;/h2&gt;

&lt;p&gt;If you are struggling with communicating a single, clear point in an email, then maybe you need an alternate form of communication:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A meeting&lt;/li&gt;
&lt;li&gt;A Gitter room or Slack channel&lt;/li&gt;
&lt;li&gt;A pull request&lt;/li&gt;
&lt;li&gt;A shared document with commenting turned on&lt;/li&gt;
&lt;li&gt;A JIRA story&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use your imagination and your available resources.&lt;/p&gt;

&lt;p&gt;Your email may turn into a short invitation to comment on a document, review a PR, or attend a meeting instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Replies
&lt;/h2&gt;

&lt;p&gt;If you haven't seen it, a great guideline for replies is the following, from &lt;a href="http://www.five.sentenc.es/" rel="noopener noreferrer"&gt;www.five.sentenc.es&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Treat all email responses like SMS text messages, using a set number of letters per response. Since it’s too hard to count letters, we count sentences instead. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.five.sentenc.es" rel="noopener noreferrer"&gt;www.five.sentenc.es&lt;/a&gt; is a personal policy that all email responses regardless of recipient or subject will be five sentences or less. It’s that simple. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Email Debates
&lt;/h2&gt;

&lt;p&gt;It often happens that programmers engage in email debates. Because of the discussion list culture among developers, there is a tendency for even short emails to turn into long email chains. Unless you actually are on a mailing list whose purpose is to have longer discussions, this is a faux pas.&lt;/p&gt;

&lt;p&gt;It can be hard for any developer to resist a debate, particularly when someone has said something incorrect, or something inflammatory, about their favorite language or framework. But this is the chance to go with the better, non-email option.&lt;/p&gt;

&lt;p&gt;Here is an example email for those times when the debate is too big for email.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;From: Lovelace, Ada &amp;lt;alovelace@example.org&amp;gt;
Date: Monday, January 24, 2022 at 8:53 AM
To: Hamilton, Margaret &amp;lt;mhamilton@example.org&amp;gt;, 
Hopper, Grace &amp;lt;ghopper@example.org&amp;gt;
Subject: Re: Proposed HTTP client library 

Hi everyone,

Can we move this discussion to the Gitter room instead? 
It seems clear that we need to incorporate these points into 
the decision and the Gitter room is where we're getting 
everyone's feedback on it. Besides, a number of people who 
should be involved aren't on this email thread.

Thanks,

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

&lt;/div&gt;



&lt;p&gt;Furthermore, this is another reason not to include more than a single point in your email. If your email covers multiple, separate points, you will end up with a reply thread that is going off in all directions. And that means no one is getting any of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don't send it yet
&lt;/h2&gt;

&lt;p&gt;Done? Great! Now revise. Maybe even get a second pair of eyes on it. You should spend as much time revising it as you spent writing it, maybe even more. You only have one chance to get it right!&lt;/p&gt;

&lt;p&gt;Mark Twain famously remarked, "...if I had more time, I would have written a shorter letter." Long emails actually communicate less than short emails.&lt;/p&gt;

&lt;h2&gt;
  
  
  Send it!
&lt;/h2&gt;

&lt;p&gt;You've taken into account all of the above advice. You feel your email is perfect. It's going to get the right message across and do so effectively. Add your recipients, click send, and sit back knowing that you cut through the noise.&lt;/p&gt;

</description>
      <category>career</category>
      <category>productivity</category>
      <category>writing</category>
    </item>
    <item>
      <title>Toxic tech interviews still rampant</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Tue, 05 Apr 2022 16:48:43 +0000</pubDate>
      <link>https://dev.to/scottshipp/toxic-tech-interviews-still-rampant-4f7</link>
      <guid>https://dev.to/scottshipp/toxic-tech-interviews-still-rampant-4f7</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9zx43nrutwojzbott68.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq9zx43nrutwojzbott68.jpg" alt="Man sitting in an office chair looking at a woman writing on a white board"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.pexels.com/photo/man-sitting-on-an-office-chair-looking-at-the-woman-writing-on-a-white-board-5439484/" rel="noopener noreferrer"&gt;Photo by Tima Miroshnichenko from Pexels&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A tweet that is burning up my timeline today:&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1511061905158377476-774" src="https://platform.twitter.com/embed/Tweet.html?id=1511061905158377476"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1511061905158377476-774');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1511061905158377476&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;If that seems outrageous, wait until you read the avalanche of similar experiences in the thread's replies.&lt;/p&gt;

&lt;p&gt;Why is this so common, &lt;em&gt;still,&lt;/em&gt; in 2022? The tech industry has &lt;em&gt;always&lt;/em&gt; enabled jerks and it hasn't changed despite frequent calls for reform over the years. I have collected a folder full of bookmarks about similar issues for over a decade, and, yet, it doesn't seem to end.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.brendangregg.com/blog/2017-11-13/brilliant-jerks.html" rel="noopener noreferrer"&gt;Brilliant Jerks in Engineering&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://boz.com/articles/be-kind" rel="noopener noreferrer"&gt;Be Kind&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://lwn.net/Articles/641779/" rel="noopener noreferrer"&gt;The Programming Talent Myth&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href=""&gt;The Myth of the Sufficiently-Smart Engineer&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Almost as stark as the calls for our industry to do better, are the "Top 10" articles about how you might be a bad programmer, which neglect to mention any human relationship skills &lt;em&gt;at all&lt;/em&gt;, such as &lt;a href="http://www.yacoset.com/Home/signs-that-you-re-a-bad-programmer" rel="noopener noreferrer"&gt;Signs that you're a bad programmer&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's rare to find an essay that pushes back on technical skills in favor of "soft skills" like Austin Tindle's &lt;a href="https://medium.com/swlh/you-need-better-senior-software-developers-4c762950fe1" rel="noopener noreferrer"&gt;You need better programmers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I don't know how engineering managers and directors aren't fighting this invasive problem more. People shouldn't be in senior-and-above roles in engineering orgs if they are asshats. No one should have to write an article like &lt;a href="https://medium.com/s/office-politics/tricks-for-dealing-with-toxic-colleagues-fc19677300d6" rel="noopener noreferrer"&gt;Tricks for Dealing with Toxic Colleagues&lt;/a&gt; but, in fact, we have many of them.&lt;/p&gt;

&lt;p&gt;About interviews: the format of the typical tech interview itself sets up a power dynamic that is not productive. Not productive at all. If hiring is the goal, why is it that we put people in the stressful, alienating position of going into a strange room with no windows, that they've never been in, and then send a series of pairs of people in to grill them with questions and problems that don't even resemble the day-to-day work for a person in that position?&lt;/p&gt;

&lt;p&gt;Something needs to change. &lt;/p&gt;

&lt;p&gt;Dear tech industry: Do Better.&lt;/p&gt;

</description>
      <category>hiring</category>
      <category>interviewing</category>
      <category>tech</category>
    </item>
    <item>
      <title>Estimation is not impossible</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Wed, 23 Mar 2022 15:19:39 +0000</pubDate>
      <link>https://dev.to/scottshipp/estimation-is-not-impossible-3c6o</link>
      <guid>https://dev.to/scottshipp/estimation-is-not-impossible-3c6o</guid>
      <description>&lt;p&gt;We've all heard someone say something like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Estimation is impossible.&lt;/p&gt;

&lt;p&gt;What's the point in estimating?&lt;/p&gt;

&lt;p&gt;Every estimate is just a SWAG.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One of my early experiences as a professional software developer was when a project manager brought me aside and told me that the way to make estimates was by the following process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write down how long you think it will take. Example: Two weeks.&lt;/li&gt;
&lt;li&gt;Double it. Example: Four weeks.&lt;/li&gt;
&lt;li&gt;Increase the unit. Example: Four months.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is estimation?
&lt;/h2&gt;

&lt;p&gt;If all of these things are true, what even &lt;em&gt;is&lt;/em&gt; estimation? I think this unanswered question is core to the myth of "estimation is impossible." Whenever I am in a conversation about estimation, I always come away with the strong sense that everyone is talking about different things. One person says estimation is &lt;em&gt;possible&lt;/em&gt; because their company delivers to deadlines all the time, proving so. Another person is adamant that developers can't make estimates because too much is outside of their control or even outside of their knowledge. A third will say that software is an amorphous intangible abstraction so you can't estimate it.&lt;/p&gt;

&lt;p&gt;None of these people defined estimation. Is it a deadline (a date) when something is delivered? Does estimation inherently involve &lt;em&gt;knowing exactly what that something is&lt;/em&gt;? Is estimation inclusive of how many people, how much money, and for how long a company will work on one "thing?" &lt;/p&gt;

&lt;h2&gt;
  
  
  Estimation techniques
&lt;/h2&gt;

&lt;p&gt;Besides the lack of clarity, there's another problem I find in these conversations. They only involve the following estimation technique:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Sit down and stare at the wall for awhile, then write down how long you think it will take to deliver the functionality in question.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At best, people discuss "planning poker" or having a conversation among the entire team about the delivery of a feature. Besides just arbitrarily throwing out numbers, this is the only game in town.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learning to estimate
&lt;/h2&gt;

&lt;p&gt;Did you know that the average developer tenure of tech companies is &lt;a href="https://mobilemonkey.com/articles/employee-tenure-in-tech-companies"&gt;less than 2 years&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;I bet if you think of all the people you've ever worked with, the colleague who made the most accurate estimates was either someone who had worked at your company for a long time or someone who worked in the same general industry (maybe e-commerce or SaaS). &lt;/p&gt;

&lt;p&gt;This suggests that you can learn to estimate. &lt;/p&gt;

&lt;p&gt;It also suggests why no one knows how to estimate.&lt;/p&gt;

&lt;h2&gt;
  
  
  So how do you?
&lt;/h2&gt;

&lt;p&gt;Steve McConnell, the author of &lt;em&gt;Code Complete&lt;/em&gt;, also wrote an oft-ignored book called &lt;a href="https://www.microsoftpressstore.com/store/software-estimation-demystifying-the-black-art-9780735605350"&gt;Software Estimation: Demystifying the Black Art&lt;/a&gt;. It tells you exactly how to make good estimates. It defines what estimation is. It gives you more techniques than throwing numbers out. And it boils down to this: every organization can learn to estimate, if they actually kept data on their projects.&lt;/p&gt;

&lt;p&gt;McConnell writes the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The most important reason to use historical data from your own organization is that it improves estimation accuracy. The use of historical data, or “documented facts,” is negatively correlated with cost and schedule overruns—that is, projects that have been estimated using historical data tend not to have overruns (Lederer and Prasad 1992).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My bet is that no one reading this article has ever worked in an organization that has historical project data from their own organization at hand when they make estimates. I make this bet confidently based on my own experience at six large companies as well as the numerous conversations I've had with software professionals from dozens of other companies including Amazon, Microsoft, and Google.&lt;/p&gt;

&lt;p&gt;It sounds shocking that companies have ignored this simple practice, but they have.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ending on a low note
&lt;/h2&gt;

&lt;p&gt;If you would like to make better estimates, I highly recommend reading McConnell's book, because it &lt;em&gt;will&lt;/em&gt; help. Using even the simplest tools that McConnell covers like &lt;a href="https://en.wikipedia.org/wiki/Work_breakdown_structure"&gt;work-breakdown structures&lt;/a&gt; will improve your estimates. &lt;/p&gt;

&lt;p&gt;On the other hand, I have bad news. Since you're not likely to work in an organization that collects project data and makes it available to everyone, accurate estimation is effectively impossible, even if it is emphatically &lt;em&gt;not&lt;/em&gt; impossible.&lt;/p&gt;

&lt;p&gt;I wish you the best of luck.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>productivity</category>
      <category>projectmanagement</category>
    </item>
    <item>
      <title>Web Services 101: Why x00 status codes are so generic</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Fri, 14 Jan 2022 00:05:10 +0000</pubDate>
      <link>https://dev.to/scottshipp/web-services-101-why-x00-status-codes-are-so-generic-2fkd</link>
      <guid>https://dev.to/scottshipp/web-services-101-why-x00-status-codes-are-so-generic-2fkd</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Photo by picjumbo.com from Pexels&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Quick intro to HTTP status codes
&lt;/h2&gt;

&lt;p&gt;HTTP status codes are sent in every HTTP response to indicate the result of servicing the request.&lt;/p&gt;

&lt;p&gt;They are arranged into categories by 100's, as follows:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code range&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;200-299&lt;/td&gt;
&lt;td&gt;Success&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;300-399&lt;/td&gt;
&lt;td&gt;Redirection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;400-499&lt;/td&gt;
&lt;td&gt;Client error&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;500-599&lt;/td&gt;
&lt;td&gt;Server error&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A useful reference to bookmark is &lt;a href="https://httpstatuses.com/"&gt;https://httpstatuses.com&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  x00 status codes
&lt;/h2&gt;

&lt;p&gt;Now let's look closer at the definition of each x00 status code.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.1"&gt;200&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;OK&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.1"&gt;300&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Multiple Choices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.1"&gt;400&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Bad Request&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1"&gt;500&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Internal Server Error&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Why do you think these are so generic like "Bad Request," "OK," or the even more vague "Multiple Choices?"&lt;/p&gt;

&lt;h2&gt;
  
  
  Explanation
&lt;/h2&gt;

&lt;p&gt;The vagueness is on purpose. These codes are supposed to cover all possibilities. The HTTP specification describes them as the "stand in" codes for those situations where a &lt;em&gt;custom HTTP status code&lt;/em&gt; has been defined by the service, and the client needs to interpret the response anyway.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;HTTP status codes are extensible. HTTP applications are not required to understand the meaning of all registered status codes, though such understanding is obviously desirable. However, applications MUST understand the class of any status code, as indicated by the first digit, and treat any unrecognized response as being equivalent to the x00 status code of that class...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.rfc-editor.org/rfc/rfc2616#section-6.1.1"&gt;RFC2616&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;p&gt;So we can conclude two things. &lt;/p&gt;

&lt;p&gt;First: we can create our own custom HTTP status codes. Maybe we want to pick the unused status code &lt;code&gt;442&lt;/code&gt; and define it as   "&amp;lt;SomeProperty&amp;gt; is required." That's totally fine. &lt;/p&gt;

&lt;p&gt;Second: we can also conclude that our clients will interpret our custom HTTP status codes as their x00 counterpart. For the given example of &lt;code&gt;442&lt;/code&gt;, clients will assume this is equivalent to &lt;code&gt;400&lt;/code&gt; "Bad Request."&lt;/p&gt;

</description>
      <category>programming</category>
      <category>web</category>
    </item>
    <item>
      <title>IntelliJ Hacks: Copy paste history and plain text paste</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Wed, 22 Dec 2021 22:25:43 +0000</pubDate>
      <link>https://dev.to/scottshipp/intellij-hacks-copy-paste-history-and-plain-text-paste-4k81</link>
      <guid>https://dev.to/scottshipp/intellij-hacks-copy-paste-history-and-plain-text-paste-4k81</guid>
      <description>&lt;p&gt;In our previous articles, we covered various IntelliJ features that you may not know about the first year that you use IntelliJ.&lt;/p&gt;

&lt;p&gt;Today's hack is one that I definitely wasn't aware of for quite some time after starting to regularly use IntelliJ, and that's the copy/paste history and plain-text paste option. IntelliJ calls this feature &lt;em&gt;Choose content to paste&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hack
&lt;/h2&gt;

&lt;p&gt;To access this feature, simply hold Shift while you press either Ctrl + V (Linux and Windows) or Cmd + V (Mac). This will display a dialog that allows you to choose any prior copied text to paste. It also gives you the option to paste as plain text!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cQw2Nt0k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rte85yh8fl21eciutmno.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cQw2Nt0k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rte85yh8fl21eciutmno.png" alt="IntelliJ IDEA Choose Content to Paste" width="527" height="579"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final tip
&lt;/h2&gt;

&lt;p&gt;Don't forget that you will find many gems like this in IntelliJ IDEA by going to the help menu and selecting "Keyboard Shortcuts PDF" which gives you a nice cheat sheet of IntelliJ keyboard shortcuts! &lt;/p&gt;

&lt;p&gt;Awesome!&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Introducing todos in noted cli v0.0.3</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Wed, 15 Dec 2021 15:13:37 +0000</pubDate>
      <link>https://dev.to/scottshipp/introducing-todos-in-noted-cli-v003-2ph6</link>
      <guid>https://dev.to/scottshipp/introducing-todos-in-noted-cli-v003-2ph6</guid>
      <description>&lt;p&gt;&lt;em&gt;If you're new to &lt;a href="https://github.com/scottashipp/noted" rel="noopener noreferrer"&gt;noted&lt;/a&gt;, there's a great introduction here:&lt;/em&gt;&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/scottshipp" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F38444%2Fd59c5288-49e2-45aa-9dd1-7c80deab3b89.jpg" alt="scottshipp"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/scottshipp/an-amazing-note-taking-system-with-markdown-and-git-part-1-48b1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;An amazing note-taking system with Markdown and Git, Part 1&lt;/h2&gt;
      &lt;h3&gt;scottshipp ・ Oct 19 '21&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#learning&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;h2&gt;
  
  
  Introducing the &lt;code&gt;todos&lt;/code&gt; subcommand!
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/scottashipp/noted/releases/tag/v0.0.3" rel="noopener noreferrer"&gt;Version 0.0.3 of the noted cli&lt;/a&gt; is out now, and introduces a new subcommand, &lt;code&gt;todos&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The todos command lists your todos.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;noted todos
/Users/jsmith/Documenents/notes/2021-12-06:todo Send out Christmas cards
/Users/jsmith/Documenents/notes/2021-12-08:todo Read Termination Shock, Jane recommended it
/Users/jsmith/Documenents/notes/2021-12-15:todo Pick up milk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also configure any text string as a marker for todo notes. You can set the text string that is used in your &lt;code&gt;.notedconfig&lt;/code&gt; file with the &lt;code&gt;NOTED_TODO_MARKER&lt;/code&gt; variable. &lt;/p&gt;

&lt;p&gt;For example, I've set my personal marker to this emoji: ✳️.&lt;/p&gt;

&lt;p&gt;You can read more about it in the &lt;a href="https://github.com/scottashipp/noted/blob/main/subcommands.md#todos" rel="noopener noreferrer"&gt;todo subcommand reference&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Speaking of which, the documentation has been improved, so take a peek at the &lt;a href="https://github.com/scottashipp/noted" rel="noopener noreferrer"&gt;README file&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm reminded that v0.0.2 has a &lt;code&gt;grep&lt;/code&gt; subcommand too, which I forgot to post on here. You can learn more about that &lt;a href="https://github.com/scottashipp/noted/blob/main/subcommands.md#grep" rel="noopener noreferrer"&gt;in the docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>unix</category>
      <category>shell</category>
    </item>
    <item>
      <title>Build a next-level RESTful web service with Spring Boot</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Wed, 08 Dec 2021 15:36:15 +0000</pubDate>
      <link>https://dev.to/scottshipp/build-a-next-level-restful-web-service-with-spring-boot-20d4</link>
      <guid>https://dev.to/scottshipp/build-a-next-level-restful-web-service-with-spring-boot-20d4</guid>
      <description>&lt;p&gt;The easiest way to learn how to use Spring Boot is hands-on with the &lt;a href="https://spring.io/guides/gs/rest-service/"&gt;Building a RESTful Web Service in Spring Boot Quickstart&lt;/a&gt; found on the Spring Boot web site.&lt;/p&gt;

&lt;p&gt;In this post, we build on top of the result in order to take it to the next level!&lt;/p&gt;

&lt;p&gt;So before you continue, please go through the Quickstart and then come back to here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the next level
&lt;/h2&gt;

&lt;p&gt;At this point you have a Spring Boot-based RESTful web service running on your machine. You can visit &lt;a href="http://localhost:8080/greeting"&gt;http://localhost:8080/greeting&lt;/a&gt; and you will see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also visit &lt;a href="http://localhost:8080/greeting?name=User"&gt;http://localhost:8080/greeting?name=User&lt;/a&gt; and you will see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Hello, User!"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, wouldn’t it be nice to be able to change the greeting? Instead of, “Hello, User!” what if it could say something like any of these examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Greetings, User!&lt;/li&gt;
&lt;li&gt;Welcome, User!&lt;/li&gt;
&lt;li&gt;Good Afternoon, User!&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Adding a PUT
&lt;/h2&gt;

&lt;p&gt;In order to change the greeting, we will use the PUT HTTP verb. It’s important to use the right verb when making RESTful web services, and PUT is typically what is used to &lt;a href="https://www.restapitutorial.com/lessons/httpmethods.html"&gt;update an existing resource&lt;/a&gt;. Since we can GET the /greeting resource right now, changing it will be an update rather than a create, and PUT is what we should use.&lt;/p&gt;

&lt;p&gt;The PUT cannot be made easily with a web browser. Instead we will use the useful &lt;a href="https://curl.haxx.se/"&gt;cURL command-line utility&lt;/a&gt;. Here is the cURL command that we can use. This can be executed within a terminal window.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; PUT &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nv"&gt;template&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Welcome'&lt;/span&gt; localhost:8080/greeting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, this won’t work yet! But we will make it work in a moment below.&lt;/p&gt;

&lt;p&gt;First, let me quickly explain, what the curl will do:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We start by calling curl&lt;/li&gt;
&lt;li&gt;We pass “-X PUT” to tell it to make a put command&lt;/li&gt;
&lt;li&gt;We pass “-d template=’Welcome'” in order to pass the “data” for the PUT command, and the data we pass is the new template String, passed as a key value pair.&lt;/li&gt;
&lt;li&gt;Finally we supply the resource, “localhost:8080/greeting”&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Preparing the existing code
&lt;/h2&gt;

&lt;p&gt;Right now the existing GreetingController.java in the project only has a “GetMapping.” As you may have guessed, we will add a “PutMapping.” Since both will use the underlying logic to construct a “Greeting” and return it, we should do a slight refactor before adding the PutMapping. The refactor accomplishes the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change the method that is currently annotated with the GetMapping to call a separate private method to get the result.&lt;/li&gt;
&lt;li&gt;Change the template variable in the class to be a member of the class that can be changed, by removing the final keyword.&lt;/li&gt;
&lt;li&gt;Also, let’s stop using String.format because it will be confusing for people using our service to have to use Java-specific String formatting. Besides, the “%” symbol that is used will be confusing at best and a problem at worst since it is used in URIs to mean something else. So refactor the new private method to just use normal Java String concatenation. This way the “template” can be one of our previously mentioned options like “Welcome” or “Greeting” and the rest of the greeting can be constructed from the supplied name.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We end up with the following class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.scottshipp.code.restservice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.GetMapping&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.RequestParam&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.RestController&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.concurrent.atomic.AtomicLong&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@RestController&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;GreetingController&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;AtomicLong&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AtomicLong&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="nd"&gt;@GetMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/greeting"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;greeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@RequestParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;defaultValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"World"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Greeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;incrementAndGet&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;", "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you’ve made that refactor, it’s a good idea to pause at this point, rebuild the project, run it, and test it to see if it still performs the desired functionality. You can follow the section titled “Test the service” in the &lt;a href="https://spring.io/guides/gs/rest-service/"&gt;original tutorial&lt;/a&gt; to test this. When you are done, stop the service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding a PUT mapping
&lt;/h2&gt;

&lt;p&gt;Next, we will add a new method that sets a new value for the template variable.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Greeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;incrementAndGet&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;", "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since this duplicates the existing method somewhat, we can refer to the new method but preserve the existing behavior:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we just need a method to handle a PUT request. It iwll be annotated with “@PutMapping.” The new method looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@PutMapping&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ResponseEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Greeting&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"World"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply by annotating this method with “@PutMapping(“/greeting”)” will now allow your web service to accept a PUT request at that URI. Because the variable the method takes is a String called “template,” the curl command we issue will pass data in the “-d” flag with the key name “template.”&lt;/p&gt;

&lt;p&gt;After you’ve added the above method to your controller class, it should now look like this new full class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.scottshipp.code.restservice&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.http.ResponseEntity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.GetMapping&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.PutMapping&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.RequestParam&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.web.bind.annotation.RestController&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.concurrent.atomic.AtomicLong&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@RestController&lt;/span&gt;
&lt;span class="nd"&gt;@RequestMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/greeting"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;GreetingController&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;AtomicLong&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AtomicLong&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="nd"&gt;@GetMapping&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;greeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@RequestParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;defaultValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"World"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@PutMapping&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ResponseEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Greeting&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"World"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt; &lt;span class="nf"&gt;customizeGreeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Greeting&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;incrementAndGet&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;", "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Test the service
&lt;/h2&gt;

&lt;p&gt;Now run the service according to the Test the service section of the &lt;a href="https://spring.io/guides/gs/rest-service/"&gt;original tutorial&lt;/a&gt;. While the service is running, issue the curl command in a separate terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; PUT &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nv"&gt;template&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'Greetings'&lt;/span&gt; localhost:8080/greeting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the same response you would have seen with a GET request, only now using the new template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Greetings, World"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you issue any subsequent GET requests, you will find that the greeting will use the new template.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl localhost:8080/greeting?name&lt;span class="o"&gt;=&lt;/span&gt;Earthlings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Greetings, Earthlings"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Congratulations
&lt;/h2&gt;

&lt;p&gt;Congratulations! You just took your RESTful web service building skills in Spring Boot to the next level! Consider trying to add another HTTP verb like POST to your controller.&lt;/p&gt;

</description>
      <category>java</category>
      <category>spring</category>
      <category>springboot</category>
    </item>
    <item>
      <title>Java Pitfalls: Misuse of types</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Tue, 07 Dec 2021 20:25:46 +0000</pubDate>
      <link>https://dev.to/scottshipp/java-pitfalls-misuse-of-types-1i</link>
      <guid>https://dev.to/scottshipp/java-pitfalls-misuse-of-types-1i</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Photo by Gratisography from Pexels&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Java is a great language but it can really &lt;em&gt;bite you&lt;/em&gt; if you don't watch out! Here's the second installment of a series of helpful &lt;em&gt;things to watch out for in Java&lt;/em&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  😰 Today's Pitfall
&lt;/h2&gt;

&lt;p&gt;Today's pitfall is &lt;em&gt;misusing types.&lt;/em&gt; It includes a variety of poor coding practices that can range from blatantly outrageous to rather subtle, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://blog.frankel.ch/coping-stringly-typed/"&gt;Stringly-typed code&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;em&gt;null&lt;/em&gt; value being used to mean something important&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using primitive types to represent complex objects&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;And more!&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll cover examples in the "Where you'll see it" section below.&lt;/p&gt;

&lt;p&gt;Because these practices are widespread, and they manifest in various ways, it can be hard to notice them!&lt;/p&gt;

&lt;p&gt;Beware!&lt;/p&gt;

&lt;h2&gt;
  
  
  🤔 Why it happens
&lt;/h2&gt;

&lt;p&gt;Generally, inexperienced developers are more prone to the misuse of types than experienced developers. But this is not always true. Sometimes you will find whole teams, or even companies, widely using poor practices in Java, due to having previously used another language.&lt;/p&gt;

&lt;h2&gt;
  
  
  👀 Where you'll see it
&lt;/h2&gt;

&lt;p&gt;Here are just a few common examples of the misuse of types!&lt;/p&gt;

&lt;h3&gt;
  
  
  Stringly-typed code
&lt;/h3&gt;

&lt;p&gt;Can a String hold an address? A car? A book? Yes...&lt;/p&gt;

&lt;p&gt;How about JSON? A database record? A line from a CSV file? An entire CSV file? &lt;/p&gt;

&lt;p&gt;Yes! All this and more!&lt;/p&gt;

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

&lt;p&gt;Please! Don't do that as a matter of course. 🤦&lt;/p&gt;

&lt;p&gt;Not only are there far better ways to represent any of these things or formats, but also code becomes quite prone to bugs like "wrong-order" bugs. &lt;/p&gt;

&lt;p&gt;Here's a quick example with not one, but two, bugs!&lt;/p&gt;

&lt;p&gt;A method signature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;NotificationResult&lt;/span&gt; &lt;span class="nf"&gt;notifyUser&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;address&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a buggy usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="n"&gt;notifyUser&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"jdoe2021"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Your subscription is about to expire."&lt;/span&gt; &lt;span class="s"&gt;"5551231212"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What are the bugs?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first is a "wrong-order" bug where the supplied parameters are in (you guessed it) the wrong order.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second is that the value supplied for message type, &lt;code&gt;text&lt;/code&gt;, does not match the expected value for that type, &lt;code&gt;SMS&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Onward! To yet more examples!&lt;/p&gt;

&lt;h3&gt;
  
  
  Null as a meaningful value
&lt;/h3&gt;

&lt;p&gt;An ecommerce site needs to represent that items are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;currently in-stock&lt;/li&gt;
&lt;li&gt;currently &lt;em&gt;not&lt;/em&gt; in-stock&lt;/li&gt;
&lt;li&gt;backordered&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;OK. Makes sense to use a Boolean, &lt;code&gt;backordered&lt;/code&gt;, which means the following, right?&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;true&lt;/td&gt;
&lt;td&gt;backordered&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;in-stock now&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;null&lt;/td&gt;
&lt;td&gt;neither in-stock nor backordered&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Wrong! The cringe is high. Please never do this  (or anything like it). &lt;/p&gt;

&lt;p&gt;Yet, it's amazing how frequent you will see code like this, even in public libraries. &lt;/p&gt;

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

&lt;h3&gt;
  
  
  Using simple types to represent complex objects
&lt;/h3&gt;

&lt;p&gt;Final example so that we don't go too long. But keep in mind these examples are literally only three of the most common ways to misuse types. There are so many more!&lt;/p&gt;

&lt;p&gt;This example is really too common: using floats to represent &lt;em&gt;money&lt;/em&gt;. It is so common, that &lt;a href="http://www.javapractices.com/topic/TopicAction.do?Id=13"&gt;JavaPractices has a whole article about it&lt;/a&gt;. You can read what they have to say, and why its a problem, over there.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ How to fix it
&lt;/h2&gt;

&lt;p&gt;There is an easy and reliable cure for the misuse of types in Java.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Complete the &lt;a href="https://docs.oracle.com/javase/tutorial/"&gt;Java tutorials&lt;/a&gt; for all trails covering the basics.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Learn and know the standard libraries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Read &lt;a href="https://www.pearson.com/store/p/effective-java/P100000841083/9780134685991"&gt;Effective Java&lt;/a&gt;. (This is a link to the publisher's site, and is not an affiliate link! I have no association to the publisher or the author. It's just a good, universally-respected book.)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Homework
&lt;/h2&gt;

&lt;p&gt;I think the homework is everything just listed under "How to fix it" above. &lt;/p&gt;

&lt;p&gt;But I have one more request:&lt;/p&gt;

&lt;p&gt;I'd love to hear some of the "misuses of types" that you have experienced in the comments below.&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>But is remote work equitable?</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Wed, 01 Dec 2021 17:10:19 +0000</pubDate>
      <link>https://dev.to/scottshipp/but-is-remote-work-equitable-1lcf</link>
      <guid>https://dev.to/scottshipp/but-is-remote-work-equitable-1lcf</guid>
      <description>&lt;p&gt;Remote work is supposed to be "the future of work," but it has me wondering, &lt;em&gt;Is remote work equitable?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Not everyone has the same working conditions. Internet connection? Heat? Noise? Ergonomics? Videoconferencing quality?&lt;/p&gt;

&lt;p&gt;I think remote work is great but I'd like to see us discuss how to even the playing field of remote work a bit more.&lt;/p&gt;

&lt;p&gt;Thoughts?&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>discuss</category>
    </item>
    <item>
      <title>IntelliJ Hacks: Save Run Configurations to Source Control</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Wed, 24 Nov 2021 15:19:48 +0000</pubDate>
      <link>https://dev.to/scottshipp/intellij-hacks-save-run-configurations-to-source-control-nlh</link>
      <guid>https://dev.to/scottshipp/intellij-hacks-save-run-configurations-to-source-control-nlh</guid>
      <description>&lt;p&gt;We've already covered &lt;a href="https://dev.to/scottshipp/two-ways-to-integrate-javadoc-into-intellij-idea-leb"&gt;instant Javadoc&lt;/a&gt;, &lt;a href="https://dev.to/scottshipp/prettify-json-with-intellij-scratch-files-pna"&gt;prettifying JSON&lt;/a&gt;, and &lt;a href="https://dev.to/scottshipp/column-selection-simultaneous-multi-line-editing-with-intellij-2ddn"&gt;multi-line editing&lt;/a&gt;, all within IntelliJ. Now let's cover &lt;a href="https://www.jetbrains.com/help/idea/run-debug-configuration.html#share-configurations" rel="noopener noreferrer"&gt;shared run configurations&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you've been an IntelliJ user for some time, you've probably collected quite a few of your own run configurations. What is a run configuration? It's simply a collection of metadata about a run of any kind. It could the metadata for creating a Docker image, running a web service, running a suite of tests, or something else entirely.&lt;/p&gt;

&lt;p&gt;Your run configurations always appear at the top of your screen with a green "play" (triangle) button next to them.&lt;/p&gt;

&lt;p&gt;They look like this, when you click the dropdown box:&lt;/p&gt;

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

&lt;p&gt;They get &lt;a href="https://www.jetbrains.com/help/idea/run-debug-configuration.html#created-permanent" rel="noopener noreferrer"&gt;created in various ways&lt;/a&gt;, but the most common way is simply clicking that little green play button when you see it in the left margin next to some code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hack
&lt;/h2&gt;

&lt;p&gt;Now, for the hack. Most people don't know that you can save these run configurations to files, and check them into source control! That way they can be shared among a team. This is actually a very &lt;a href="https://www.jetbrains.com/help/idea/run-debug-configuration.html#created-permanent" rel="noopener noreferrer"&gt;simple thing to set up&lt;/a&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to "Edit configurations" in the Run configurations dropdown.&lt;/li&gt;
&lt;li&gt;Navigate to the run configuration you would like to save.&lt;/li&gt;
&lt;li&gt;Check the "Store as project file" box.&lt;/li&gt;
&lt;li&gt;Commit it to your source control the normal way.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;More information about this is &lt;a href="https://www.jetbrains.com/help/idea/run-debug-configuration.html#created-permanent" rel="noopener noreferrer"&gt;documented in the help&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final tip
&lt;/h2&gt;

&lt;p&gt;Don't forget to scrub any secrets out of your run configurations before you check them in. A good way to do this is to replace them with environment variables. &lt;/p&gt;

&lt;p&gt;Now go share those things with each other and save your team some time!&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Java Pitfalls: Unboxing null Booleans</title>
      <dc:creator>scottshipp</dc:creator>
      <pubDate>Fri, 19 Nov 2021 18:00:03 +0000</pubDate>
      <link>https://dev.to/scottshipp/java-pitfalls-unboxing-null-booleans-1agj</link>
      <guid>https://dev.to/scottshipp/java-pitfalls-unboxing-null-booleans-1agj</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Photo by Vlad Bagacian from Pexels&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Java is a great language but it can really &lt;em&gt;bite you&lt;/em&gt; if you don't watch out! Here's the first installment of a series of helpful &lt;em&gt;things to watch out for in Java&lt;/em&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  😰 Today's Pitfall
&lt;/h2&gt;

&lt;p&gt;The following code sometimes throws a &lt;code&gt;NullPointerException&lt;/code&gt;. Can you guess why?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;checkIfDelivered&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;wasDelivered&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's hard to imagine a &lt;code&gt;NullPointerException&lt;/code&gt; happening here, isn't it? Considering the &lt;code&gt;null&lt;/code&gt; check?&lt;/p&gt;

&lt;p&gt;Yet, here is the exception you may see from Java code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Exception in thread "main" java.lang.NullPointerException
    at com.company.MyClass.checkIfDelivered(MyClass.java:20)
    at com.company.MyClass.main(MyClass.java:13)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OK so it's actually impossible to see the problem without another piece of vital information. Here's part of the &lt;code&gt;Food&lt;/code&gt; interface you should know about.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Boolean&lt;/span&gt; &lt;span class="nf"&gt;wasDelivered&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🤔 Why it happens
&lt;/h2&gt;

&lt;p&gt;This all has to do with conflicting types. The return type of &lt;code&gt;Food.wasDelivered()&lt;/code&gt; is &lt;code&gt;Boolean&lt;/code&gt;, with a capital "B." But the return type of the &lt;code&gt;checkIfDelivered()&lt;/code&gt; method is &lt;code&gt;boolean&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Yes, that's right: it's all because of one letter. 😆&lt;/p&gt;

&lt;p&gt;Well, that's not entirely fair. There's a lot more to it than a letter: &lt;code&gt;boolean&lt;/code&gt; is a &lt;a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html"&gt;&lt;em&gt;primitive type&lt;/em&gt;&lt;/a&gt; in Java, whereas &lt;code&gt;Boolean&lt;/code&gt; is a special class called a "wrapper class."&lt;/p&gt;

&lt;p&gt;Primitive types in Java are represented by reserved keywords like &lt;code&gt;boolean&lt;/code&gt;,  &lt;code&gt;int&lt;/code&gt;, and &lt;code&gt;char&lt;/code&gt;. Notice that they are always shortened and lowercased.&lt;/p&gt;

&lt;p&gt;Every primitive can be "wrapped" in a corresponding Java class called a "wrapper class." Each wrapper class is capitalized according to Java's class naming convention and lengthened to its full name. &lt;code&gt;int&lt;/code&gt; becomes &lt;code&gt;Integer&lt;/code&gt;, &lt;code&gt;char&lt;/code&gt; becomes &lt;code&gt;Character&lt;/code&gt;, and &lt;code&gt;boolean&lt;/code&gt; becomes &lt;code&gt;Boolean&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Java tutorial explains it this way:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;…the Java platform provides wrapper classes for each of the primitive data types. These classes "wrap" the primitive in an object. Often, the wrapping is done by the compiler—if you use a primitive where an object is expected, the compiler boxes the primitive in its wrapper class for you. Similarly, if you use a number object when a primitive is expected, the compiler unboxes the object for you.&lt;/p&gt;

&lt;p&gt;—From the &lt;a href="https://docs.oracle.com/javase/tutorial/java/data/numberclasses.html"&gt;Oracle Java Tutorial&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;By the way, it is more common to use the terms "boxing" and "unboxing" instead of "wrapping" and "unwrapping." You can read more about autoboxing in &lt;a href="https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html"&gt;the Java tutorial&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The automatic "unboxing" of a &lt;code&gt;Boolean&lt;/code&gt; to a &lt;code&gt;boolean&lt;/code&gt; is exactly the problem with the code snippet above! The &lt;code&gt;food.wasDelivered()&lt;/code&gt; method returns a &lt;code&gt;Boolean&lt;/code&gt; object, which means it can also return &lt;code&gt;null&lt;/code&gt;. The &lt;code&gt;checkIfDelivered&lt;/code&gt; method returns a primitive &lt;code&gt;boolean&lt;/code&gt;, which means if you try and return &lt;code&gt;food.wasDelivered()&lt;/code&gt; the compiler attempts to unbox it.&lt;/p&gt;

&lt;p&gt;And…BOOM! 💥 When it is null, a &lt;code&gt;NullPointerException&lt;/code&gt; results.&lt;/p&gt;

&lt;h2&gt;
  
  
  👀 Where you'll see it
&lt;/h2&gt;

&lt;p&gt;It's common these days to retrieve data over the network from web services. When that happens, the response is usually in a format like JSON, which does not have the same "primitive" types as Java.&lt;/p&gt;

&lt;p&gt;It may be common for the JSON representation of a &lt;code&gt;Food&lt;/code&gt; to look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;wasDelivered:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Null is an entirely valid value in the &lt;a href="https://www.json.org/json-en.html"&gt;JSON schema&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Or it may just be missing altogether, like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In either of these cases, most Java developers will use a JSON-to-Java conversion library, such as &lt;a href="https://github.com/FasterXML/jackson"&gt;Jackson&lt;/a&gt;, to map the JSON object to a Java object. These libraries can be configured to default the value of &lt;code&gt;wasDelivered&lt;/code&gt; on the resulting Java object to &lt;code&gt;false&lt;/code&gt; or &lt;code&gt;true&lt;/code&gt;, but more often either of the above cases will just result in the value being &lt;code&gt;null&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;If the resulting object is a &lt;code&gt;Food&lt;/code&gt; object like in our example code, you now know what will happen. 😈&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ How to fix it
&lt;/h2&gt;

&lt;p&gt;It's considered a best practice to prefer the use of primitive types in Java because of the performance overhead that comes from autoboxing. So, if you can, avoid the problem rather than fixing it. Use &lt;code&gt;boolean&lt;/code&gt; throughout your code and then you won't have to think that much about what happens if the JVM attempts to box or unbox a value.&lt;/p&gt;

&lt;p&gt;But, as you can see from the above example of a JSON response being mapped to a Java object, you're not going to be able to avoid it in some cases. It may even be preferable in our Food example that &lt;code&gt;wasDelivered&lt;/code&gt; is stored as a &lt;code&gt;Boolean&lt;/code&gt;, because it may be useful as a way to know that the value was &lt;code&gt;null&lt;/code&gt; or missing in the JSON response.&lt;/p&gt;

&lt;p&gt;So that means you just need to exercise your due diligence when retrieving the value.&lt;/p&gt;

&lt;p&gt;The offending method can be rewritten just slightly as follows, and all will be well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;checkIfDelivered&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;wasDelivered&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;wasDelivered&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You may find that you write a lot of boilerplate methods like the above. In that case, wouldn't it be nice to have a utility to use instead? The popular &lt;a href="http://commons.apache.org/proper/commons-lang/"&gt;Apache Commons Lang&lt;/a&gt; library has the exact thing you need. &lt;/p&gt;

&lt;p&gt;It's called &lt;a href="http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/BooleanUtils.html"&gt;&lt;code&gt;BooleanUtils&lt;/code&gt;&lt;/a&gt; and has two nice methods you should be aware of. The first, &lt;a href="http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/BooleanUtils.html#toBoolean-java.lang.Boolean-"&gt;&lt;code&gt;toBoolean&lt;/code&gt;&lt;/a&gt;, translates the wrapper &lt;code&gt;Boolean&lt;/code&gt; to false if it has a null value. The second, &lt;a href="http://commons.apache.org/proper/commons-lang/javadocs/api-release/org/apache/commons/lang3/BooleanUtils.html#toBooleanDefaultIfNull-java.lang.Boolean-boolean-"&gt;&lt;code&gt;toBooleanDefaultIfNull&lt;/code&gt;&lt;/a&gt;, lets you explicitly define the behavior, meaning you can default to &lt;code&gt;true&lt;/code&gt; if that makes more sense for your case.&lt;/p&gt;

&lt;p&gt;Here is our offending method rewritten with &lt;code&gt;toBoolean&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;checkIfDelivered&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Food&lt;/span&gt; &lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;BooleanUtils&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toBoolean&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;food&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;wasDelivered&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Homework
&lt;/h2&gt;

&lt;p&gt;Now that you know a little more about autoboxing, don't forget to read the &lt;a href="https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html"&gt;Java tutorial&lt;/a&gt; to learn more.&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
