<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nikhil K on Medium]]></title>
        <description><![CDATA[Stories by Nikhil K on Medium]]></description>
        <link>https://medium.com/@nikhilajayk?source=rss-c15a7374be21------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JTtciO0RAG-iIf1SkAqqwQ.jpeg</url>
            <title>Stories by Nikhil K on Medium</title>
            <link>https://medium.com/@nikhilajayk?source=rss-c15a7374be21------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 19:34:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikhilajayk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating your first gRPC .NET Core Client and Server App using Visual Studio or Visual Studio Code]]></title>
            <link>https://medium.com/@nikhilajayk/creating-your-first-grpc-net-core-client-and-server-app-using-visual-studio-or-visual-studio-code-293a6a5a5f7?source=rss-c15a7374be21------2</link>
            <guid isPermaLink="false">https://medium.com/p/293a6a5a5f7</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[net-core]]></category>
            <category><![CDATA[visual-studio]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Nikhil K]]></dc:creator>
            <pubDate>Sat, 30 Mar 2019 19:47:19 GMT</pubDate>
            <atom:updated>2019-03-30T19:47:19.556Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIT-5yS5Kwhnc4g9XdcicQ.png" /></figure><h3>Creating your first gRPC .NET Core Client and Server App using Visual Studio or Visual Studio Code</h3><p>This is a quick setup guide for creating and running .NET core apps that use the gRPC framework for communication. This guide includes the setup for Visual Studio 2017 or above(Windows / MacOS) as well as Visual Studio Code (Windows / MacOS / Linux).</p><p>This tutorial includes the following:</p><ol><li>Creating your first protocol buffers</li><li>IDE Environment Setup (Visual Studio &amp; VS Code)</li><li>Generating C# code from protocol buffers</li><li>Creating the Server</li><li>Creating the Client</li></ol><p>In this tutorial, we will be creating a simple Account management system that will retrieve an employee’s first and last name based on the employee’s ID.</p><p>Prerequisites:</p><ol><li>Introductory knowledge of gRPC</li><li>Introductory knowledge of .NET Core</li><li>Visual Studio 2017 and above for .NET Core / VSCode</li></ol><h3>Step 1 : Creating your first protocol buffers</h3><p>A protocol buffer defines the request and response parameters for client-server interaction. In this case, a service (Account Service) will be defined that would facilitate data exchange between the client and server by defining the request and response parameters.</p><blockquote>“Protocol buffers are easy to read, flexible contracts that define client — server interaction via gRPC.”</blockquote><pre>syntax = &quot;proto3&quot;;<br></pre><pre>service AccountService {<br>  rpc GetEmployeeName (EmployeeNameRequest) returns (EmployeeName);<br>}<br></pre><pre>message EmployeeNameRequest {<br>  string emp_id = 1;<br>}<br></pre><pre>message EmployeeName {<br>  string first_name = 1;<br>  string last_name = 2;<br>}</pre><p>The code snippet above contains the following:</p><ul><li>A service (AccountService) that serves as the entry point and has all the available rpc calls.</li><li>An rpc (GetEmployeeName) which accepts a request message (EmployeeNameRequest) and returns a response message (EmployeeName).</li><li>messages (EmployeeNameRequest and EmployeeName) that contain various data fields which are used for data format definition (similar to properties in classes).</li></ul><p>More information about protocol buffers can be found <a href="https://developers.google.com/protocol-buffers/docs/proto3">here</a>.</p><p>Save the following as “Accounts.proto” within a folder named protos. This folder will later be moved to the project, once the project is setup.</p><h3>Step 2 : IDE Environment Setup (Visual Studio &amp; VS Code)</h3><p>The environment setup includes the following:</p><ol><li>Basic IDE Setup</li><li>Setting up .NET Core</li><li>Installing gRPC dependencies</li></ol><p>Basic IDE Setup</p><p>For VS Code ensure that C# extension for Visual Studio Code has been installed.The extension can be found in the VS Code marketplace within the IDE or can be downloaded from <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp">here</a>.</p><p>Setting up .NET Core</p><p>.NET core can be downloaded for all platforms <a href="https://dotnet.microsoft.com/download">here</a>. Note that VS 2017 would already have this installed.</p><p>Installing gRPC dependencies(VS Code)</p><p>For VS Code, run the following commands to set up the project and it’s dependencies. Create a new Project/Folder name: Accounts. This will be the gRPC server.</p><pre>dotnet new console<br>dotnet add package Grpc<br>dotnet add package Grpc.Core<br>dotnet add package Grpc.Tools<br>dotnet add package Google.Protobuf<br>dotnet restore</pre><p>From the snippet above:</p><ul><li>“dotnet new console”: Creates the console app.</li><li>“dotnet add package Grpc , Grpc.Core and Google.Protobuf”: Installs the necessary gRPC dependencies</li><li>“dotnet add package Grpc.Tools”: Downloads the tools required to generate C# code from the protocol buffers.</li><li>“dotnet restore”: Restores necessary packages.</li></ul><p>Installing gRPC dependencies (VS2017 and above)</p><p>In Visual studio, create a new .NET Core console project named Accounts. Add the following dependencies using the NuGet package manager: (Grpc , Grpc.Core, Google.Protobuf and Grpc.Tools)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/292/0*UI0gyDmwI3x_V7jr" /></figure><p>These packages can be added by accessing Tools-&gt;NuGet Package Manager -&gt; Manage NuGet Packages for Solution…</p><h3>Step 3 : Generating C# code from protocol buffers</h3><p>The C# code is generated from the protocol buffers using the protoc executable that is bundled along with the Grpc.Tools package.</p><p>Before generating the code, ensure that the protos folder that contains the protocol buffer created earlier is placed within the project directory structure. Create 2 other folders in the project : controller and modules. This will be re-visited later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*13L45MGp0JwW9Pkv1DyqpQ.png" /></figure><p>Your project structure should now look similar to the image(Left: Visual Studio , Right: VS Code).</p><p>If Grpc.Tools is installed correctly, the executable can be found in the following locations, based on the type of Operating System:</p><p>Mac (~/.nuget/packages) Windows (%UserProfile%\.nuget\packages) Linux (~/.nuget/packages)</p><p>Using the terminal / powershell, navigate to the project folder(Accounts) and run the command mentioned below. In the command which is specifically for the Windows OS, “C:\Users\Nikhil\” is the %UserProfile% variable, and needs to be altered accordingly based on the type of operating system and the username. Make sure that the changes are done for both the protoc and plugin before running the command.</p><pre><em>C:\Users\Nikhil\</em>.<em>nuget\packages\grpc</em>.<em>tools\1</em>.<em>19</em>.<em>0\tools\windows_x64\protoc</em>.<em>exe</em> --<em>proto_path=protos</em> --<em>grpc_out=protos</em> --<em>csharp_out=protos</em> --<em>csharp_opt=file_extension=</em>.<em>g</em>.<em>cs</em> <em>Accounts</em>.<em>proto</em> --<em>plugin=protoc</em>-<em>gen</em>-<em>grpc=C:\Users\Nikhil\</em>.<em>nuget\packages\grpc</em>.<em>tools\1</em>.<em>19</em>.<em>0\tools\windows_x64\grpc_csharp_plugin</em>.<em>exe</em></pre><p>The protoc command includes the following:</p><ol><li>— proto_path: Sets the path where the protocol buffer resides(in this case ,protos)</li><li>— grpc_out: Sets the path for gRPC file output.</li><li>— csharp_out: Sets the path for C# file output.</li><li>— csharp_opt: Extra options.In this case,it sets the C# output extension to g.cs.</li><li>Accounts.proto :Specifies the protocol buffer name.</li><li>— plugin: The plugin to be used, in this case the grpc_csharp_plugin.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*JpYFmcD5fwKtTnBT" /></figure><p>If successful, no message will be displayed. In the protos folder, two files will be generated(Accounts.g.cs and AccountsGrpc.cs). The generated C# files contains the classes and attributes necessary to implement the contract.</p><h3>4. Creating the Server</h3><p>Before creating the server, create a sample C# response class EmployeeData.cs with basic values in the modules folder as shown below:</p><pre>using System;<br>namespace Accounts<br>{<br>    public class EmployeeData<br>    {<br>        public EmployeeName GetEmployeeName(EmployeeNameRequest request)<br>        {<br>            EmployeeName empName = new EmployeeName();</pre><pre>            switch(request.EmpId)<br>            {<br>                case &quot;1&quot;:            <br>                    empName.FirstName=&quot;John&quot;;<br>                    empName.LastName=&quot;Doe&quot;;<br>                break;<br></pre><pre>                case &quot;2&quot;:            <br>                    empName.FirstName=&quot;Dave&quot;;<br>                    empName.LastName=&quot;Williams&quot;;<br>                break;<br></pre><pre>                default:<br>                break;<br>            }<br>            return empName;<br>        }<br>    }<br>}</pre><p>EmployeeName and EmployeeNameRequest will be automatically referenced from the generated C# files. The method GetEmployeeName() contains the business logic. If emp ID is passed as 1, the response will have first name as “John” and last name as “Doe”.</p><p>Create a class Controller.cs in the controller folder. Add the following code snippet:</p><pre>using System;<br>using System.Threading.Tasks;<br>using Grpc.Core;<br></pre><pre>namespace Accounts<br>{<br>    class AccountsImpl: AccountService.AccountServiceBase<br>    {<br>        <em>// Server side handler of the GetEmployeeName RPCpublic override Task&lt;EmployeeName&gt; GetEmployeeName(EmployeeNameRequest request, ServerCallContext context)</em><br>        {<br>            EmployeeData empData = new EmployeeData();<br>            return Task.FromResult( empData.GetEmployeeName(request) );<br>        }<br>    }<br>}</pre><p>This class implements the AccountServiceBase class, and will be bound to the server. When the server receives a request for GetEmployeeName, it will pass the data to the previously created class EmployeeData, and return the appropriate response back to the caller.</p><p>Finally, set up the server bindings to the controller. Add the following code snippet to the entry point of the project(In this case, Program.cs)</p><pre>using System;<br>using Grpc.Core;<br></pre><pre>namespace Accounts<br>{<br>    class Program<br>    {<br>        const int Port = 50051;<br>        public static void Main(string[] args)<br>        {<br>            try<br>            {    <br>                Server server = new Server<br>                {<br>                    Services = { AccountService.BindService(new AccountsImpl()) },<br>                    Ports = { new ServerPort(&quot;localhost&quot;, Port, ServerCredentials.Insecure) }<br>                };<br>                server.Start();<br></pre><pre>                Console.WriteLine(&quot;Accounts server listening on port &quot; + Port);<br>                Console.WriteLine(&quot;Press any key to stop the server...&quot;);<br>                Console.ReadKey();<br></pre><pre>                server.ShutdownAsync().Wait();<br>            }<br>            catch(Exception ex)<br>            {<br>                Console.WriteLine($&quot;Exception encountered: {ex}&quot;);<br>            }<br>        }<br>    }    <br>}</pre><p>Services = { AccountService.BindService(new AccountsImpl()) } binds the controller to the server, which is internally referencing the business logic that was setup earlier. Run the project to start the server. For VS Code use the command “dotnet run”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/0*69gnNrJaiazap3iy" /></figure><p>If the console output is similar to the image then the server is now up and running.</p><h3>5. Creating the Client</h3><p>Set up another project named Client and follow the same steps as mentioned in Step 2 to install all necessary packages related to gRPC(Grpc.Tools not required). The protos folder along with the files need not be regenerated, directly copy the protos folder to the new project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/0*yRVy71kTbSltA9Cr" /></figure><p>Your project structure should now look similar to the image(Left: Visual Studio , Right: VS Code).</p><p>Add the following code snippet to Program.cs:</p><pre>using Grpc.Core;<br>using System;<br></pre><pre>namespace Client<br>{<br>    class Program<br>    {<br>        static void Main(string[] args)<br>        {<br>            try<br>            {<br>                Channel channel = new Channel(&quot;127.0.0.1:50051&quot;, ChannelCredentials.Insecure);<br>                var client = new AccountService.AccountServiceClient(channel);<br>                EmployeeName empName = client.GetEmployeeName(new EmployeeNameRequest { EmpId = &quot;1&quot; });<br></pre><pre>                if (empName == null || string.IsNullOrWhiteSpace(empName.FirstName) || string.IsNullOrWhiteSpace(empName.LastName))<br>                {<br>                    Console.WriteLine(&quot;Employee not found.&quot;);<br>                }<br>                else<br>                {<br>                    Console.WriteLine($&quot;The employee name is {empName.FirstName} {empName.LastName}.&quot;);<br>                }<br>                channel.ShutdownAsync().Wait();<br>                Console.WriteLine(&quot;Press any key to exit...&quot;);<br>                Console.ReadKey();<br>            }<br>            catch(Exception ex)<br>            {<br>                Console.WriteLine($&quot;Exception encountered: {ex}&quot;);<br>            }<br>        }<br>    }<br>}</pre><p>The client creates a channel and passes the request object. In this case, EmpId is passed as 1. Ensure that the server is running before the client app is executed. The expected console output is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*uWMKnrmcapwtRWuy" /></figure><h3>Conclusion</h3><p>gRPC has multiple benefits when it comes to cross service communications, as compared to conventional methods. A quick way to start learning is by referring to the well composed <a href="https://grpc.io/docs/">official documentation</a>. The source code for both the projects are available on <a href="https://github.com/nikhilajayk/gRPCDotnetCore">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=293a6a5a5f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quick Setup Guide: Aerospike on Windows in minutes, using Docker]]></title>
            <link>https://medium.com/@nikhilajayk/quick-setup-guide-aerospike-on-windows-in-minutes-using-docker-b45840f8ce2c?source=rss-c15a7374be21------2</link>
            <guid isPermaLink="false">https://medium.com/p/b45840f8ce2c</guid>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[data-stores]]></category>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[aerospike]]></category>
            <dc:creator><![CDATA[Nikhil K]]></dc:creator>
            <pubDate>Sun, 03 Feb 2019 18:17:39 GMT</pubDate>
            <atom:updated>2019-02-03T18:21:23.781Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a quick setup guide for running and interacting with Aerospike on your local PC. This tutorial includes the following:</p><ol><li>Setting up the Aerospike-server container.</li><li>Aerospike namespace configuration.</li><li>Volume mounting Aerospike configuration files and data to your local machine for data persistence.</li><li>Connect to Aerospike using aql (Aerospike Query Language)</li></ol><p>Prerequisites:</p><ol><li>Docker Desktop for Windows 10 Professional Users / (Docker Toolbox for Windows 10 Home or below) <a href="https://www.docker.com/products/docker-desktop">Download link</a></li></ol><h3><strong>Step 1: Setting up the Aerospike-server container</strong></h3><p>Run the following command on Powershell to setup Aerospike-server:</p><p>docker run -tid --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server</p><p>Once Aerospike is setup completely, check the status by using the following command:</p><pre>docker ps -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sCd9p27ioQ_cDW33VoepDQ.png" /><figcaption>If the status of the container is Up, we’re good to go to step 2.</figcaption></figure><p>In my case, the container id created is <strong>605f9cf8106d. </strong>Take note of your respective id as it would be required in the next step.</p><h3><strong>Step 2: Aerospike namespace configuration</strong></h3><p>The Aerospike namespace is configured in the aerospike.conf file. This file is located in the /etc/aerospike directory in the container.</p><p>In this tutorial we will save this locally to ensure that we don’t re create it each time a new container is spawned.</p><p>To begin with, create the following folder structure in the D Drive:</p><ol><li>Aerospike/data</li><li>Aerospike/config</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*nRAnXcii8yA8TQQrXZBVrg.png" /></figure><p>Once this is done, store the aerospike.conf file from the container into the config folder as created above, by running the following command(Powershell):</p><pre>docker cp &lt;containerId&gt;:/etc/aerospike/aerospike.conf D:\Aerospike\config\</pre><p>where &lt;containerId&gt; is your container id , in this case it is :</p><pre>docker cp <strong>605f9cf8106d</strong>:/etc/aerospike/aerospike.conf D:\Aerospike\config\</pre><p>If, successful, the file will be present in the D:\Aerospike\config directory. Open the file with any text editor.</p><p>At the end of the configuration file ,a default namespace configuration will be found as follows:</p><pre>namespace test {<br> replication-factor 2<br> memory-size 1G<br> default-ttl 30d # 5 days, use 0 to never expire/evict.</pre><pre># storage-engine memory</pre><pre># To use file storage backing, comment out the line above and use the<br> # following lines instead.</pre><pre>storage-engine device {<br>  file /opt/aerospike/data/test.dat<br>  filesize 4G<br>  data-in-memory true # Store data in memory in addition to file.<br> }</pre><p>You can either add another one or change the existing default namespace. For this tutorial the existing namespace will be changed to “MyApp”.</p><p>The namespace has multiple parameters such as replication factor, filesize and storage options, most of which will be left as default for this tutorial.</p><p>Make the following changes to the file as shown below(marked in bold):</p><pre>namespace <strong>MyApp</strong> {<br> replication-factor 2<br> memory-size 1G<br> default-ttl 30d # 5 days, use 0 to never expire/evict.</pre><pre># storage-engine memory</pre><pre># To use file storage backing, comment out the line above and use the<br> # following lines instead.</pre><pre>storage-engine device {<br>  file /opt/aerospike/data/<strong>MyApp</strong>.dat<br>  filesize <strong>1G</strong><br>  data-in-memory true # Store data in memory in addition to file.<br> }</pre><p>Note that the filesize has been limited to 1 GB. Change these values according to your use case. Save and close the file.</p><h3><strong>Step 3: </strong>Volume mounting Aerospike configuration files and data to your local machine for data persistence</h3><p>Docker by default doesn&#39;t share the D drive for volume mount. This needs to be configured as per your docker setup.</p><p><strong>For Windows 10 Professional Users</strong>, right click docker on the task bar and enter settings. Click on shared drives and select the D Drive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*tgOe8Esvpn6CqohN4zvRiQ.png" /></figure><p>Provide the necessary permissions and restart docker if prompted.</p><p><strong>For Windows 10 Home users and below</strong> who are using the docker toolbox and VirtualBox, change the configuration as follows:</p><ol><li>Open Oracle VM Virtualbox, click on the settings icon and then click on shared folders.</li></ol><p>2. Add the previously created Aerospike directory as shown in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*iTWyzbXYvKw_WNk5kVXcWQ.png" /></figure><p>In the sub options, select Auto-mount and Make Permanent.</p><p>3. Once done, open the <strong>docker quickstart terminal</strong> and run the following command:</p><pre>docker-machine restart</pre><p>Once restarted, we need to run Aerospike with the new configurations. Remove the currently running container using the command (Powershell):</p><pre>docker rm -f &lt;container id&gt;</pre><p>In this example:</p><pre>docker rm -f <strong>605f9cf8106d</strong></pre><p>(Note : In the future, avoid using rm -f , use docker stop and then rm for a cleaner exit.)</p><p>Setup a new Aerospike container using the following command(Powershell):</p><p>For<strong> </strong>Windows 10 Professional Users with <strong>Docker Desktop</strong> :</p><pre>docker run -tid -v D:\Aerospike\data:/opt/aerospike/data   -v D:\Aerospike\config:/opt/aerospike/etc --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server /usr/bin/asd --foreground --config-file /opt/aerospike/etc/aerospike.conf</pre><p>For lower windows versions using <strong>docker toolbox</strong> :</p><pre>docker run -tid -v /Aerospike/data://opt/aerospike/data   -v /Aerospike/config://opt/aerospike/etc --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server /usr/bin/asd --foregro<br>und --config-file /opt/aerospike/etc/aerospike.conf</pre><p>The following command specifies the volume mounts for Aerospike (data and config respectively) using -v param and the config-file option.</p><p>Once done, run the following command to check the status (Powershell):</p><pre>docker ps -a</pre><p>If the status of the container is Up, then everything has been setup as expected.</p><h3><strong>Step 4: Connect to Aerospike using aql (Aerospike Query Language)</strong></h3><p>To setup aql we need to first find out the I.P of the running Aerospike container.</p><p>To fetch the I.P , run the following command to fetch the container details:</p><pre>docker inspect &lt;container id&gt;</pre><p>In this case it would be:</p><pre>docker inspect <strong>605f9cf8106d</strong></pre><p>This will print the configurations out on the console. Towards the end of the config you will find the IP address.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*bMe5G4_zAjwuMUhs4coimg.png" /></figure><p>In this example, the command resulted in the following IP address as seen in the image (172.17.0.2)</p><p>This IP address will be used to connect to Aerospike by Aerospike Query language, which would help us get started on interacting with Aerospike via console.</p><p>To Setup aql, run the following command (Powershell):</p><pre>docker run -ti --name aerospike-aql --rm aerospike/aerospike-tools aql -h <strong>&lt;container-IP&gt;</strong> aerospike/aerospike-server</pre><p>For this example:</p><pre>docker run -ti --name aerospike-aql --rm aerospike/aerospike-tools aql -h <strong>172.17.0.2</strong> aerospike/aerospike-server</pre><p>(Make sure that the IP is as per your container’s configuration.)</p><p>Once setup correctly, the aql console will start as shown in the image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hJzfMYRkW6YWL9HLkD96w.png" /></figure><p>Aerospike has a syntax similar to SQL. To check the available namespaces, run the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*k8qw3RqfIqaS_86Rs7RUBg.png" /></figure><p>If the results are similar to the image above, the setup is successful.</p><h3><strong>Conclusion</strong></h3><p>Follow these simple steps, and you will be on your way to setting up and interacting with your first Aerospike container. The data created will be stored in the /data directory as configured previously. Any changes to the config in the local drive will reflect upon restarting the container.</p><p>Please note that there are many other ways of setup as well. Although this setup is specific to Windows, most of the commands will be similar in Linux as they&#39;re mostly related to docker.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b45840f8ce2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Back to basics: Why you should use .Equals() instead of == when comparing objects to avoid chaos.]]></title>
            <link>https://medium.com/@nikhilajayk/back-to-basics-why-you-should-use-equals-instead-of-when-comparing-objects-to-avoid-chaos-bde90792c049?source=rss-c15a7374be21------2</link>
            <guid isPermaLink="false">https://medium.com/p/bde90792c049</guid>
            <category><![CDATA[csharp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Nikhil K]]></dc:creator>
            <pubDate>Sat, 26 Jan 2019 18:36:44 GMT</pubDate>
            <atom:updated>2019-01-26T18:36:44.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>Back to basics: Why you should use .Equals() instead of == when comparing objects to avoid chaos.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*vyuF2XN8wJXV1L-b307ZOg.png" /></figure><p>Yes, we all did this initially, especially during our school / college days when we started to learn computer science and programming languages such as C# and Java. The habit of comparing objects (especially strings) using the == operator is a common one and can be found being used even today by seasoned developers.</p><p>In their defense, it surely does seem to serve the purpose and there seems to be no specific harm in doing so. This holds true until you encounter some weird situations, one of which I am going to show you now.</p><p>Here is the general reason why == shouldn&#39;t be used (as per Sonar : The continuous inspection tool)</p><p>“<em>Using the equality (==) and inequality (!=) operators to compare two objects does not check to see if they have the same values. Rather it checks to see if both object references point to exactly the same object in memory. The vast majority of the time, this is not what you want to do.</em>”</p><p>Although the above sentence makes sense, it still doesn&#39;t bother us enough to change the way we code, as long as the result we are expecting doesn&#39;t change.</p><p>However, there is a hidden advantage to using the Equals() method that could save you a lot of trouble.</p><p>Consider a scenario wherein you have to fetch the exam results of a student by accessing an external API, and display an appropriate message to their parents when they access the results page.</p><p>For some weird reason, the external API GetExamResult() returns a string value to indicate the result. “Pass” if the student has cleared all exams, and “Fail” if they haven&#39;t.</p><p>This is how the display student result method would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*6qP8CLempK4_J-feAl4mQA.png" /></figure><p>Here we are using == to compare the result. In most cases, this would work fine.</p><p>Now assume a scenario wherein the student has passed, but the API call malfunctions and returns a null value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*2BnkzX6SlVUo-pvN1Yp2xg.png" /></figure><p>In this case, the == check would return false, which would lead to catastrophic consequences for that student.</p><p>If we were to use the Equals() method here, it would return a <strong>null pointer exception</strong> instead of entering the else block, which should ideally be the case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*I8I026r9zuesJgJ4_hz5-A.png" /></figure><p>This would return a retry message to the user, which is appropriate in this case.</p><p>To conclude, don’t traumatize someone’s parents. Use Equals() instead of == wherever feasible, unless you’re expecting and preemptively handling null values in your code. The source code for this example can be downloaded <a href="https://github.com/nikhilajayk/StringOperation">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bde90792c049" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>