<?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: Ibrahim Alausa</title>
    <description>The latest articles on DEV Community by Ibrahim Alausa (@tosinibrahim96).</description>
    <link>https://dev.to/tosinibrahim96</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%2F120129%2F604b59fb-645d-45ea-bf5f-dd338d2da04f.JPG</url>
      <title>DEV Community: Ibrahim Alausa</title>
      <link>https://dev.to/tosinibrahim96</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tosinibrahim96"/>
    <language>en</language>
    <item>
      <title>A comprehensive guide on how to design future-proof controllers: Part 2</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Sat, 02 Apr 2022 11:23:39 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/a-comprehensive-guide-on-how-to-design-future-proof-controllers-part-2-i6f</link>
      <guid>https://dev.to/tosinibrahim96/a-comprehensive-guide-on-how-to-design-future-proof-controllers-part-2-i6f</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;This article is the second part of a series of articles where we talk about how separating code based on functionality can improve the quality of your codebase. If you have not read the first part, check it out &lt;a href="https://dev.to/tosinibrahim96/a-comprehensive-guide-on-how-to-design-future-proof-controllers-part-1-4ll4"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This article will focus on separating the request validation concern from the rest of the code in the Controller. I will be using Laravel in this tutorial. Still, you can apply the ideas we will be discussing here to any programming language that supports any form of code separation into packages, modules, etc., in such a way that you can use code written in &lt;code&gt;file A&lt;/code&gt; in &lt;code&gt;file B&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reading the first part of this article &lt;a href="https://dev.to/tosinibrahim96/a-comprehensive-guide-on-how-to-design-future-proof-controllers-part-1-4ll4"&gt;here&lt;/a&gt; to understand some concepts and terminologies&lt;/li&gt;
&lt;li&gt;Knowledge of Object-Oriented Programming (OOP) is required&lt;/li&gt;
&lt;li&gt;Basic knowledge of &lt;a href="https://laravel.com/"&gt;Laravel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;If you want to test the code on your system, then you **MUST **have &lt;a href="https://www.php.net/manual/en/install.php"&gt;PHP&lt;/a&gt; installed on your system&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Let's dive in 🚀
&lt;/h2&gt;

&lt;p&gt;You can find all the code from this article &lt;a href="https://github.com/tosinibrahim96/concerns-demo"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What we currently have&lt;/strong&gt; &lt;br&gt;&lt;br&gt;
Let's look at a simple controller function that adds a new user to the database during a registration process. I have added comments to illustrate how we can identify the three concerns involved in the register function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  /**
   * create a new account
   * @param \Illuminate\Http\Request $request
   * @return \Illuminate\Http\Response
   */
  public function register(Request $request)
  {
    /*----Concern (Request validation)----*/
    $validator = Validator::make($request-&amp;gt;all(), [
      'email' =&amp;gt; 'required|email|unique:users',
      'name' =&amp;gt; 'required|string',
      'password' =&amp;gt; 'required|min:6'
    ]);

    if ($validator-&amp;gt;fails()) {
      /*----Concern (Sending response to the client)----*/
      return response()-&amp;gt;json(
        [
          "status" =&amp;gt; false,
          "message" =&amp;gt; $validator-&amp;gt;errors()
        ],
        422
      );
    }

    /*----Concern (Handling business logic (In this case, hashing the user's password and interaction with database)----*/
    $password = Hash::make($request-&amp;gt;password);
    $user = User::create([
      'name' =&amp;gt; $request-&amp;gt;name,
      'password' =&amp;gt; $password,
      'email' =&amp;gt; $request-&amp;gt;email
    ]);

    /*----Concern (Sending response to the client)----*/
    return response()-&amp;gt;json(
      [
        "status" =&amp;gt; true,
        "message" =&amp;gt; 'User account created successfully',
        "data" =&amp;gt; $user
      ],
      201
    );
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Separating the Request Validation Concern
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5X9JYds---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644901361473/Bzp-o9JId.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5X9JYds---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644901361473/Bzp-o9JId.gif" alt="separation.gif" width="480" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will discuss two approaches to separate the Request validation concern from the Controller.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first approach involves building a request validation class and writing all your validation logic in the validation class. The Class needs to contain some &lt;code&gt;public&lt;/code&gt; methods to ensure that the Controller can execute the validation logic.&lt;/li&gt;
&lt;li&gt;The second approach is called &lt;a href="https://laravel.com/docs/8.x/validation#form-request-validation"&gt;Form request validation&lt;/a&gt;. This approach is specific to Laravel, and the validation class has to follow a particular pattern. It's a powerful feature.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Approach 1: Building a Request Validation Class
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3KoFs7Z3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644899837341/aYjcDYcyd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3KoFs7Z3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644899837341/aYjcDYcyd.gif" alt="building.gif" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a folder called &lt;code&gt;Validators&lt;/code&gt; inside the &lt;code&gt;app/Http&lt;/code&gt; directory &lt;/li&gt;
&lt;li&gt;Create a new file called &lt;code&gt;AuthValidator.php&lt;/code&gt; in the newly created &lt;code&gt;Validators&lt;/code&gt; folder&lt;/li&gt;
&lt;li&gt;The code below should be the content of the &lt;code&gt;AuthValidator.php&lt;/code&gt; file
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

namespace App\Http\Validators;

use Illuminate\Support\Facades\Validator;


class AuthValidator
{
  protected $errors = [];

  /**
   * validate user registration data
   *
   * @param  array $requestData
   * @return \App\Http\Validators\AuthValidator
   */
  public function validateRegistrationData(array $requestData)
  {
    $validator = Validator::make($requestData, [
      'email' =&amp;gt; 'required|email|unique:users',
      'name' =&amp;gt; 'required|string',
      'password' =&amp;gt; 'required|min:6'
    ]);

    $this-&amp;gt;errors = $validator-&amp;gt;errors();

    return $this;
  }


  /**
   * get the errors that occurred during 
   * validation
   *
   * @return array
   */
  public function getErrors()
  {
    return $this-&amp;gt;errors;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What exactly does the code do? 😕&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, we have a property in the Class called &lt;code&gt;$errors&lt;/code&gt; and set the value as an empty array&lt;/li&gt;
&lt;li&gt;Then, we create a method called &lt;code&gt;validateRegisterationData(),&lt;/code&gt; which will be responsible for executing the actual validation logic&lt;/li&gt;
&lt;li&gt;The result of the validation check (&lt;code&gt;$validator-&amp;gt;errors()&lt;/code&gt;) is stored in the &lt;code&gt;$errors&lt;/code&gt; property of the current object. If all the data in the request are valid and no validation error(s) occurred, the validator returns an empty array.&lt;/li&gt;
&lt;li&gt;Finally, we return the current object (&lt;code&gt;$this&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The second method, &lt;code&gt;getErrors()&lt;/code&gt; simply returns the &lt;code&gt;$errors&lt;/code&gt; property for the current object. This property would contain the actual errors that occurred during validation or an empty array if no errors occurred&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How do we use the AuthValidator in the Controller? 🤔&lt;/strong&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Create a constructor method (&lt;code&gt;__construct()&lt;/code&gt;) in the AuthController class and pass the Authvalidator class as a parameter in the constructor. Then the value of the parameter is stored in a class property.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class AuthController extends Controller
{

  protected $authValidator;

  /**
  * __construct
  * 
  *  @param \App\Http\Validators\AuthValidator $authValidator
   * @return void
   */
  public function __construct(AuthValidator $authValidator)
  {
   $this-&amp;gt;authValidator = $authValidator;

  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can remove the existing validation logic in the &lt;code&gt;register()&lt;/code&gt; method of the Controller and use the logic in the AuthValidator class we created ☺️.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  /**
   * create a new account
   * @param \Illuminate\Http\Request $request
   * @return \Illuminate\Http\Response
   */
  public function register(Request $request)
  {
    $errors = $this-&amp;gt;authValidator
      -&amp;gt;validateRegistrationData($request-&amp;gt;all())
      -&amp;gt;getErrors();

    if (count($errors)) {
      return response()-&amp;gt;json([ "status" =&amp;gt; false,"message" =&amp;gt; $errors],
        422
      );
    }

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

&lt;/div&gt;



&lt;p&gt;Since the &lt;code&gt;validateRegistrationData()&lt;/code&gt; method returns an object, we can immediately execute the &lt;code&gt;getErrors()&lt;/code&gt; method on the returned object without assigning it to a variable first. This pattern is called &lt;a href="https://designpatternsphp.readthedocs.io/en/latest/Structural/FluentInterface/README.html"&gt;Fluent interface&lt;/a&gt;. &lt;code&gt;count($errors)&lt;/code&gt; checks if there is at least one element in the errors array returned from the validator and returns a response to the client if any error exists.&lt;/p&gt;

&lt;p&gt;With the code designed this way, the Controller does not care how the validation logic works. The Controller knows that the validator will do its job and return a response after completing the validation process. Then the final response is sent from the Controller. So we can add, remove or modify the validation logic, and the Controller still works perfectly without any issues. Sweet right. If you think this is great, let's look at the second method, which is using Laravel Form Requests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Approach 2: Using Laravel Form Requests
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jZBgMVDf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644899979881/XCA6MnWka.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jZBgMVDf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1644899979881/XCA6MnWka.gif" alt="laravelvalidation.gif" width="500" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Form requests are custom request classes containing their validation logic, just like we did in the first approach. Laravel Form requests are also awesome because they contain authorization logic by default. To create a form request class, you may use the &lt;code&gt;make:request&lt;/code&gt; artisan command provided by Laravel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan make:request CreateNewUserRequest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Laravel will generate a form request class in the &lt;code&gt;app/Http/Requests&lt;/code&gt; directory with the name passed as the file name. In our case, a new file, &lt;code&gt;CreateNewUserRequest.php&lt;/code&gt; will be created.&lt;/p&gt;

&lt;p&gt;By default, Form request classes generated by Laravel come with two methods, &lt;code&gt;authorize()&lt;/code&gt; and &lt;code&gt;rules()&lt;/code&gt;. The &lt;code&gt;authorize()&lt;/code&gt; method contains the logic that determines if the user making that request has the permission to do so. Of course, you can modify the logic to fit your specific use case at any time. In our case, we do not require any special permission or authorization for the &lt;code&gt;CreateNewUserRequest&lt;/code&gt; Class, so we return true.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
/**
   * Determine if the user is authorized to make this request.
   *
   * @return bool
   */
  public function authorize()
  {
    return true;
  }

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

&lt;/div&gt;



&lt;p&gt;On the other hand, the &lt;code&gt;rules()&lt;/code&gt; method returns the validation rules that should apply to the request's data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
/**
   * Get the validation rules that apply to the request.
   *
   * @return array
   */
  public function rules()
  {
    return [
      'email' =&amp;gt; 'required|email|unique:users',
      'name' =&amp;gt; 'required|string',
      'password' =&amp;gt; 'required|min:6'
    ];
  }

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How do we use the rules in the CreateNewUserRequest class in the Controller? 🤔&lt;/strong&gt;&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Change the type of the parameter in the register function from &lt;code&gt;\Illuminate\Http\Request&lt;/code&gt; to &lt;code&gt;\App\Http\Requests\CreateNewUserRequestwith&lt;/code&gt;(this is the path to the Laravel form request class we just built)&lt;/li&gt;
&lt;li&gt;Remove the validation logic in the &lt;code&gt;register()&lt;/code&gt; function&lt;/li&gt;
&lt;li&gt;Since Laravel internally checks for errors and returns an appropriate response when using Form requests, we do not need an &lt;code&gt;if&lt;/code&gt; statement to check if the validation failed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
   * create a new account
   * @param App\Http\Requests\CreateNewUserRequest $request
   * @return \Illuminate\Http\Response
   */
  public function register(CreateNewUserRequest $request)
  {
    /*--------Concern 2 (Business logic execution)------------------*/
    $password = Hash::make($request-&amp;gt;password);
    $user = User::create([
      'name' =&amp;gt; $request-&amp;gt;name,
      'password' =&amp;gt; $password,
      'email' =&amp;gt; $request-&amp;gt;email
    ]);

    /*--------Concern 3(Response formatting and return)------------------*/
    return response()-&amp;gt;json(
      [
        "status" =&amp;gt; true,
        "message" =&amp;gt; 'User account created',
        "data" =&amp;gt; $user
      ],
      201
    );
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And voila! Our Controller has absolutely no idea about the validation logic, and changes to the validations rules do not affect the Controller. So once again, we can change the validation logic however we want, and the Controller will remain the same and work perfectly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's explore Form Requests a little further 💪🏿
&lt;/h3&gt;

&lt;p&gt;Here is a sample error response from the &lt;code&gt;CreateNewUserRequest&lt;/code&gt; class after sending a request with an empty value as the &lt;code&gt;name&lt;/code&gt; of the new user&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "message": "The given data was invalid.",
    "errors": {
        "name": [
            "The name field is required."
        ]
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's assume that due to our team's convention, we need to change the structure of the error response sent back to the client after a failed validation. We can achieve this by overriding the default &lt;code&gt;failedValidation()&lt;/code&gt; method in all Laravel form request classes that extend &lt;code&gt;FormRequest&lt;/code&gt;, just like our &lt;code&gt;CreateNewUserRequest&lt;/code&gt; Class.&lt;/p&gt;

&lt;p&gt;Now we have an extra method, &lt;code&gt;failedValidation()&lt;/code&gt;, that looks 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;/**
   * Handle a failed validation attempt.
   *
   * @param  \Illuminate\Contracts\Validation\Validator  $validator
   * @return void
   *
   * @throws \Illuminate\Validation\ValidationException
   */
  protected function failedValidation(Validator $validator)
  {
    throw new HttpResponseException(
      response()-&amp;gt;json(
        [
          'status' =&amp;gt; false,
          'message' =&amp;gt; 'Validation errors occurred',
          'errors' =&amp;gt; $validator-&amp;gt;errors(),
        ],
        422
      )
    );
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After making our changes on how we want the error message to be structured, our response looks 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;{
    "status": false,
    "message": "Validation errors occurred",
   "errors": {
        "name": [
            "The name field is required."
        ]
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What's next? 💭
&lt;/h2&gt;

&lt;p&gt;In the next part of this series, we will be looking at how to use &lt;code&gt;Actions&lt;/code&gt; to separate business logic away from the Controller. Believe me, that would be awesome, and you don't want to miss it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick recap 🔄
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The controllers in your codebase should know what validation class to call to a particular request but have zero knowledge about the validation rules that apply to the request's data. That is the responsibility of Validators&lt;/li&gt;
&lt;li&gt;You can build your validator class or use Laravel form requests. I don't think any approach is better than the other. It all depends on whichever approach you prefer&lt;/li&gt;
&lt;li&gt;The Laravel form request class can also handle user authorization even before checking if the data from the client passes all the validation rules, and this is done via the &lt;code&gt;authorize()&lt;/code&gt; method&lt;/li&gt;
&lt;li&gt;The advantage of building your validators is that your methods can follow any naming convention you want. However, when using Laravel Form requests, the method handling the data validation must be named &lt;code&gt;rules&lt;/code&gt; while the method that handles authorization must be named &lt;code&gt;authorize&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  It's a wrap 🎉
&lt;/h2&gt;

&lt;p&gt;You can check out all the code in this article on Github. After reading this, I sincerely hope that you have learned something, no matter how small. If you did, kindly drop a thumbs up.&lt;br&gt;
Thanks for sticking with me till the end. If you have any suggestions or feedback, kindly drop them in the comment section. Enjoy the rest of your day. Bye 😊.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>php</category>
    </item>
    <item>
      <title>A comprehensive guide on how to design future-proof controllers: Part 1</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Thu, 13 Jan 2022 10:55:55 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/a-comprehensive-guide-on-how-to-design-future-proof-controllers-part-1-4ll4</link>
      <guid>https://dev.to/tosinibrahim96/a-comprehensive-guide-on-how-to-design-future-proof-controllers-part-1-4ll4</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When you are still in that learning phase with any technology, your focus is to make your app work, but I think the exponential progress starts coming when you begin to ask yourself "How can I make this better?". One simple principle that you can immediately apply to your existing or new codebase for cleaner and more maintainable code is the &lt;em&gt;Separation of Concerns&lt;/em&gt; principle.&lt;/p&gt;

&lt;p&gt;Most of the server-side codebases I have come across have controllers that contain code specifying the real-world business rules on how data can be created, stored, and changed on the system. If you want to learn how to build controllers that are clean, concise, and easily maintainable, then this series is for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you will learn after reading this article
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;You will have a solid understanding of the Separation of concerns principle&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will be able to identify the major steps involved in the lifecycle of a request on the server-side&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You will understand the role of the controller on the server side. This will ensure that the lines of code present in your controller functions are the ones that **absolutely **need to be in the controller&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Understanding of &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Server-side/First_steps/Client-Server_overview"&gt;client-server&lt;/a&gt;  architecture&lt;/li&gt;
&lt;li&gt;Familiarity with &lt;a href="https://www.youtube.com/watch?v=DUg2SWWK18I"&gt;model-view-controller&lt;/a&gt; architecture &lt;/li&gt;
&lt;li&gt;A basic understanding of Object-Oriented Programming&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With all that out of the way, let's move 🚀&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Separation of concerns
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a &lt;em&gt;concern&lt;/em&gt;?
&lt;/h3&gt;

&lt;p&gt;A concern is a section of a feature or software that handles a particular functionality in the system. A good example of a concern in a well-designed backend system is &lt;em&gt;request validation&lt;/em&gt;, which means there is a part of the code that accepts the data coming from the client to make sure all the information is valid or at least in the right format before sending it to the other parts of the system.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does the term &lt;em&gt;Separation of concerns&lt;/em&gt; mean?
&lt;/h3&gt;

&lt;p&gt;Since we know what a concern is, understanding the idea behind the Separation of concerns will not be difficult. Separation of concerns promotes the idea of building software in such a way that our code should be broken down into separate components or layers such that each layer handles a specific concern. An example is a feature that retrieves data from the database and then formats the data based on the client’s request. Placing both logic in the same function is a really bad idea since retrieving data from the database is a specific concern, then formatting the retrieved data is another concern.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lifecycle of a request on the server
&lt;/h2&gt;

&lt;p&gt;I have worked on building many backend systems that provide services to clients and many of them usually follow a similar pattern with 3 major steps which are mainly.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Request validation:&lt;/strong&gt; This refers to the part of your code that ensures that the data sent by a client is in a valid and acceptable format. A simple example is making sure that a value sent from the client as an email is actually a valid email address.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Business logic execution:&lt;/strong&gt; This is the section of your codebase that contains the code that enforces real-world business rules. Let's use an app that allows a customer to transfer money from one account to another. A valid business rule is that you cannot transfer an amount that is greater than your current balance. For this app to work properly, there has to be a section of your code that compares the amount you are trying to transfer and your current balance and makes sure the business rule is obeyed. That is what we refer to as business logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Response formatting and return:&lt;/strong&gt;This refers to the section of your codebase responsible for making sure the data returned to the client after business logic execution is properly formatted and well presented. eg &lt;a href="https://www.json.org/json-en.html"&gt;JSON&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction"&gt;XML&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oqOzLBWn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641287318597/I-dRgwjVx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oqOzLBWn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641287318597/I-dRgwjVx.png" alt="Backend receives request.png" width="880" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have come across a lot of codebases that perform these three steps using a single function or method, where line 10 to 15 handles request validation, line 16 to 55 handles all the business logic with long if-else statements, loops, etc, then line 56-74 formats the response based on certain conditions, and finally, line 75 returns the data to the client. That’s about 65 lines of code in a single function!  That is a ticking time bomb waiting to explode when a new engineer joins the team or when you come back to add more changes to the code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the role of the controller in the backend request lifecycle
&lt;/h2&gt;

&lt;p&gt;Imagine we have 3 tasks involving the same feature. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fix a bug in request validation&lt;/li&gt;
&lt;li&gt;Change the way data is retrieved from the database (use &lt;a href="https://laravel.com/docs/8.x/eloquent"&gt;Eloquent ORM&lt;/a&gt; instead of raw queries)&lt;/li&gt;
&lt;li&gt;Add extra meta-data to the response returned to the client&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If our controllers are designed in a way where each method contains all these three major steps involved in fulfilling a request on the server-side, then the flow looks something like the image below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p33LN1pT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641289830987/beNORqKs7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p33LN1pT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641289830987/beNORqKs7.png" alt="Backend receives request 1.png" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Handling these tasks become a nightmare because everyone in the team will be modifying the same function, and good luck merging all these changes without the need to resolve merge conflicts 🙄.&lt;/p&gt;

&lt;h3&gt;
  
  
  So, what exactly should the controller do?
&lt;/h3&gt;

&lt;p&gt;The controller should serve as a delegator, meaning that the controller accepts a request with the associated data from the client, then the controller should assign the different tasks involved in fulfilling the client’s request to different parts of the codebase, then finally, the controller sends a proper response (success or failure) to the client depending on the result of the executed code.&lt;br&gt;
I have illustrated this using the image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jIK99n8T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641456625687/98jpwGdzc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jIK99n8T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641456625687/98jpwGdzc.png" alt="controller delegator.png" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If our controllers are built this way, making changes will be incredibly easy, bugs will be easy to trace and the responsibility of each class and other classes it depends on to fulfill its tasks will be immediately visible even to someone looking at the code for the first time.&lt;/p&gt;

&lt;h2&gt;
  
  
  There is more juicy stuff to come 😋
&lt;/h2&gt;

&lt;p&gt;Like I said at the beginning of the article, this is going to be a series because there is a lot of information to digest and I want to make sure you can remember a lot after reading each article. I want to separate the concerns you know 😂, so that this article does not become massive like the controllers we will be refactoring starting from the next part. If you didn't get that joke, then maybe next time.&lt;/p&gt;

&lt;p&gt;In the next article, Part 2. We will be refactoring a controller function with a specific focus on the Request validation concern. We will build a Request validator class and  &lt;a href="https://stackify.com/oop-concept-abstraction/"&gt;abstract &lt;/a&gt; all the logic involved in validating the client's request away from the controller. I will be using  &lt;a href="https://laravel.com/"&gt;Laravel &lt;/a&gt; in the rest of the series.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Recap
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Separation of concerns is simply a concept that promotes the idea that you should always look at your code to identify the different functionalities involved, and think of how you can break down the code into smaller components for clarity, easy debugging, and maintenance among other benefits.&lt;/li&gt;
&lt;li&gt;All the logic involved in fulfilling a client's request on the server-side should not be in a single location, like a controller. &lt;/li&gt;
&lt;li&gt;The controllers should serve as classes that delegate tasks to other parts of the codebase and get's back a response from those other parts. Depending on the response received by the controller, the controller decides if the response to send back to the client should be a success or failure response.&lt;/li&gt;
&lt;li&gt;More code might be involved when trying to break down a feature into smaller components but remember, it pays off in the long run.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  It's a wrap 🎉
&lt;/h2&gt;

&lt;p&gt;I sincerely hope that you have learned something, no matter how small, after reading this. If you did, kindly drop a thumbs up.&lt;/p&gt;

&lt;p&gt;Thanks for sticking with me till the end. If you have any suggestions or feedback, kindly drop them in the comment section. Enjoy the rest of your day...bye 😊. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>laravel</category>
      <category>programming</category>
      <category>php</category>
    </item>
    <item>
      <title>PHP 8: Constructor Property Promotion</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Mon, 29 Nov 2021 10:38:06 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/php-8-constructor-property-promotion-7a1</link>
      <guid>https://dev.to/tosinibrahim96/php-8-constructor-property-promotion-7a1</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;If you have been a software engineer for a while, you know that software engineers love using scary names to describe simple things. The term &lt;em&gt;constructor property promotion&lt;/em&gt; should not scare you because you might be using it in your codebase already without realizing it has a fancy name. &lt;/p&gt;

&lt;p&gt;Here are the things you will achieve after reading this article.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You will be able to refactor a PHP class to use constructor property promotion instead of using the default syntax used when setting class properties in the constructor function. &lt;/li&gt;
&lt;li&gt;You will know the different ways of accessing class properties after setting them using the constructor property promotion syntax.&lt;/li&gt;
&lt;li&gt;You will know the common mistakes that lead to errors when using the constructor property promotion syntax in your PHP class and how to avoid them.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Interested? Let's move 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;A basic understanding of Object-Oriented Programming in PHP&lt;/li&gt;
&lt;li&gt;You must have PHP 8 installed to enjoy this feature in your code or project. Alternatively, you can test this feature on  &lt;a href="https://phpsandbox.io/n/standard"&gt;phpsandbox&lt;/a&gt;  by selecting PHP8 as your preferred version&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What is Constructor Property Promotion? 🤔
&lt;/h3&gt;

&lt;p&gt;Constructor property promotion is a feature introduced in PHP 8 that allows values passed to a constructor to be automatically set as class properties without the need to write the assignment statement in the body of the constructor. &lt;br&gt;
For a better understanding of the concept, let's take a look at the way values were assigned to class properties before the introduction of the constructor property promotion feature in PHP8.&lt;/p&gt;
&lt;h4&gt;
  
  
  Before constructor property promotion 🥱
&lt;/h4&gt;

&lt;p&gt;Before constructor property promotion was introduced, here’s how you will typically set the &lt;br&gt;
&lt;code&gt;firstName&lt;/code&gt; and &lt;code&gt;lastName&lt;/code&gt; properties passed to the &lt;code&gt;Employee&lt;/code&gt; class through the constructor.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{

  protected $firstName, $lastName;

  public function __construct(string $firstName, string $lastName)
  {
    $this-&amp;gt;firstName = $firstName;
    $this-&amp;gt;lastName = $lastName;
  }
}


$employee = new Employee('Ibrahim', 'Alausa');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above, we are declaring the properties &lt;code&gt;firstName&lt;/code&gt; and &lt;code&gt;lastName&lt;/code&gt; without any initial value. Then, in the body of the constructor, we set the &lt;code&gt;firstName&lt;/code&gt; and &lt;code&gt;lastName&lt;/code&gt; properties to the value passed to the constructor. In this example, that is **Ibrahim **as the value of the &lt;code&gt;firstName&lt;/code&gt; property and **Alausa **as the value of the &lt;code&gt;lastName&lt;/code&gt; property.&lt;/p&gt;

&lt;h4&gt;
  
  
  The new way for the cool programmers 😎
&lt;/h4&gt;

&lt;p&gt;Now, let's rewrite the &lt;code&gt;Employee&lt;/code&gt; class to use constructor property promotion. Let's see what our code will look like in this case&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{
  public function __construct(protected string $firstName, protected string $lastName)
  {
  }
}


$employee = new Employee('Ibrahim', 'Alausa');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Yes. Isn't this beautiful? Just in case your answer is *&lt;em&gt;NO *&lt;/em&gt; well, that was a rhetorical question, my friend. It is beautiful.&lt;/p&gt;

&lt;h4&gt;
  
  
  What exactly is different
&lt;/h4&gt;

&lt;p&gt;By adding an access modifier (protected, private, etc) to each parameter in the constructor, PHP understands that you are trying to “promote” the constructor parameter to a class property. &lt;/p&gt;

&lt;h3&gt;
  
  
  Important points to note when working with constructor property promotion
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Accessing class properties  🔐
&lt;/h4&gt;

&lt;p&gt;Within the constructor, promoted properties can be accessed with or without the &lt;code&gt;$this&lt;/code&gt; keyword since they are still within the function scope where they were declared. Let's see what our code will look like in this case&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{
  public function __construct(protected string $firstName, protected string $lastName)
  {
    var_dump($firstName);  Ibrahim ✔️
    var_dump($this-&amp;gt;firstName); Ibrahim ✔️
  }
}


$employee = new Employee('Ibrahim', 'Alausa');

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

&lt;/div&gt;



&lt;p&gt;Run the code &lt;a href="https://phpsandbox.io/e/x/ymalo?layout=EditorPreview&amp;amp;defaultPath=%2F&amp;amp;theme=dark&amp;amp;showExplorer=no&amp;amp;openedFiles="&gt;here&lt;/a&gt; to see for yourself.&lt;/p&gt;

&lt;p&gt;However, once you are outside the constructor, you need to use the &lt;code&gt;$this&lt;/code&gt; keyword to access all promoted properties so that PHP understands that you are referring to the &lt;code&gt;firstName&lt;/code&gt; or &lt;code&gt;lastName&lt;/code&gt; property of the class and not an undefined variable or a variable that may have been declared using the same name.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{
  public function __construct(protected string $firstName, protected string $lastName)
  {
  }

  public function getUndefinedFirstName()
  {
    var_dump($firstName); // Output: Undefined variable '$firstName' ❌
  }

  public function getWrongFirstName()
  {
    $firstName = 'John';
    var_dump($firstName); // Output:John ❌
  }

  public function getFirstName()
  {
    var_dump($this-&amp;gt;firstName); // Output:Ibrahim ✔️
  }
}


$employee = new Employee('Ibrahim', 'Alausa');

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

&lt;/div&gt;



&lt;p&gt;Run the code &lt;a href="https://phpsandbox.io/e/x/nuuvz?layout=EditorPreview&amp;amp;defaultPath=%2F&amp;amp;theme=dark&amp;amp;showExplorer=no&amp;amp;openedFiles="&gt;here&lt;/a&gt; to see for yourself.&lt;/p&gt;



&lt;h4&gt;
  
  
  2. You don't have to promote all constructor parameters. Mix 'em up 🥂
&lt;/h4&gt;

&lt;p&gt;Let’s assume that for some reason, we need to append &lt;code&gt;Fname_&lt;/code&gt; to every value passed to our Employee class as the first name and we want to do that cleanly. We don’t need to promote the &lt;code&gt;firstName&lt;/code&gt; property. Let's see what our code will look like in this case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{
  protected $firstName;

  public function __construct(string $firstName, protected string $lastName)
  {
    $this-&amp;gt;firstName = "Fname_$firstName";
  }

  public function getFirstName()
  {
    var_dump($this-&amp;gt;firstName); // Output:Fname_Ibrahim ✔️
  }
}


$employee = new Employee('Ibrahim', 'Alausa');

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

&lt;/div&gt;



&lt;p&gt;Run the code &lt;a href="https://phpsandbox.io/e/x/gmycf?layout=EditorPreview&amp;amp;defaultPath=%2F&amp;amp;theme=dark&amp;amp;showExplorer=no&amp;amp;openedFiles="&gt;here&lt;/a&gt; to see for yourself.&lt;/p&gt;



&lt;h4&gt;
  
  
  3. You either want to promote a property or you don't. Make a choice 🤦‍♂️
&lt;/h4&gt;

&lt;p&gt;This means that you can't declare a class property above the constructor and still try to promote that property in the constructor parameter list. Let's see what our code will look like in this case. Remember, this will throw an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{
  protected $firstName;

  public function __construct(protected string $firstName, protected string $lastName) 
  //Cannot redeclare Employee::$firstName ❌
  {
    $this-&amp;gt;firstName = $firstName;
  }
}


$employee = new Employee('Ibrahim', 'Alausa');

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

&lt;/div&gt;



&lt;p&gt;Run the code &lt;a href="https://phpsandbox.io/e/x/rgawi?layout=EditorPreview&amp;amp;defaultPath=%2F&amp;amp;theme=dark&amp;amp;showExplorer=no&amp;amp;openedFiles="&gt;here&lt;/a&gt; to see for yourself.&lt;/p&gt;



&lt;h4&gt;
  
  
  4. You can set default values for promoted properties 😐
&lt;/h4&gt;

&lt;p&gt;If one or more values in the constructor are optional, a default value can be set for that property. &lt;br&gt;
Let's see what our code will look like in this case.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

class Employee
{
  public function __construct(protected string $firstName, protected string $lastName='N/A') 
  {
  }

  public function getLastName()
  {
    var_dump($this-&amp;gt;lastName); //Output: N/A ✔️
  }
}

$employee = new Employee('Ibrahim');

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

&lt;/div&gt;



&lt;p&gt;Run the code &lt;a href="https://phpsandbox.io/e/x/wayaz?layout=EditorPreview&amp;amp;defaultPath=%2F&amp;amp;theme=dark&amp;amp;showExplorer=no&amp;amp;openedFiles="&gt;here&lt;/a&gt; to see for yourself.&lt;/p&gt;



&lt;h3&gt;
  
  
  Quick Recap
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;The constructor property promotion feature only works with PHP8.0 and above.&lt;/li&gt;
&lt;li&gt;To promote a constructor parameter to a class property, the constructor parameter should have an access modifier like public, private, etc.&lt;/li&gt;
&lt;li&gt;Since the constructor parameters are both parameters and class properties, you can access the promoted properties in the constructor with or without the &lt;code&gt;$this&lt;/code&gt; keyword. However, class properties must be accessed with the &lt;code&gt;this&lt;/code&gt; keyword outside the constructor function.&lt;/li&gt;
&lt;li&gt;Not all parameters need to be promoted. Mix 'em up and enjoy the best of both worlds.&lt;/li&gt;
&lt;li&gt;While trying to enjoy the best of both worlds, remember that you can't declare a class property above the constructor and still try to promote that property in the constructor parameter list.&lt;/li&gt;
&lt;li&gt;Default values can be set for promoted properties in the constructor.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  It's a wrap 🎉
&lt;/h3&gt;

&lt;p&gt;PHP8 comes with a lot of amazing features that will make you write shorter and cleaner code. If you can, upgrade your version and start using it today.&lt;/p&gt;

&lt;p&gt;Thanks for sticking with me till the end. If you have any suggestions or feedback, kindly drop them in the comment section. Enjoy the rest of your day...bye 😊. &lt;/p&gt;

</description>
      <category>php</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Journey of a Javascript Samurai S01 E02 [Compatibility, Transpilers, Polyfills]</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Sat, 25 Apr 2020 09:33:29 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/journey-of-a-javascript-samurai-s01-e02-compatibility-transpilers-polyfills-50eg</link>
      <guid>https://dev.to/tosinibrahim96/journey-of-a-javascript-samurai-s01-e02-compatibility-transpilers-polyfills-50eg</guid>
      <description>&lt;p&gt;In the previous episode, we talked about the relationship between Javascript &amp;amp; Java, Relationship between ECMAScript &amp;amp; Javascript, Javascript environments and their APIs and how they are different from the core Javascript language. We rounded up that episode with the Programming Paradigms used in Javascript It's a great one, trust me 🤞🏽. Check it out &lt;a href="https://www.apparentdev.com/journey-of-a-javascript-samurai-s01-e01/"&gt;here&lt;/a&gt; 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  Lets move 🚀
&lt;/h2&gt;

&lt;p&gt;In this article, we will talk about compatibility in Javascript language with browsers. Our major highlights are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  What compatibility is and the types such as Forward and Backward compatibility&lt;/li&gt;
&lt;li&gt;  What category of compatibility does Javascript fall into&lt;/li&gt;
&lt;li&gt;  The tools used to handle compatibility problems between Javascript and the browser environment

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

&lt;h3&gt;
  
  
  What is compatibility
&lt;/h3&gt;

&lt;p&gt;According to &lt;a href="https://whatis.techtarget.com/"&gt;techtarget&lt;/a&gt;, compatibility is the capacity for two systems to work together without having to be altered to do so. In our case, the two systems involved are the Browser and the Javascript code we write.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forward compatibility vs Backward compatibility
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://images.unsplash.com/photo-1549357333-a32a1993b1ca?ixlib=rb-1.2.1&amp;amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;amp;auto=format&amp;amp;fit=crop&amp;amp;w=1050&amp;amp;q=80"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VUi7lsP3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1549357333-a32a1993b1ca%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1050%26q%3D80" alt="Door with directions" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we describe Javascript as a &lt;strong&gt;Forward compatible&lt;/strong&gt; language, this means that when there’s a new addition to the Javascript language specification and we include the new syntax in our Javascript code, it should work in an old browser without issues. In very simple terms, old browsers should understand the new Javascript syntax. e.g &lt;code&gt;async-await&lt;/code&gt; syntax should work in old browsers. On the other hand, If we describe the Javascript language as a &lt;strong&gt;Backward compatible&lt;/strong&gt; language, then old Javascript syntax will always work in new browsers. I.e If a new version of chrome or firefox is released today, a syntax from an old Javascript specification like the &lt;code&gt;var&lt;/code&gt; keyword should still work on the new browser.&lt;/p&gt;

&lt;h3&gt;
  
  
  What category of compatibility is Javascript
&lt;/h3&gt;

&lt;p&gt;I thought Javascript is both forward and backward compatible, but it isn’t. Javascript is Backwards compatible (Old syntax works in new browsers ALWAYS). If a new feature is added to the language today and we include it in our codebase, an old browser will throw an error because it doesn’t support that feature yet. Not cool Javascript!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://images.unsplash.com/photo-1541199249251-f713e6145474?ixlib=rb-1.2.1&amp;amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;amp;auto=format&amp;amp;fit=crop&amp;amp;w=967&amp;amp;q=80"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IN3bFWJp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1541199249251-f713e6145474%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D967%26q%3D80" alt="Frustrated man" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As a programmer writing Javascript code, We always want to use the new shiny features of the language because most times they are always shorter and cleaner. We also don't want to tell users to download the latest version of chrome or firefox to make our application work properly for them. How do we ensure we can use the new, cleaner syntax without facing compatibility issues when a user with an ancient browser tries to use the application?&lt;/p&gt;

&lt;h3&gt;
  
  
  Transpilers to the rescue
&lt;/h3&gt;

&lt;p&gt;For new and incompatible syntax, the solution is transpiling. A transpiler is simply a source-to-source translator. In our case, the new syntax is transpiled to old syntax to ensure that older browsers understand the syntax. The most common transpiler is &lt;a href="https://babeljs.io"&gt;Babel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.imgur.com/TroOvkk.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xya-C8Bs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/TroOvkk.png" alt="Babel showing old and new syntax" width="880" height="419"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
In the image above, the syntax on the left uses the ES2015 &lt;code&gt;const&lt;/code&gt; keyword for variable declaration. Babel transpiles the code to the old &lt;code&gt;var&lt;/code&gt; keyword as seen on the right. The old version is what we upload to the server so that all browsers(old and new) use our application without facing compatibility issues.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sometimes, the problem is not Javascript
&lt;/h3&gt;

&lt;p&gt;Sometimes the issue may not be the Javascript syntax, the Javascript environment may not support a certain API. I described the difference between Javascript syntax and Javascript environment API &lt;a href="https://www.apparentdev.com/journey-of-a-javascript-samurai-s01-e01/"&gt;here&lt;/a&gt;. We may encounter an issue where a browser functionality is available in firefox but not in Internet Explorer, then we use A &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Polyfill"&gt;shim/polyfill&lt;/a&gt; to mimic the feature so we have something to fallback to for non supporting browsers.&lt;/p&gt;

&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;When performing DOM manipulation using &lt;code&gt;ChildNode.replaceWith()&lt;/code&gt;, this is the regular syntax below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.imgur.com/se9WVrJ.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QYA89d30--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/se9WVrJ.png" alt="Syntax for ChildNode.replaceWith()" width="880" height="609"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;However, performing the same action on Safari or Internet Explorer 10+ and higher, a &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Polyfill"&gt;polyfill&lt;/a&gt; is required and here's what we have to do&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.imgur.com/VtFheuh.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QXuPM35K--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/VtFheuh.png" alt="Polyfill Syntax for ChildNode.replaceWith()" width="880" height="695"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  It's a Wrap
&lt;/h3&gt;

&lt;p&gt;Like always, thanks for making it this far. I appreciate it. The major points I need you to take away from this article are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Compatibility is the capacity for two systems to work together without having to be altered to do so.&lt;/li&gt;
&lt;li&gt;  Javascript is backwards compatible, not forward i.e old syntax will always work in new browsers.&lt;/li&gt;
&lt;li&gt;  We can create the illusion of forward compatibility in Javascript (new syntax working in old browsers) by using a transpiler like Babel.&lt;/li&gt;
&lt;li&gt;  When the issue is with the Javascript environment API and not the language, we make use of a polyfill instead of transpiler.&lt;/li&gt;
&lt;li&gt;  Having a good understanding of the difference between core Javascript syntax and Javascript environment API as decribed &lt;a href="https://www.apparentdev.com/journey-of-a-javascript-samurai-s01-e01/"&gt;here&lt;/a&gt; will help you understand if what you need is a polyfill or a transpiler.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Please reach out to me on &lt;a href="https://www.linkedin.com/in/ibrahim-alausa-624a47140/"&gt;LinkedIn&lt;/a&gt; or &lt;a href="https://twitter.com/apparent_dev"&gt;Twitter&lt;/a&gt; for questions, comments, and feedback. I would love to hear and learn from you too.&lt;/p&gt;

&lt;p&gt;Keep learning 💪🏿.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>motivation</category>
    </item>
    <item>
      <title>The big mistake I made while trying to get that first software job.</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Wed, 04 Mar 2020 19:52:58 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/the-big-mistake-i-made-while-trying-to-get-that-first-software-job-5891</link>
      <guid>https://dev.to/tosinibrahim96/the-big-mistake-i-made-while-trying-to-get-that-first-software-job-5891</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;I’m Ibrahim Alausa, a software developer from Nigeria.&lt;/p&gt;

&lt;p&gt;When I decided to become a software developer, I researched the programming languages I should be familiar with to increase my chances of getting a job in Nigeria and noticed many companies were looking for PHP(Laravel) and Javascript(JQuery, React, and NodeJS) developers. I learned just enough to get myself a role at any company.&lt;/p&gt;

&lt;p&gt;After almost a year of studying, reading articles, watching tutorials, attending meetups and most importantly coding, I finally got a job 🎉 🎉🎉 .&lt;br&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/photos/p-I9wV811qk"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aq35p-V_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1454486837617-ce8e1ba5ebfe%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1052%26q%3D80" alt="Happy person photo by Andre Hunter on Unsplash" width="880" height="585"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;After working professionally for the company for about 9 months, I was comfortable with a couple of things including&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Build user-ready features with ReactJS and Redux.&lt;/li&gt;
&lt;li&gt;  Convert mockups to functional User Interface,&lt;/li&gt;
&lt;li&gt;  Became familiar with building APIs.&lt;/li&gt;
&lt;li&gt;  Write Tests using Jest, Mocha, and Chai&lt;/li&gt;
&lt;li&gt;  A lot more :)
 
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Then there was a lay-off
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/photos/BuNWp1bL0nc"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iW1SLuyT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1493836512294-502baa1986e2%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1067%26q%3D80" alt="Sad person photo by Nik Shuliahin on Unsplash" width="880" height="574"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, there was a massive lay-off in the company and I had to start searching for a new job. I thought it would be a smooth ride since I had some skills on my toolbelt, however as time went on I realized the saying, Job search itself is a full-time job is a very accurate one. Believe me when I say It was not as easy as I thought.&lt;/p&gt;

&lt;p&gt;After attending a lot of interviews during this period, I realized that there are lots of gaps in my knowledge. Many Interviewers didn’t just want to know if I can build and deliver features with my stack. They also wanted to make sure I have a concrete understanding of important concepts about the tools and programming languages.&lt;/p&gt;

&lt;h4&gt;
  
  
  A few questions from several interviews
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;  What are closures in javascript?&lt;/li&gt;
&lt;li&gt;  Please can you explain the concept of hoisting in javascript?&lt;/li&gt;
&lt;li&gt;  As a react developer, what would you call a &lt;em&gt;SIDE EFFECT&lt;/em&gt; in your application?&lt;/li&gt;
&lt;li&gt;  As someone familiar with redux, please describe the thunk in redux?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those are just a few from a lot of questions I was asked at different interviews. Since I could not accurately answer many of these questions, it was very evident that I didn't have a firm understanding of certain concepts.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The problem was my learning approach
&lt;/h3&gt;

&lt;p&gt;These interviews made me realize that the problem was my approach to learning programming when I was trying to get that first job as a software developer, I focused mainly on knowing how to implement a feature and get the job done.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/photos/TgjSku4-g6Q"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1nYvv-Zk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1522292923399-bf8ddbd6e4e2%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D700%26q%3D80" alt="The End photo by Matt Botsford on Unsplash" width="700" height="875"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;I never considered having an in-depth study of any technology I was using, to learn about how it fits with others. I just needed to get a job with a steady monthly income. I never recognized it, but the same mindset stuck with me even after getting my first job, so it was no surprise that I found it difficult to explain core concepts concerning the technologies I was working with every day.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  My new learning strategy
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;If I can't explain it totally, I don't understand it well enough.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;This platform will serve as a way for me to expand on whatever I learn extensively, just like I’m teaching a 5-year-old. I can't wait to experience the light bulb moments.&lt;/p&gt;

&lt;p&gt;To make sure I fill up my previous knowledge gaps, I have decided to become a Newbie once again 😎 . I will start learning web development from the basics with a primary focus on front-end technologies. I’m starting from where it all began, &lt;em&gt;the internet&lt;/em&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  It's a Wrap
&lt;/h3&gt;

&lt;p&gt;I have a lot of respect and admiration for developers that teach. Especially those that can break down complex concepts and terminologies to anyone who is trying to learn. I don’t think it’s hard to figure out that these people can do these things because they have a solid understanding of the tools they work with and that’s my target.&lt;/p&gt;

&lt;p&gt;Thanks for making it this far. I appreciate it. This is a new start for me and I hope you will also take the time to reflect on your knowledge gaps and work towards having a solid grasp on the programming languages and tools you use every day.&lt;/p&gt;

&lt;p&gt;Keep Coding, Keep Learning 💪🏿 .&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Don't make the same mistake I made while trying to get that first software job. </title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Tue, 03 Mar 2020 11:43:20 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/hello-world-4ac0</link>
      <guid>https://dev.to/tosinibrahim96/hello-world-4ac0</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;I’m Ibrahim Alausa, a software developer from Nigeria.&lt;/p&gt;

&lt;p&gt;When I decided to become a software developer, I researched the programming languages I should be familiar with to increase my chances of getting a job in Nigeria and noticed many companies were looking for PHP(Laravel) and Javascript(JQuery, React, and NodeJS) developers. I learned just enough to get myself a role at any company.&lt;/p&gt;

&lt;p&gt;After almost a year of studying, reading articles, watching tutorials, attending meetups and most importantly coding, I finally got a job 🎉 🎉🎉 .&lt;br&gt; &lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/photos/p-I9wV811qk"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aq35p-V_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1454486837617-ce8e1ba5ebfe%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1052%26q%3D80" alt="Happy person photo by Andre Hunter on Unsplash" width="880" height="585"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;After working professionally for the company for about 9 months, I was comfortable with a couple of things including&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Build user-ready features with ReactJS and Redux.&lt;/li&gt;
&lt;li&gt;  Convert mockups to functional User Interface,&lt;/li&gt;
&lt;li&gt;  Became familiar with building APIs.&lt;/li&gt;
&lt;li&gt;  Write Tests using Jest, Mocha, and Chai&lt;/li&gt;
&lt;li&gt;  A lot more :)
 
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Then there was a lay-off
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/photos/BuNWp1bL0nc"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iW1SLuyT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1493836512294-502baa1986e2%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1067%26q%3D80" alt="Sad person photo by Nik Shuliahin on Unsplash" width="880" height="574"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Unfortunately, there was a massive lay-off in the company and I had to start searching for a new job. I thought it would be a smooth ride since I had some skills on my toolbelt, however as time went on I realized the saying, Job search itself is a full-time job is a very accurate one. Believe me when I say It was not as easy as I thought.&lt;/p&gt;

&lt;p&gt;After attending a lot of interviews during this period, I realized that there are lots of gaps in my knowledge. Many Interviewers didn’t just want to know if I can build and deliver features with my stack. They also wanted to make sure I have a concrete understanding of important concepts about the tools and programming languages.&lt;/p&gt;

&lt;h4&gt;
  
  
  A few questions from several interviews
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;  What are closures in javascript?&lt;/li&gt;
&lt;li&gt;  Please can you explain the concept of hoisting in javascript?&lt;/li&gt;
&lt;li&gt;  As a react developer, what would you call a &lt;em&gt;SIDE EFFECT&lt;/em&gt; in your application?&lt;/li&gt;
&lt;li&gt;  As someone familiar with redux, please describe the thunk in redux?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those are just a few from a lot of questions I was asked at different interviews. Since I could not accurately answer many of these questions, it was very evident that I didn't have a firm understanding of certain concepts.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The problem was my learning approach
&lt;/h3&gt;

&lt;p&gt;These interviews made me realize that the problem was my approach to learning programming when I was trying to get that first job as a software developer, I focused mainly on knowing how to implement a feature and get the job done.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://unsplash.com/photos/TgjSku4-g6Q"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1nYvv-Zk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1522292923399-bf8ddbd6e4e2%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D700%26q%3D80" alt="The End photo by Matt Botsford on Unsplash" width="700" height="875"&gt;&lt;/a&gt;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;I never considered having an in-depth study of any technology I was using, to learn about how it fits with others. I just needed to get a job with a steady monthly income. I never recognized it, but the same mindset stuck with me even after getting my first job, so it was no surprise that I found it difficult to explain core concepts concerning the technologies I was working with every day.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  My new learning strategy
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;If I can't explain it totally, I don't understand it well enough.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;This platform will serve as a way for me to expand on whatever I learn extensively, just like I’m teaching a 5-year-old. I can't wait to experience the light bulb moments.&lt;/p&gt;

&lt;p&gt;To make sure I fill up my previous knowledge gaps, I have decided to become a Newbie once again 😎 . I will start learning web development from the basics with a primary focus on front-end technologies. I’m starting from where it all began, &lt;em&gt;the internet&lt;/em&gt;.&lt;br&gt;
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  It's a Wrap
&lt;/h3&gt;

&lt;p&gt;I have a lot of respect and admiration for developers that teach. Especially those that can break down complex concepts and terminologies to anyone who is trying to learn. I don’t think it’s hard to figure out that these people can do these things because they have a solid understanding of the tools they work with and that’s my target.&lt;/p&gt;

&lt;p&gt;Thanks for making it this far. I appreciate it. This is a new start for me and I hope you will also take the time to reflect on your knowledge gaps and work towards having a solid grasp on the programming languages and tools you use every day.&lt;/p&gt;

&lt;p&gt;Keep Coding, Keep Learning 💪🏿 .&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>productivity</category>
      <category>reflection</category>
      <category>knowledgegaps</category>
    </item>
    <item>
      <title>This is day 2, Still haven't written a single line of code for this codewars challenge</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Thu, 22 Aug 2019 23:09:05 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/this-is-day-2-still-haven-t-written-a-single-line-of-code-for-this-codewars-challenge-811</link>
      <guid>https://dev.to/tosinibrahim96/this-is-day-2-still-haven-t-written-a-single-line-of-code-for-this-codewars-challenge-811</guid>
      <description>&lt;p&gt;As a junior developer, One of the pieces of advice I often read about how to improve my skills is to solve coding challenges. I started doing this about a week ago and at the beginning of this week, I decided to start picking questions that are above my current level. I have solved 1 and then yesterday I picked the next one. Believe me when I say, from yesterday up until this moment, I haven't written a single line of code because I have absolutely no idea on how to solve the problem. I am not a maths genius, but at least I know how to solve my basic maths problems, but the question is about Fibonacci😱and the help resources link to even a more confusing concept that I just heard about. Golden Ratio 😓.&lt;/p&gt;

&lt;p&gt;I could just google the solution, but I feel like I won't be learning anything then. I could also just skip the question, but what if I face the same challenge with the next question and I press the skip button again, then I won't be improving myself since I will only be working on problems I can solve. &lt;/p&gt;

&lt;p&gt;What do you do when you are faced with this kind of problem?&lt;/p&gt;

&lt;p&gt;What's the best approach to make sure I keep learning?&lt;/p&gt;

&lt;p&gt;I'd really appreciate any advice that will help🙏&lt;/p&gt;

</description>
      <category>challenge</category>
      <category>codewars</category>
    </item>
    <item>
      <title>My first portfolio is now LIVE!!</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Fri, 16 Aug 2019 15:20:37 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/my-first-portfolio-is-now-live-4d13</link>
      <guid>https://dev.to/tosinibrahim96/my-first-portfolio-is-now-live-4d13</guid>
      <description>&lt;p&gt;A very big thank you to the &lt;a href="https://skillpathway.thinkific.com/courses/frontend-development-crash-course"&gt;Skill Pathway&lt;/a&gt; team for this great course that walked me through building my first portfolio. I'll definitely continue to improve this site as I gain more skills and also purchase a custom domain when in future. For me, I learnt a lot about bootstrap and also how to write SCSS. Even if I don't have any world-class project on my portfolio yet lol.&lt;/p&gt;

&lt;p&gt;I feel on top of the world. I'm dreaming of my portfolio redesign blog post already and I am very sure by that time, I would have great projects to showcase because I never stop learning.&lt;/p&gt;

&lt;p&gt;Please check it out &lt;a href="https://dev-alawish.netlify.com/"&gt;here&lt;/a&gt; and tell me how I can make it even better. Thanks so much 🙏.&lt;/p&gt;

</description>
      <category>newdev</category>
      <category>portfolio</category>
      <category>skillpathway</category>
    </item>
    <item>
      <title>Now I now know why I Can access Facebook from anywhere in the world</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Thu, 25 Apr 2019 11:38:33 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/now-i-now-know-why-i-can-access-facebook-from-anywhere-in-the-world-26jg</link>
      <guid>https://dev.to/tosinibrahim96/now-i-now-know-why-i-can-access-facebook-from-anywhere-in-the-world-26jg</guid>
      <description>&lt;p&gt;So, I am actually learning the fundamentals of the internet from &lt;a href="http://www.internetfundamentals.com" rel="noopener noreferrer"&gt;www.internetfundamentals.com&lt;/a&gt; and the first lesson is about client and servers. To solidify my understanding, I’m trying to explain to myself with this note by using Facebook as a case study.&lt;/p&gt;

&lt;p&gt;If Mark Zuckerberg designed facebook from his computer,  how come I have access to the same application from Nigeria? &lt;br&gt;
Is he making use of some kind of computer that can be accessed from anywhere in the world?&lt;br&gt;
But, wait a minute, he definitely can’t be using the same computer system he was using back then right?..ooh...I get it..he just transferred the files to his new system with a flash drive and did some kind of configuration I don’t know about on his new system to make Facebook available for anyone in the world.&lt;/p&gt;

&lt;p&gt;At least that’s what I thought Mark Zuckerberg did until I heard about these two words CLIENT and SERVER. As web developers, we build our applications with computer systems that are right in front of us (Client), but how do we make them accessible to anyone, anywhere in the world? It turns out that we need to actually move these apps to a place or should I say another system that has the ability to make sure someone from an entirely different continent has access to our app (Server).&lt;/p&gt;

&lt;p&gt;Well, at least now I know Mark Zuckerberg used a client computer to build Facebook and then moved it to a server so I can have access to it from Nigeria. Thanks, Mark.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when I want to view the home page of facebook
&lt;/h2&gt;

&lt;p&gt;From what I understand so far, here’s an illustration describing the interaction between my computer system(client) and the computer system where Mark Zuckerberg uploaded the files containing facebook’s code.&lt;br&gt;
When I type in &lt;a href="http://www.facebook.com" rel="noopener noreferrer"&gt;www.facebook.com&lt;/a&gt; on the address bar, it initiates a conversation between my system (client) and the server and it’s something like this.&lt;/p&gt;

&lt;p&gt;My computer: Hey server, I need the homepage of Facebook, can you help me with that?&lt;/p&gt;

&lt;p&gt;Server: Here you go buddy, here’s the homepage. &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%2Fi.imgur.com%2Fup5gY8p.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%2Fi.imgur.com%2Fup5gY8p.png" alt="Facebook homepage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s clarify here, the server does not actually send the homepage as we see in the image, it sends a bunch of files that are interpreted by the browser to form the homepage we see. We can actually take a look at all the files sent by the server after our request was made..yeah!!!&lt;/p&gt;

&lt;p&gt;I am actually using google chrome browser, but I am sure the commands might be similar for other browsers. &lt;br&gt;
press Command+Option+C (Mac) or Control+Shift+C (Windows, Linux).&lt;br&gt;
Navigate to the network tab and reload the page &lt;/p&gt;

&lt;p&gt;Now, we can see the files, images, fonts that make up the Facebook homepage.&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%2Fi.imgur.com%2FrXscirD.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%2Fi.imgur.com%2FrXscirD.png" alt="Dev tools network tab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s play with this a little.
&lt;/h2&gt;

&lt;p&gt;Right-click on the first CSS file and select BLOCK REQUEST URL to exclude the file when the page reloads.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FIMKcBrp.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%2Fi.imgur.com%2FIMKcBrp.png" alt="Dev tools network tab"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now RELOAD the page and see how our facebook homepage looks like after blocking that CSS file&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%2Fi.imgur.com%2F96NS7WW.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%2Fi.imgur.com%2F96NS7WW.png" alt="Facebook page with only little CSS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Woow...This is what my facebook homepage looks like after excluding that CSS file from loading.&lt;/p&gt;

&lt;p&gt;This is my basic understanding of how we access websites from anywhere in the world. If there’s any correction you feel I should make or any additions, I’ll appreciate the feedback. Thanks.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>notetaking</category>
    </item>
    <item>
      <title>Codebase is too large. Any tips on how you quickly understood existing codebase on your first job?</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Tue, 19 Mar 2019 14:32:00 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/codebase-is-too-large-any-tips-on-how-you-quickly-understood-existing-codebase-on-your-first-job-1d3g</link>
      <guid>https://dev.to/tosinibrahim96/codebase-is-too-large-any-tips-on-how-you-quickly-understood-existing-codebase-on-your-first-job-1d3g</guid>
      <description>&lt;p&gt;Yesterday was the beginning of a new chapter in my career. I was given a warm welcome by the team I'll be working with on my first job. It's a full-stack role where the team uses React/Redux on the front-end and Laravel on the backend. &lt;/p&gt;

&lt;h2&gt;
  
  
  Where do I need help?
&lt;/h2&gt;

&lt;p&gt;First, so far, I have always started all my projects on my own because I was using them for practice. Now all the coding tutorials and practice turned into a job and words cannot express how happy I am. Here's the challenge, There's an existing codebase I have to jump on, understand and contribute. I have been given 1 week to familiarize myself with everything and I'll be assigned a task on Monday, next week.&lt;/p&gt;

&lt;p&gt;Second, I have only gone through tutorials and built minimal APIs with NodeJS and express but the team uses Laravel. I haven't worked with Laravel before now, so any advice, resources on building APIs with Laravel framework will be appreciated. They also use a TDD approach so I'll appreciate any advice and resource that can get me started on TDD with Laravel API. &lt;/p&gt;

</description>
      <category>firstjob</category>
      <category>confused</category>
      <category>help</category>
    </item>
    <item>
      <title>A new beginning for me</title>
      <dc:creator>Ibrahim Alausa</dc:creator>
      <pubDate>Sun, 17 Mar 2019 12:58:07 +0000</pubDate>
      <link>https://dev.to/tosinibrahim96/a-new-beginning-for-me-3f0c</link>
      <guid>https://dev.to/tosinibrahim96/a-new-beginning-for-me-3f0c</guid>
      <description>&lt;p&gt;So, I am starting my first "Real Project" tomorrow at &lt;a href="https://andela.com/" rel="noopener noreferrer"&gt;Andela Nigeria&lt;/a&gt;. Up until now, It's been tutorials and dummy projects I work on and admire by myself 😂😂. I'll be using my blog posts to serve as a progress tracker. I'll document new thing I learn and I know looking back One year from today, I'll appreciate how far I've come. Two awesome people have really influenced my decision and I'll love to say Thank You! 🤝&lt;/p&gt;

&lt;p&gt;The first person is &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__2857"&gt;
    &lt;a href="/kaydacode" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__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%2F2857%2Faec6d4ba-b8c3-442f-b954-24c9932ddf30.JPG" alt="kaydacode image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/kaydacode"&gt;Kim Arnett &lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/kaydacode"&gt;Kim Arnett [she/her] leads the mobile team at Deque Systems, bringing expertise in iOS development and a strong focus on accessibility, user experience, and team dynamics.&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 for her awesome post.&lt;br&gt;
&lt;div class="ltag__link"&gt;
  &lt;a href="/kaydacode" 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%2F2857%2Faec6d4ba-b8c3-442f-b954-24c9932ddf30.JPG" alt="kaydacode"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/kaydacode/5-reasons-you-should-write-that-blog-post-24ib" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;5 Reasons You Should Write That Blog Post&lt;/h2&gt;
      &lt;h3&gt;Kim Arnett  ・ Jun 19 '18&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#career&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;
&lt;br&gt;
This made me understand that even if I feel like I'm just beginning my journey, My experience is unique and there are some people who are presently at the stage I was about six months back when it was still about learning from a lot of tutorials and building as much "stupid" projects as possible just to make sure I get better. Thanks so much, Kim.

&lt;p&gt;Secondly, thanks to &lt;/p&gt;
&lt;div class="ltag__user ltag__user__id__22532"&gt;
    &lt;a href="/helenanders26" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__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%2F22532%2F09e84050-6dae-4c1c-82f0-eefe67148c23.jpg" alt="helenanders26 image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/helenanders26"&gt;Helen Anderson&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/helenanders26"&gt;Data wrangler by day, tag moderator by night &lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 for her awesome post &lt;div class="ltag__link"&gt;
  &lt;div class="ltag__link__content"&gt;
    &lt;div class="missing"&gt;
      &lt;h2&gt;Article No Longer Available&lt;/h2&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
 and in that post, she talked about how blogging helps to reinforce learning or understanding of your chosen technology or tool and definitely a lot of other pieces of advice. I'll make sure I try as much as possible to put them into practice as I start this journey. Thanks, Helen.

&lt;p&gt;Finally, I'll be working with Laravel, React and Redux on this new team. I'm pretty comfortable now with React and Redux but I learnt NodeJs when trying to understand how APIs work. Any resource you think would get me up to speed in building APIs with Laravel would be highly appreciated. Thanks so much guys. Much love from me to the &lt;a href="https://dev.to"&gt;dev.to&lt;/a&gt; family🙏.&lt;/p&gt;

</description>
      <category>newdev</category>
      <category>newbeginning</category>
      <category>thankyou</category>
    </item>
  </channel>
</rss>
