<?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: Himashi Hettege Dona</title>
    <description>The latest articles on DEV Community by Himashi Hettege Dona (@himashi99).</description>
    <link>https://dev.to/himashi99</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%2F65468%2F30a4a9b3-f6f4-4560-8f78-2302a4d19ea7.jpg</url>
      <title>DEV Community: Himashi Hettege Dona</title>
      <link>https://dev.to/himashi99</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/himashi99"/>
    <language>en</language>
    <item>
      <title>How To Build Your First Chrome Extension</title>
      <dc:creator>Himashi Hettege Dona</dc:creator>
      <pubDate>Thu, 31 May 2018 14:49:35 +0000</pubDate>
      <link>https://dev.to/himashi99/how-to-build-your-first-chrome-extension-19lb</link>
      <guid>https://dev.to/himashi99/how-to-build-your-first-chrome-extension-19lb</guid>
      <description>&lt;h3&gt;Changing the Web, One Puppy Image at a Time&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fc8q64tgpqsalyen1tpv2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fc8q64tgpqsalyen1tpv2.jpg" alt="Riley" width="432" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s talk about browser extensions, or more specifically how to build your first Chrome extension. I went to a class a few weeks ago where we had a lot of fun creating this very silly extension with a few lines of code. I thought I would share it, so you all can try it out and maybe even expand on it.&lt;/p&gt;

&lt;h3&gt;What is a Browser Extension&lt;/h3&gt;

&lt;p&gt;Before we get started, let’s review what browser extensions are. Browser extensions are really just short pieces of code that provide some extra functionality to a browser. You’re probably using a few right now such as an Ad Blocker or a Password Manager. Google has a whole store of really useful and fun Chrome extensions that people have built to enhance the web browsing experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://chrome.google.com/webstore/category/extensions" rel="noopener noreferrer"&gt;https://chrome.google.com/webstore/category/extensions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For today, we’ll be creating an extension that targets all images on a webpage, and replaces them with pictures of puppies!&lt;/p&gt;

&lt;h3&gt;Folder Structure&lt;/h3&gt;

&lt;p&gt;To get started:&lt;/p&gt;

&lt;p&gt;Clone the following repo locally to grab the starter files: &lt;a href="https://github.com/himashi99/chrome-extension" rel="noopener noreferrer"&gt;https://github.com/himashi99/chrome-extension&lt;/a&gt;&lt;/p&gt;

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

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Your folder structure should resemble the above.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I’ve included the “poop” emoji for you in the image folder, but feel free to use 3. any image icon you would like.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The Manifest File is a JSON file that describes our extension to Chrome. It is where we specify important information about our extension, such as permissions it needs or icons it uses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Include the below code in your “manifest.json” file.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{   
    "name": "Yay Chrome!", 
    "version": "1.2", 
    "description": "First project to build a fresh chrome  extension", 
    "manifest_version": 2,
"permissions": ["activeTab", "declarativeContent"],
"icons": {
      "16": "images/poop_16.png",
      "32": "images/poop_32.png",
      "48": "images/poop_48.png",
      "128": "images/poop_128.png"
    },
"page_action": { 
      "default_icon": {
        "16": "images/poop_16.png",
        "32": "images/poop_32.png",
        "48": "images/poop_48.png",
        "128": "images/poop_128.png"
      }
    },
"background": {
      "scripts": ["scripts.js"],
      "persistent": false
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down the above code:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We need to give our extension a name, version number, and a short description.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The current manifest_versions is 2 so leave this as is.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The “activeTab” permission allows access to the current tab the user is on. The “declarativeContent” permission allows the extension to be aware when a tab is changed, or a new webpage is visited.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We import image icons of varying sizes so our extension is responsive on different screen sizes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The “pageAction” places the icon in the Chrome toolbar and represents an action that can be taken on a current webpage i.e. button is clickable.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the final code block, background scripts are loaded when needed and listens for, and manages events. Persistent is set to “false” so that background scripts are unloaded once they have completed their action.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In this case, the Manifest file instructs that “scripts.js” file should be loaded. We will be coming back to “scripts.js” and “main.js” files shortly.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;Chrome Setup&lt;/h3&gt;

&lt;p&gt;Open up Chrome and go into the Extension Manager&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgbqghutrod2kpsnrlpwr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fgbqghutrod2kpsnrlpwr.png" alt="Extension Manaer" width="800" height="603"&gt;&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;We need to let Chrome know we’re badass developers, so let’s turn on the “Developer Mode” at the top right corner. This will allow us to load our own extensions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F75kouk073kpdou8r6ia9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F75kouk073kpdou8r6ia9.png" alt="Developer Mode" width="800" height="69"&gt;&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Click on “Load Unpacked” and select your “chrome-extension” folder.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxo881688wmpo5e0wblvq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxo881688wmpo5e0wblvq.png" alt="Load Extension" width="800" height="101"&gt;&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;Alright! We have now loaded our extension in. You should see the extension in the extension manager, and the icon in the Google Chrome Toolbar. The icon will be greyed out and inactive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fn2oywd6iukv8q24cxf3i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fn2oywd6iukv8q24cxf3i.png" alt="Extension Icon" width="492" height="236"&gt;&lt;/a&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;If you do make any changes to the JSON file at this point, you can hit the refresh button on your extension.&lt;/p&gt;

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

&lt;h3&gt;scripts.js File&lt;/h3&gt;

&lt;p&gt;It’s time to activate the icon , and in order to do that, we need to link the button to our “scripts.js” file.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Include the below code blocks in your “scripts.js” file.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
   chrome.declarativeContent.onPageChanged.addRules([{
     conditions: [new chrome.declarativeContent.PageStateMatcher({
       pageUrl: {schemes: ['https', 'http']},
     })
     ],
         actions: [new chrome.declarativeContent.ShowPageAction()]
   }]);
 });


chrome.pageAction.onClicked.addListener(function() {
   chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
     chrome.tabs.executeScript(
       tabs[0].id, 
       {file: 'main.js'}
     );
   });
 });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down the above code:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First Code Block:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Going back to the Manifest File for a second, remember that we specified permissions for activeTab and declarativeContent? Well this lets us use the Chrome APIs (“chrome.declarativeContent”), which then allows our extension to take actions depending on the content of a webpage, without asking for host permission to read the webpage content.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We also defined “pageAction” in the Manifest File as our extension icon in the Chrome toolbar.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The declarative API further allows rules to be set on the “onPageChanged” event, which then takes an action when conditions under “PageStateMatcher” are met.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The “PageStateMatcher” only matches webpages when the listed conditions are met. In this case, the rules would show a page action for any http or https webpage.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“removeRules” is called to clear all previously defined rules that were added when the extension was installed, so a new set of rules can be defined (“addRules”).&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second Code Block:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;When pageAction, which is the extension icon we created in in our Manifest file is clicked, we add a listener i.e. don’t run the script yet.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The next line refers to the “active tab” permission we stated in our Manifest File. Chrome queries to the current window that is open, and determines the active tab. Once the active tab is determined, it runs a function with the parameters “tabs”.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The last bit of code tells Chrome to go to the active tab, which we isolated in the previous line, and execute a script, in this case the “main.js” file.&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save your file and refresh your extension.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Open a new tab and you should see that your icon is now active and no longer greyed out.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxn8et6kqev43hnpdj2g4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fxn8et6kqev43hnpdj2g4.png" alt="Active Icon" width="554" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We’re finally done all the setup work and can get to the fun part!&lt;/p&gt;

&lt;h3&gt;Image Placeholder Service&lt;/h3&gt;

&lt;p&gt;We need to find some replacement images for our extension. There are a couple of sites that do this and have images of varying sizes. I’m going to use the puppy one, &lt;a href="https://placedog.net/" rel="noopener noreferrer"&gt;https://placedog.net/&lt;/a&gt; but there are many more so choose your favourite!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://placekitten.com/" rel="noopener noreferrer"&gt;https://placekitten.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://placebear.com/" rel="noopener noreferrer"&gt;https://placebear.com/&lt;/a&gt;  &lt;/p&gt;

&lt;h3&gt;main.js File&lt;/h3&gt;

&lt;p&gt;We’re now going to write our script so we can replace the images with our cute puppy photos when we click on our extension.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Include the below code in your main.js file
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var allImages = document.getElementsByTagName('img');

for (var i = 0; i &amp;lt; allImages.length; i++) {
  allImages[i].addEventListener('mouseover', function() {

    var thisImageHeight = this.clientHeight;
    var thisImageWidth = this.clientWidth;

  this.setAttribute('src', 'https://placedog.net/' + thisImageHeight + '/' + thisImageWidth)
  })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break down the above code:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We want to target all of the images on a given webpage. Since these image elements will all have an “img” tag, we grab them with document.getElements byTagName(‘img’) and assign it to the variable “allImages”.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We can now use a “for loop” to loop over each image and add an Event Listener. In this case, we are awaiting the user to mouse over the image.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The width and height of our new images should be equal to the images that are being replaced. We assign this original image height and width to separate variables: thisImageHeight and thisImageWidth.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We can now use the setAttribute feature to change the attribute of the src element. Remember that “this” refers to the image that was moused over. We will also include the image height and width using the variables from our previous line.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;You did it!&lt;/h3&gt;

&lt;p&gt;Alright, save your file and refresh your extension. Open up a webpage (with lots of images) and try out your fun new Chrome extension!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>chromeextension</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>JavaScript — Back to Basics: Prefix vs. Postfix</title>
      <dc:creator>Himashi Hettege Dona</dc:creator>
      <pubDate>Sun, 15 Apr 2018 20:54:12 +0000</pubDate>
      <link>https://dev.to/himashi99/javascriptback-to-basics-prefix-vs-postfix-997</link>
      <guid>https://dev.to/himashi99/javascriptback-to-basics-prefix-vs-postfix-997</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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbx58cffauijbx6b4xa0b.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbx58cffauijbx6b4xa0b.jpg" alt="abc-building-blocks"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Wish me luck, I’m diving into JavaScript!&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;As much as I want to start using JavaScript right away, and create applications, I know that I won’t be able to fully grasp the language unless I understand the fundamentals. Consequently, I’ve been following the chapters from &lt;a href="https://javascript.info" rel="noopener noreferrer"&gt;https://javascript.info&lt;/a&gt; which has been a great source so far.&lt;/p&gt;

&lt;p&gt;For my own reference, I thought I would write about interesting tidbits I’m learning, or topics I’m struggling with along the way. I hope this will also be of some use to others who are leaning JavaScript as well.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Increment/Decrement&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;This numerical operation increases or decreases a variable by 1. It’s important to remember that this can only be applied to variables, and applying this operation to numerical values will return an error.&lt;/p&gt;

&lt;p&gt;Increment ++: Increases variable by 1&lt;br&gt;
Decrement — — : Decreases variable by 1&lt;/p&gt;

&lt;p&gt;The ++ or — — can be applied both before and after the variable. This is where it gets a bit tricky.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;em&gt;Syntax&lt;/em&gt;
&lt;/h5&gt;

&lt;p&gt;Postfix Form: counter++&lt;br&gt;
Prefix Form: ++counter&lt;/p&gt;

&lt;p&gt;Although both forms increase the variable by 1, there is a difference. The Postfix Form returns the original value of the variable, before the increment/decrement The Prefix Form returns the value after the increment/decrement. This difference can be seen if we are using the returned value of the increment/decrement.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;em&gt;Example&lt;/em&gt;
&lt;/h5&gt;

&lt;p&gt;Prefix&lt;br&gt;
&lt;code&gt;let counter = 2;&lt;br&gt;
 alert(++counter); //3 incremented value has been returned&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Postfix&lt;br&gt;
&lt;code&gt;let counter = 2;&lt;br&gt;
 alert(counter++); //2 Returns the original value prior to the increment&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we are using the value of the increment/decrement at a later point in time however, there is no difference between the forms.&lt;/p&gt;

&lt;h5&gt;
  
  
  &lt;em&gt;Example&lt;/em&gt;
&lt;/h5&gt;

&lt;p&gt;Prefix&lt;br&gt;
&lt;code&gt;let counter = 2; &lt;br&gt;
 ++counter; //3 The incremented value&lt;br&gt;
 alert(counter); //3 Incremented value has been returned&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Postfix&lt;br&gt;
&lt;code&gt;let counter = 2;&lt;br&gt;
 counter++; // 2 The original value&lt;br&gt;
 alert(counter); //3 Value has been incremented and returns the new value&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It took me a bit of time to wrap my head around this so I hope this was a clear enough explanation.&lt;/p&gt;

&lt;p&gt;If you liked this article, click the heart button. I would greatly appreciate it!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>prefix</category>
      <category>postfix</category>
      <category>learningtocode</category>
    </item>
    <item>
      <title>Cognitive Behavioural Therapy (CBT) for Developers</title>
      <dc:creator>Himashi Hettege Dona</dc:creator>
      <pubDate>Sat, 31 Mar 2018 18:53:45 +0000</pubDate>
      <link>https://dev.to/himashi99/cognitive-behavioural-therapy-cbt-for-developers-2lo6</link>
      <guid>https://dev.to/himashi99/cognitive-behavioural-therapy-cbt-for-developers-2lo6</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%2Fwww.hampshirepsychology.co.uk%2Fwp-content%2Fuploads%2F2014%2F07%2Fheadgear2.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%2Fwww.hampshirepsychology.co.uk%2Fwp-content%2Fuploads%2F2014%2F07%2Fheadgear2.png" alt="head-gear"&gt;&lt;/a&gt;&lt;br&gt;
I went to a really interesting Meetup the other day called Cognitive Behavioural Therapy (CBT) for Tech Leads. The talk was led by Jamie Strachan, who was a developer for 15 years and now manages a team of developers at Info-Tech Research Group. In battling his own depression, he was introduced to the book “Feeling Good” by David D Burns, where he discovered CBT.&lt;/p&gt;

&lt;p&gt;Although not a tech lead myself, I was intrigued by the topic. Coming from a Neuroscience background and spending countless hours in various psychology classes, I wanted to see how Jamie was using CBT to help improve the day-to-day effectiveness of his fellow developers.&lt;/p&gt;

&lt;p&gt;CBT is the idea that our thoughts determine our emotions. Changing how we think therefore, will change how we feel about an experience. CBT is generally used to treat depression and other mental disorders, but Jamie outlined how CBT can be used to overcome common challenges such as procrastination, perfectionism, or handling criticisms.&lt;/p&gt;

&lt;p&gt;Now before we can go into how CBT can help overcome these challenges, we need to understand how our minds can trick us into arriving at negative conclusions. These “tricks” or cognitive distortions, are inaccurate thoughts that reinforce negative patterns of thought or emotions. It’s essentially a faulty way of thinking that convinces us of something, that isn’t really true. There are many cognitive distortions but some of the ones that Jamie pointed out were:&lt;/p&gt;

&lt;p&gt;Emotional Reasoning — We believe what we feel must automatically be true. We believe these unhealthy emotions reflect the way things actually are.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;Because I am feeling overwhelmed, I must be facing something overwhelming.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;All-or-Nothing Thinking — If we don’t perform perfectly in one area, we see ourselves as a total failure.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;I can’t learn this language quickly enough therefore I’m a failure as a developer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;“Should” Statements — We have a firm set of rules about how we should behave. We think these statements are motivating when directed towards ourselves, however they often leave feelings of guilt, frustration, and failure.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;I really should exercise.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Jumping to conclusions (Mind reading, fortune teller error) — We come to a negative conclusion even though there are no definitive facts that convincingly support said conclusion.&lt;/p&gt;

&lt;p&gt;a.) Mind reading — You arbitrarily conclude that someone is reacting negatively to you.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;She didn’t say hello to me this morning. She must dislike me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;b.)&lt;/em&gt; The fortune teller error. — You anticipate that things will go awry, and you feel convinced that your prediction is an established fact.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;My year-end review will definitely go poorly.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Catastrophizing / Magnifying or Minimizing — We expect the worst to happen based on a slight incident that was not a big issue in the first place.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;I made a mistake and now the whole project is ruined and I’ll be fired.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Labelling — We generalize one or two qualities into a negative global judgement.&lt;/p&gt;

&lt;p&gt;eg.) &lt;em&gt;I can’t even help him find a solution. I’m an idiot.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Jamie then went on to explain how these cognitive distortions are intertwined with some of the everyday challenges we face both in the workplace and our personal life.&lt;/p&gt;

&lt;h3&gt;
  
  
  Perfectionism
&lt;/h3&gt;

&lt;p&gt;Perfectionism is described as setting extremely high and often unreasonable expectations for yourself and/or others. Oftentimes, your self-worth is based on your ability to strive and achieve these standards. Perfectionism involves “all-or-nothing” thinking; if something is not “perfect” or up to a certain standard, it’s useless.&lt;/p&gt;

&lt;p&gt;As soon as Jamie mentioned this, I instantly thought of an example from my own life. When I was coming up with ideas for my personal website, I looked through multiple examples that others had done. I would finally settle on an idea and start working on it, but then I would see something better that someone else had done and scrap my idea. This happened numerous times as I felt my work wasn’t “perfect” and didn’t measure up to some standard I had set for myself. Even after I had the website put up, I would still obsess about various changes or improvements that I could include.&lt;/p&gt;

&lt;p&gt;Of course, wanting to improve your work is a good thing, but not when it gets in the way of other more important tasks. In my case, I had other programming languages to learn, and it was far more important to improve my coding skills than put up a cool looking portfolio website.&lt;/p&gt;

&lt;h3&gt;
  
  
  Procrastination
&lt;/h3&gt;

&lt;p&gt;Consider the following scenario. There’s a deadline fast approaching for a project and you’ve barely started to work. You’re feeling anxious about it so you find yourself scrolling Pinterest, watching T.V., or even cleaning the house all to avoid the task and temporarily find some relief from your anxiety. Once the reality of the deadline sets in, you feel extreme guilt and shame that you’ve wasted all this time. Again you turn to T.V to shut off those negative feelings, and now you’re in a vicious self-defeating cycle.&lt;/p&gt;

&lt;p&gt;This is something I’m sure everyone has gone through at some point in their life. Again our brains are really good at misleading us. In this case, we’re using emotional reasoning. We are feeling anxious and overwhelmed so therefore we must be facing a task that’s daunting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mishandling Criticism
&lt;/h3&gt;

&lt;p&gt;In any work place, your work will face scrutiny and criticism from others at some point. Hopefully this will be constructive criticism and lead to the overall improvement of the project. It’s important to be able to take criticism from others without feeling anger, frustration, or guilt.&lt;/p&gt;

&lt;p&gt;I’ll be honest, I’m not someone who handles criticism well. For me, receiving criticism leads me straight to “Should” statements. “I should have known better.” “I should have caught that error.” “I should have worked harder.” These statements often lead to guilt and the feeling of defeat.&lt;/p&gt;

&lt;p&gt;So how do we actually change this way of thinking. The first thing according to Jamie is you need to test your feelings. Feelings will not necessarily be positive. The should however be helpful, reasonable, and rational (based on reality). This helps you identify the issue. Next, get the thoughts out of your head using the Triple Column Method (see below). Lastly, do not be afraid to seek help.&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%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AuyPuWBWZscmD2qu32w8tPw.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%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2AuyPuWBWZscmD2qu32w8tPw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course, this topic is far more vast than I can hope to cover in this post but I hope it has piqued your interest. Please check out Jamie’s full talk at &lt;a href="https://vimeo.com/253833709" rel="noopener noreferrer"&gt;https://vimeo.com/253833709&lt;/a&gt;&lt;/p&gt;

</description>
      <category>coding</category>
      <category>mentalhealth</category>
      <category>developer</category>
      <category>cbt</category>
    </item>
  </channel>
</rss>
