<?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: Ravina Deogadkar</title>
    <description>The latest articles on DEV Community by Ravina Deogadkar (@deogadkarravina).</description>
    <link>https://dev.to/deogadkarravina</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%2F333681%2F0efbc095-ae54-4727-a30f-18bc808c95fe.jpg</url>
      <title>DEV Community: Ravina Deogadkar</title>
      <link>https://dev.to/deogadkarravina</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deogadkarravina"/>
    <language>en</language>
    <item>
      <title>Reflecting my Journey</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Fri, 01 Mar 2024 04:54:00 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/reflecting-my-journey-2cgi</link>
      <guid>https://dev.to/deogadkarravina/reflecting-my-journey-2cgi</guid>
      <description>&lt;p&gt;I started my career without any intention of ending in coding!..&lt;br&gt;
Like all teenagers I was so unsure about my career, all I did was go with the flow. I didn't make it to the Engineering entrance instead I didn't know what I wanted to do. I graduated with a computer science major and that was my baby steps to coding.&lt;/p&gt;

&lt;p&gt;Then I completed a Master's in Computer Application and that was beam to my foundation. Learning new programming languages and developing minor projects started becoming my new hobby. Completing challenges and Hackathons on &lt;a href="https://www.techgig.com/challenge"&gt;Techgig&lt;/a&gt; and &lt;a href="https://www.hackerrank.com/"&gt;Hackerrank&lt;/a&gt; started becoming a passion.&lt;/p&gt;

&lt;p&gt;I started my blogging journey 5 years back with dev.to and I completely became known for it at work. I keep receiving appreciation from my colleagues for my blogs.&lt;/p&gt;

&lt;p&gt;Before starting my blogging journey I was very skeptical about my work. What if someone criticizes it? What if no one reads it?&lt;/p&gt;

&lt;p&gt;To get out of my Imposter Syndrome, I drafted a blog and gave it to my friend to read and he helped me with little bits and pieces and gave his strong shoulder to publish it.&lt;/p&gt;

&lt;p&gt;To my surprise, my first drafted blog &lt;a href="https://dev.to/deogadkarravina/string-compare-or-string-contains-best-way-to-compare-strings-4k2l"&gt;String.Compare() or String.Contains(), the best way to compare strings&lt;/a&gt; has 3579 views to date.&lt;/p&gt;

&lt;p&gt;One of my blogs on &lt;a href="https://dev.to/deogadkarravina/javascript-predicate-and-uses-8pl"&gt;Javascript: Predicate&lt;/a&gt; has 10000+ views to date.&lt;/p&gt;

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

&lt;p&gt;A good ingredient for success for me is supportive friends, family, and colleagues but also self-doubt.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Until you question your skills you won't know what you are capable of.&lt;/p&gt;

&lt;p&gt;And you cannot overcome uncertainty, failures, and fears until you embrace them. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Happy coding to all Women coders out there. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExbmVyaDU4bjA1eXcwNXMyc3pwNXRjY21kZ2Q5cjNreHN1bDU5YjdqNCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/KaNs6mp1uD7qCFlRHJ/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExbmVyaDU4bjA1eXcwNXMyc3pwNXRjY21kZ2Q5cjNreHN1bDU5YjdqNCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/KaNs6mp1uD7qCFlRHJ/giphy.gif" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>wecoded</category>
    </item>
    <item>
      <title>Unleashing the Power of Delegates in C#: Boost Your Programming Skills</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Mon, 25 Dec 2023 10:09:17 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/unleashing-the-power-of-delegates-in-c-boost-your-programming-skills-3ah5</link>
      <guid>https://dev.to/deogadkarravina/unleashing-the-power-of-delegates-in-c-boost-your-programming-skills-3ah5</guid>
      <description>&lt;p&gt;Delegates are like pointers to the method. That means they point to the method's address, which we can call the method. A delegate type is defined using the following three parts. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The name of the method on which a delegate calls.&lt;/li&gt;
&lt;li&gt;Any argument (if any) of a method.&lt;/li&gt;
&lt;li&gt;The return value (if any) of a method. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's look at a simple Publish and Subscribe model using delegates.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;IPublisher.cs&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface IPublisher
{
     public delegate void DateTimeDelegate(DateTime dt);

     public void OnDataPublished();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The IPublisher interface defines the structure of our publisher class. We have a delegate &lt;strong&gt;DateTimeDelegate&lt;/strong&gt; which will accept DateTime parameter. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;ISubscriber.cs&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface ISubscriber
{
     public void DisplayDate(DateTime date);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And our ISubscriber interface defines the structure of the Subscriber class. &lt;strong&gt;DisplayDate&lt;/strong&gt; method accepts parameter type matching with the delegate we declared in IPublisher interface.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Publisher.cs&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Publisher : IPublisher
    {

        private event IPublisher.DateTimeDelegate _datetimeEvent;

        public void OnDataPublished()
        {
            while (true)
            {
                if (_datetimeEvent != null)
                    _datetimeEvent(DateTime.Now);
                Task.Delay(1000).Wait();
            }
        }

        public void Subscribe(IPublisher.DateTimeDelegate dateTimeDelegate)
        {
            _datetimeEvent += dateTimeDelegate;
        }

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

&lt;/div&gt;



&lt;p&gt;In our publisher class, &lt;strong&gt;_datetimeEvent&lt;/strong&gt; parameter of type IPublisher.DateTimeDelegate is being assigned to a parameter of type IPublisher.DateTimeDelegate in Subscribe method.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Subscriber.cs&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Subscriber: ISubscriber
    {
        public void DisplayDate(DateTime date)
        {
            Console.WriteLine("DateTime Today" + date);
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The subscriber class defines the DisplayDate method which simply prints the date.&lt;/p&gt;

&lt;p&gt;We have our publisher and subscriber ready, to connect the dots, in program.cs file add the lines below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var publisher = new Publisher();

var subscriber = new Subscriber();

publisher.Subscribe(subscriber.DisplayDate);

publisher.OnDataPublished();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we are calling publisher.Subscribe method by passing subscriber.DisplayDate as the parameter. OnDataPublished() method call triggers the event. In other words, it calls the delegated method subscriber.DisplayDate().&lt;/p&gt;

&lt;p&gt;This is a short explanation of delegates to know more about delegates and events stay tuned, until then keep coding :)&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Send SMTP email with Node.js using Nodemailer</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Thu, 09 Mar 2023 16:29:55 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/send-smtp-email-with-nodejs-using-nodemailer-45l0</link>
      <guid>https://dev.to/deogadkarravina/send-smtp-email-with-nodejs-using-nodemailer-45l0</guid>
      <description>&lt;p&gt;Lately I was working on open source project that needs integration with &lt;strong&gt;hotmail&lt;/strong&gt; to send emails out to user. I did pick up a story as an learning for me and ended up with creating a demo for this blog. I will like to share my learning below.&lt;/p&gt;

&lt;p&gt;To send email from Node.js code we need to use &lt;a href="https://www.npmjs.com/package/nodemailer" rel="noopener noreferrer"&gt;nodemailer library&lt;/a&gt;. Nodemailer is a module for Node.js applications to allow easy as cake email sending. If you are able to run Node.js version 6 or newer, then you can use Nodemailer. There are no platform or resource specific requirements.&lt;/p&gt;

&lt;p&gt;Also for creating demo, I made use of &lt;a href="https://ethereal.email/create" rel="noopener noreferrer"&gt;Ethereal email&lt;/a&gt; It is fake SMTP service that creates fake email and password for testing purpose and sandboxes the mail box.&lt;/p&gt;

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

&lt;p&gt;You could see all the mails sent to the requested mail in the &lt;a href="https://ethereal.email/messages" rel="noopener noreferrer"&gt;mailbox&lt;/a&gt;. Since it is sandbox environment, mail is not actually received in the real time.&lt;/p&gt;

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

&lt;p&gt;We are going to create '/forgotpassword' api which will send email to user with password reset link.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const transporter = nodemailer.createTransport({
    host: 'smtp.ethereal.email',
    port: 587,
    auth: {
        user: process.env.ETHERAL_EMAIL,
        pass: process.env.ETHERAL_PASSWORD
    }
});

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

&lt;/div&gt;



&lt;p&gt;Email and password are stored and fetched from .env file created in root directory of project. This email and password is used to authenticate and send emails through &lt;a href="https://emailengine.app/?utm_source=ethereal&amp;amp;utm_campaign=ethereal&amp;amp;utm_medium=hero-button" rel="noopener noreferrer"&gt;EmailEngine&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Host in this example is 'smtp.ethereal.email' which could also be gmail, hotmail or office 365.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//gmail
const transporter = nodemailer.createTransport({
    host: 'smtp.gmail.email',
    ....
}

//hotmail
const transporter = nodemailer.createTransport({
    host: 'smtp.hotmail.email',
    ....
}

// office 365
const transporter = nodemailer.createTransport({
    host: 'smtp.office365.com',
    ....
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now we need to call sendMail method on transporter object passing 4 arguments from, to, subject and html.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  const options = {
    from: process.env.ETHERAL_EMAIL,
    to: req.body.email,
    subject: 'Reset Password',
    html: `You are receiving this email because you(maybe someone else) wanted to change your password.\nIf it was not you, ignore this email.`
  };

  transporter.sendMail(options, (err, info) =&amp;gt; {
    if (err) {
        console.log(err);
        return res.status(400).json({ error: "Internal Server Error!" });
    }
    console.log(info.response);

    return res.status(200).json({ success: "Email sent successfully!!" });
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example we are sending plain text email. We can also send html email by wrapping up html tags with strings.&lt;/p&gt;

&lt;p&gt;Let's Test '/forgotpassword' endpoint in postman to verify response.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun1qh4086ar5ohgzlr8o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun1qh4086ar5ohgzlr8o.png" alt="Postman endpoint test" width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And in our mail box all outgoing mails are recorded.&lt;/p&gt;

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

&lt;p&gt;That's it... Happy Coding!&lt;/p&gt;

</description>
      <category>vibecoding</category>
    </item>
    <item>
      <title>WPF: Working with Templates</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Sat, 04 Feb 2023 13:13:06 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/wpf-working-with-templates-1jkb</link>
      <guid>https://dev.to/deogadkarravina/wpf-working-with-templates-1jkb</guid>
      <description>&lt;p&gt;Each control has its own default template which gives it appearance. Template describes overall visual appearance of control. You can easily create your own templates when you want to customize the visual behavior and visual appearance of a control&lt;/p&gt;

&lt;h2&gt;
  
  
  Control Template
&lt;/h2&gt;

&lt;p&gt;Control Template enables you to customize the default appearance and behavior of the control. e.g., Button has an appearance and behavior. Click event or mouse hover event are the behaviors which are fired in response to a click and hover.&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;UserControl x:Class="WpfDevelopment.ControlTemplateEx"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WpfDevelopment"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;Button MinHeight="100" MinWidth="200" Content="Click Me!"&amp;gt;
            &amp;lt;Button.Template&amp;gt;
                &amp;lt;ControlTemplate TargetType="Button"&amp;gt;
                    &amp;lt;Grid&amp;gt;
                        &amp;lt;Ellipse Width="205" Height="105" Fill="Black"&amp;gt;&amp;lt;/Ellipse&amp;gt;

                        &amp;lt;Ellipse Width="200" Height="100" Fill="LightCoral" Name="Button"&amp;gt;&amp;lt;/Ellipse&amp;gt;
                        &amp;lt;ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/&amp;gt;
                    &amp;lt;/Grid&amp;gt;

                    &amp;lt;ControlTemplate.Triggers&amp;gt;

                        &amp;lt;Trigger Property="IsMouseOver" Value="True"&amp;gt;
                            &amp;lt;Setter TargetName="Button" Property="Fill" Value="Red"&amp;gt;
                            &amp;lt;/Setter&amp;gt;
                        &amp;lt;/Trigger&amp;gt;
                    &amp;lt;/ControlTemplate.Triggers&amp;gt;
                &amp;lt;/ControlTemplate&amp;gt;
            &amp;lt;/Button.Template&amp;gt;
        &amp;lt;/Button&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Data Template
&lt;/h2&gt;

&lt;p&gt;Data Template defines and specifies the appearance and structure of a collection of data. It enables you to customize the appearance of the data objects. It is mostly used with data related item controls such as ListView, ListItem and ComboBox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public class Movie
    {
        public string Title { get; set; }
        public string CoverImage { get; set; }
        public int ReleaseDate { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, I have created Movie model class with Title, CoverImage and ReleaseDate fields.&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;UserControl x:Class="WpfDevelopment.DataTemplate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WpfDevelopment"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"&amp;gt;
    &amp;lt;UserControl.Resources&amp;gt;
        &amp;lt;DataTemplate x:Key="MovieTemplate"&amp;gt;

                &amp;lt;StackPanel Orientation="Horizontal"&amp;gt;
                &amp;lt;Image Source="{Binding Path=CoverImage, FallbackValue=CoverImage}" 
                       Grid.Column="0"
                       Height="200" 
                       Width="150"
                       Margin="5"
                       /&amp;gt;

                &amp;lt;StackPanel Orientation="Vertical" Grid.Column="1" VerticalAlignment="Center"&amp;gt;
                    &amp;lt;Label Foreground="BlueViolet" 
                           FontWeight="Bold" 
                           FontSize="18" 
                           Content="{Binding Path = Title}"/&amp;gt;
                    &amp;lt;Label Foreground="Crimson" Content="{Binding Path = ReleaseDate}"/&amp;gt;
                &amp;lt;/StackPanel&amp;gt;
                &amp;lt;/StackPanel&amp;gt;
        &amp;lt;/DataTemplate&amp;gt;
    &amp;lt;/UserControl.Resources&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;ListView 
                  ItemTemplate="{StaticResource MovieTemplate}"
                  x:Name="MovieListView"/&amp;gt;


    &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;In this xaml file, DataTemplate is created for ListView control and ItemSource is set from code behind.&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;summary&amp;gt;
    /// Interaction logic for DataTemplate.xaml
    /// &amp;lt;/summary&amp;gt;
    public partial class DataTemplate : UserControl
    {
        public DataTemplate()
        {
            InitializeComponent();
            List&amp;lt;Movie&amp;gt; movies = new List&amp;lt;Movie&amp;gt;()
            {
                new Movie() { Title = "Logan", CoverImage = @"images/logan.jpg", ReleaseDate = 2006},
                new Movie() { Title = "Top Gun Maverick", CoverImage = @"images/topgun.jpg", ReleaseDate = 2011},
                new Movie(){ Title = "Puss in Boots", CoverImage = @"images/pussinboots.jpg", ReleaseDate = 2022}
            };

            this.MovieListView.ItemsSource = movies;    
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code behind DataTemplate.xaml.cs file, sample data is created and set as ItemSource for ListView. Images path are set from images\ folder.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  ItemPanelTemplate
&lt;/h2&gt;

&lt;p&gt;ItemPanelTemplate is used to customize the panel that defines the layout of items of ItemControls like ListView, ListBox etc.&lt;br&gt;
Example: Default panel for ListBox is &lt;em&gt;VirtualizingStackPanel&lt;/em&gt;.&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;ListView 
                  ItemTemplate="{StaticResource MovieTemplate}"
                  x:Name="MovieListView"&amp;gt;
            &amp;lt;ListView.ItemsPanel&amp;gt;
                &amp;lt;ItemsPanelTemplate&amp;gt;
                    &amp;lt;UniformGrid Columns="2" /&amp;gt;
                &amp;lt;/ItemsPanelTemplate&amp;gt;
            &amp;lt;/ListView.ItemsPanel&amp;gt;
        &amp;lt;/ListView&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ItemPanelTemplate is placed within ListView.ItemsPanel tag.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  HierarchialDataTemplate
&lt;/h2&gt;

&lt;p&gt;HierarchialDataTemplate is used to customize template of parent &lt;strong&gt;TreeViewItems&lt;/strong&gt; as well as of child.&lt;/p&gt;

&lt;p&gt;We have created Episode(child) class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public class Episode
    {
        public Episode(string title)
        {
            Title = title;
        }
        public string Title { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And a Series(Parent class)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public class Series
    {
        public Series(string title)
        {
            Title = title;
            Episodes = new List&amp;lt;Episode&amp;gt;();
        }

        public string Title { get; set; }

        public List&amp;lt;Episode&amp;gt; Episodes { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this xaml file, HierarchicalDataTemplate is created for  TreeView control.&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;UserControl x:Class="WpfDevelopment.TreeViewTemplate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WpfDevelopment"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;TreeView x:Name="treeView"&amp;gt;
            &amp;lt;TreeView.ItemTemplate&amp;gt;
                &amp;lt;HierarchicalDataTemplate ItemsSource="{Binding Episodes}"&amp;gt;
                    &amp;lt;StackPanel Orientation="Horizontal"&amp;gt;
                        &amp;lt;Rectangle Width="10" Height="10" Fill="BlueViolet" Margin="2"/&amp;gt;
                        &amp;lt;Label Content="{Binding Path=Title}"/&amp;gt;
                    &amp;lt;/StackPanel&amp;gt;
                &amp;lt;/HierarchicalDataTemplate&amp;gt;
            &amp;lt;/TreeView.ItemTemplate&amp;gt;
        &amp;lt;/TreeView&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/UserControl&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;In the code behind, I have created sample data and set as ItemSource for TreeView control.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public partial class TreeViewTemplate : UserControl
    {
        public TreeViewTemplate()
        {
            InitializeComponent();

            var webSeries = new List&amp;lt;Series&amp;gt;()
            {
                new Series("Friends")
                {
                    Episodes = new List&amp;lt;Episode&amp;gt;()
                    {
                        new Episode("Episode 1"),
                        new Episode("Episode 2"),
                        new Episode("Episode 3"),
                        new Episode("Episode 4")

                    }
                },
                new Series("Young Sheldon")
                {
                    Episodes = new List&amp;lt;Episode&amp;gt;()
                    {
                        new Episode("Episode 1"),
                        new Episode("Episode 2"),
                        new Episode("Episode 3")

                    }
                }
            };
            treeView.Items.Clear();
            treeView.ItemsSource = webSeries;   

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

&lt;/div&gt;



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

&lt;p&gt;That's it for today, Happy Coding!..&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Asynchronous programming with C#</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Thu, 26 Jan 2023 09:35:45 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/asynchronous-programming-with-c-34pd</link>
      <guid>https://dev.to/deogadkarravina/asynchronous-programming-with-c-34pd</guid>
      <description>&lt;p&gt;Asynchronous programming is an essential part of modern software development, and C# provides powerful tools for implementing it. Asynchronous programming allows developers to write code that can execute tasks concurrently, without blocking the main thread of execution. This makes applications more responsive and efficient by allowing multiple tasks to be processed at the same time.&lt;/p&gt;

&lt;p&gt;In C#, asynchronous programming is implemented using a combination of language features such as async/await keywords and Task objects. The async keyword marks a method as being capable of running in an asynchronous context while the await keyword tells compiler that it should wait until all operations within an async method have completed before continuing with subsequent instructions in the program flow. By combining these two elements together developers can create highly performant applications which are able to process multiple requests simultaneously without waiting on any particular task or operation to complete before continuing with other work items in its queue. &lt;/p&gt;

&lt;p&gt;To illustrate how this works let’s take a look at some sample code written using Visual Studio 2019:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void Main() {  

      var myTask = DoSomethingAsync();   // Start executing DoSomethingAsync(). Returns immediately!    

      Console .WriteLine("Doing something else...");     
      // Continue doing other things here...    
} 

private static async Task&amp;lt;int&amp;gt; DoSomethingAsync() {        
      int result = await LongRunningOperation();         
      return result;     
}    

private static int LongRunningOperation(){          
      Thread.Sleep(5000);           
      return 42;        
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example we start off by calling our long-running function “DoSomethingAsync” from our main entry point (Main). Notice however that when we call this function nothing actually happens because all operations within “DoSomethingAsync” are marked with ‘async' so they will run asynchronously instead – meaning they won't block or delay anything else happening inside Main(). We then print out some text indicating what's going on next ("Doing something else...") followed by finally returning control back over again once everything has finished executing inside "LongRunningOperation". &lt;/p&gt;

&lt;p&gt;The advantage here is obvious - not only does our application remain responsive throughout but also no unnecessary resources were wasted during execution since only one thread was used for both functions even though their individual executions were performed independently from each other (in parallel). This makes asynchronous coding very effective when dealing with high volumes data processing scenarios where performance needs to be optimized accordingly&lt;/p&gt;

&lt;p&gt;In this blog we focused on what and how's of asynchronous programing, in the next blog we will understand Task class and its methods in more detail.&lt;/p&gt;

&lt;p&gt;Happy Coding!... &lt;/p&gt;

</description>
      <category>gratitude</category>
    </item>
    <item>
      <title>Why C# records should be preferred over classes.</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Thu, 19 Jan 2023 14:48:08 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/why-c-records-should-be-preferred-over-classes-2jhp</link>
      <guid>https://dev.to/deogadkarravina/why-c-records-should-be-preferred-over-classes-2jhp</guid>
      <description>&lt;p&gt;Hello everyone! Hope everything is fine. Today I am going to discuss about why we should use C# records instead of classes.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Record?
&lt;/h2&gt;

&lt;p&gt;From C# 9, records are new type defined as reference type using record keyword. They are immutable which means once created it cannot be changed.&lt;/p&gt;

&lt;p&gt;Record type already overrides both virtual &lt;strong&gt;ToString&lt;/strong&gt; and &lt;strong&gt;Equals&lt;/strong&gt; method on the Object base class.&lt;br&gt;
&lt;code&gt;public record class Person(string firstName, string lastName)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public record Person{
    public String firstName {get; set;}
    public String lastName {get; set;}   
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use of class keyword is optional&lt;/p&gt;

&lt;p&gt;IN C# 10, records are introduced as struct type which defines record as value type.  &lt;/p&gt;

&lt;p&gt;&lt;code&gt;public readonly record struct Point(double X, double Y, double Z)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public record struct Point{
    public double X {get; set;}
    public double Y {get; set;}   
    public double Z {get; set;}   
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Equality
&lt;/h2&gt;

&lt;p&gt;Records are value type unlike class type, So two record variable are said to be equal if they have &lt;strong&gt;same record type definition&lt;/strong&gt; and values are equal in &lt;strong&gt;two records&lt;/strong&gt;. &lt;br&gt;
on the other hand two class type variable are said to be equal if they have &lt;strong&gt;same class type definition&lt;/strong&gt; and both are pointing to &lt;strong&gt;same object&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's look at example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public record struct Point{

    public Point(double pt1, double pt2, double pt3){
        X = pt1;
        Y = pt2;
        Z = pt3;
    }

    public double X {get; set;}
    public double Y {get; set;}   
    public double Z {get; set;}   
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then we will create variables of those records&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Main{

    public static void main(){

        Point p1 = new Point(5.0, 10.0, 1);
        Point p2 = new Point(15.0, 10.0, 0);
        Point p3 = new Point(5.0, 10.0, 1);

        if(p1 == p2)
            Console.log("p1 and p2 are Equal");

        if(p1 == p3)
            Console.log("p1 and p3 are Equal");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Below we are going to see same example using classes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Main{

    public static void main(){

        Point p1 = new Point(5.0, 10.0, 1);
        Point p2 = new Point(15.0, 10.0, 0);
        Point p3 = p1;

        if(p1 == p2)
            Console.log("p1 and p2 are Equal");

        if(p1 == p3)
            Console.log("p1 and p3 are Equal");
    }
}
//Output : p1 and p3 are Equal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Immutability
&lt;/h2&gt;

&lt;p&gt;Records are designed to be immutable unlike classes, Once records are instantiated they cannot be changed.&lt;/p&gt;

&lt;p&gt;Records do support nondestructive mutation by using keyword &lt;strong&gt;with&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public static void Main(){
        Person employee1 = new Person("John", "Doe");
        Person employee2 = employee1 with {firstName = "Martin"};

        Console.WriteLine(employee1.firstName + " "+ 
        employee1.lastName);
        //John Doe
        Console.WriteLine(employee2.firstName + " "+ 
        employee1.lastName);
        //Martin Doe

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Concise code
&lt;/h2&gt;

&lt;p&gt;We have already discussed short hand way(single line declaration) of writing records. Less code means smaller codebase and easy maintenance.&lt;/p&gt;

&lt;p&gt;Records are generally used for handling data and classes defines behaviors.&lt;/p&gt;

&lt;p&gt;That's all for today, Happy coding!...&lt;/p&gt;

</description>
      <category>git</category>
      <category>cli</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Understanding TDD</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Sun, 04 Dec 2022 14:24:43 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/understanding-tdd-4end</link>
      <guid>https://dev.to/deogadkarravina/understanding-tdd-4end</guid>
      <description>&lt;p&gt;Test Driven Development (TDD) is a very powerful development methodology that completely turns traditional development around. When you first go to implement a new feature, the first question that you ask is whether the existing design is the right design for that feature. If it is not, you make changes to the existing design locally to enable that feature to be implemented as quickly and easily as possible. The result is that you are constantly improving the quality of your code and ensuring that your designs match the actual requirements that you will actually use in production. This also helps to ensure that the final code works as expected and does not introduce any unwanted side-effects or bugs.&lt;/p&gt;

&lt;p&gt;When implementing new features in a software system it is important to keep sight of the bigger picture at all times and make sure that the system is working as efficiently and accurately as possible. This includes running tests against your production environment. These tests will check whether the new feature is working correctly and identify any potential problems that might arise as a result. If these tests fail then the underlying design of the code will need to be changed to ensure that the new feature can be successfully implemented.&lt;/p&gt;

&lt;p&gt;The continuous integration and deployment (CI/CD) process is designed to automate this process. TDD is essentially a test-first development methodology in which you write an automated test suite for your code before you write the actual code itself. These tests are written using programming language-specific syntax and are not actual examples of user behavior. &lt;/p&gt;

&lt;p&gt;Looking at few examples for understanding TDD.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Main.java
public String helloString(){
    return "Hello";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a simple method returning string "Hello" .To test the returned string we will be adding a test method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//MainTest.java
    @Test
    void shouldReturnHello(){
        Assertions.assertEquals("Hello", Main.helloString());
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make tests readable have meaningful name for the test methods and aggregate testcases to different classes as per their respective purpose.&lt;/p&gt;

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

&lt;p&gt;Here is a directory structure of LibraryMgmt project. I have separate test class for controller, service and application class.&lt;/p&gt;

&lt;p&gt;You can find complete source code &lt;a href="https://github.com/Ravina-Deogadkar/libraryMgmt" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That's it for today! Thank you and Happy Coding!...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/KvAKXViNfpU8fSDiF0/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/KvAKXViNfpU8fSDiF0/giphy.gif"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>testing</category>
    </item>
    <item>
      <title>How to create an image from an existing container</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Sun, 23 Oct 2022 08:29:01 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/how-to-create-new-image-from-existing-container-olf</link>
      <guid>https://dev.to/deogadkarravina/how-to-create-new-image-from-existing-container-olf</guid>
      <description>&lt;p&gt;Hi everyone! Earlier we have created docker container using nginx:alpine image and now we will learn to create snapshots of docker container. To the readers who have not read my previous article you can find it &lt;a href="https://dev.to/deogadkarravina/create-docker-container-9nj"&gt;here&lt;/a&gt;. Don't forget to like it and share it😄&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker run
&lt;/h2&gt;

&lt;p&gt;Let's create a container from nginx:alpine image and name it as "myweb" that will run on 80 port using Docker run command.&lt;/p&gt;

&lt;p&gt;docker run -p 80:80 --name myweb -d nginx:alpine&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YEqEfdtv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knvx1c66enzqrwr1b9co.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YEqEfdtv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/knvx1c66enzqrwr1b9co.png" alt="docker create container" width="521" height="50"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now check our newly created container&lt;br&gt;
docker ps -a&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fhz-pk8P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk45h5d5f8x62d3o1pty.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fhz-pk8P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dk45h5d5f8x62d3o1pty.png" alt="docker container list" width="880" height="61"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker exec -it
&lt;/h2&gt;

&lt;p&gt;Docker exec command is used to execute a command in the running container.&lt;/p&gt;

&lt;p&gt;docker exec -it myweb /bin/bash&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--N7BIT4tn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2q9p3v9yyoqvkb94tsy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--N7BIT4tn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2q9p3v9yyoqvkb94tsy.png" alt="Docker exec error" width="880" height="39"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It gives us an error, but why so??&lt;br&gt;
Its because bash is not installed on our container so we are going to use /bin/sh.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yLmSFtXh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbr23zpa3fav9vhof65h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yLmSFtXh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbr23zpa3fav9vhof65h.png" alt="Docker exec resolve" width="478" height="79"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let's add Tutorial.txt file in the root directory of our container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l9uYvWYD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehr39m6hj06kxi4p0w8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l9uYvWYD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ehr39m6hj06kxi4p0w8c.png" alt="Echo file" width="880" height="120"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;press &lt;strong&gt;'Ctrl + D'&lt;/strong&gt; to exit&lt;/p&gt;

&lt;h2&gt;
  
  
  Docker commit
&lt;/h2&gt;

&lt;p&gt;Now we have our container ready we can create snapshot of our container by using &lt;strong&gt;docker commit&lt;/strong&gt; comand along with the container name/Id and new container name.&lt;/p&gt;

&lt;p&gt;docker commit myweb mynginx&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tkeJtRDp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zz69lesn7v66cme6a6dr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tkeJtRDp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zz69lesn7v66cme6a6dr.png" alt="Docker commit" width="655" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's check our newly created docker images.&lt;/p&gt;

&lt;p&gt;docker images&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wFyKaFGN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0w5whpqdyfhebcngpqk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wFyKaFGN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f0w5whpqdyfhebcngpqk.png" alt="Docker images" width="770" height="113"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And let's check if our file is there in image by creating a container from that image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4Vobbf2a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gipvdpiulmu77xbr6ifh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4Vobbf2a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gipvdpiulmu77xbr6ifh.png" alt="Docker new container" width="579" height="51"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our new container is created with name myweb_v2, now we will check for our &lt;strong&gt;Tutorial.txt&lt;/strong&gt; file in a new container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4ezBC5W2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xwnoeb7xzgn6xrvgobz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4ezBC5W2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xwnoeb7xzgn6xrvgobz.png" alt="Docker exec new conatiner" width="880" height="83"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it for today, Happy Coding!.....&lt;/p&gt;

</description>
      <category>docker</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Learn how to spin up docker container</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Sat, 17 Sep 2022 11:19:47 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/create-docker-container-9nj</link>
      <guid>https://dev.to/deogadkarravina/create-docker-container-9nj</guid>
      <description>&lt;p&gt;Hello everyone!, Today we are going to look at step by step process of creating and running a docker container.&lt;/p&gt;

&lt;p&gt;Docker is a software platform that lets you build, test and deploy application very quickly. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly Using Docker an application can be easily deployed and scaled in any environment. Docker provides the ability to package and run an application in a loosely isolated environment called a container. Containers are lightweight and contain everything needed to run the application, so you do not need to rely on what is currently installed on the host machine.&lt;/p&gt;

&lt;p&gt;Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers which may or may not run on same system as client.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker create
&lt;/h3&gt;

&lt;p&gt;To create docker container from image we make use of docker create command along with the image.&lt;br&gt;
An image is a read-only template with instructions for creating a Docker container. A container is a runnable instance of an image.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker create nginx:alpine&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create container with nginx:alpine image and the container will have some random name assign to it. If the images are not present locally then it will pull it from &lt;a href="https://hub.docker.com/search?q=&amp;amp;type=image" rel="noopener noreferrer"&gt;registry&lt;/a&gt;.&lt;br&gt;
We can assign custom name to docker using &lt;strong&gt;--name&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker create --name myNginx nginx:alpine&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will create nginx docker container with name myNginx. But to access our container from our computer we need to port forward it to specific port using &lt;strong&gt;-p&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker create --name myNginx -p 80:80 -d nginx:alpine&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5c0orugiwlyq9prce07.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz5c0orugiwlyq9prce07.png" alt="Docker create"&gt;&lt;/a&gt;&lt;br&gt;
In the docker desktop you can see our new container created.&lt;/p&gt;

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

&lt;p&gt;Now we can access our container myNginx on port 8080.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Docker start
&lt;/h3&gt;

&lt;p&gt;Docker start command will start docker container and status of container will change from &lt;strong&gt;Created&lt;/strong&gt; to &lt;strong&gt;Running&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker start&lt;/code&gt;&lt;/p&gt;

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

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

&lt;h3&gt;
  
  
  Docker ps
&lt;/h3&gt;

&lt;p&gt;Docker ps will list all the running containers and using -a will list all containers created in the machine.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker ps -a&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;You can see our myNginx container created and currently in running state.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker images
&lt;/h3&gt;

&lt;p&gt;Docker images command will list down all the images.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker images -a&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zkhqsmjqngbbg126xtz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zkhqsmjqngbbg126xtz.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
You can see our nginx alpine image the one that we have currently used to create container.&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker stop
&lt;/h3&gt;

&lt;p&gt;Docker stop command will stop the container and you can see the status turned to &lt;strong&gt;Exited&lt;/strong&gt; state.&lt;/p&gt;

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

&lt;p&gt;And our docker ps command shows the status as Exited&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Docker rm
&lt;/h3&gt;

&lt;p&gt;Docker rm command will remove the specific container permanently&lt;/p&gt;

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

&lt;p&gt;You can check using docker ps command that container is removed from machine.&lt;/p&gt;

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

&lt;p&gt;That's it for today, until next time Happy Coding!..&lt;/p&gt;

</description>
      <category>programming</category>
      <category>docker</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>React: Code splitting</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Wed, 07 Sep 2022 16:05:16 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/react-code-splitting-3c67</link>
      <guid>https://dev.to/deogadkarravina/react-code-splitting-3c67</guid>
      <description>&lt;p&gt;Hi everyone! recently I was working on complex multiple module react app and also it has lots of dependencies on third party libraries. So the loading time of some of the components was beyond its expectations and the size of bundle was the other part.&lt;/p&gt;

&lt;p&gt;Any web application will be user accessible/friendly only if the response time is lowest as possible and smaller bundle size will  improvise build time and save storage.&lt;/p&gt;

&lt;p&gt;Bundling is a process to merge all imported modules in a single files. Bundling is good when size of dependencies is small but as dependencies grow merging in a single file is a problem. Here code splitting comes in a picture, Code splitting is a feature supported by &lt;a href="https://gist.github.com/gaearon/ca6e803f5c604d37468b0091d9959269"&gt;Webpack&lt;/a&gt; and comes pre-configured with &lt;a href="https://create-react-app.dev/docs/code-splitting/"&gt;code-react-app&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Splitting
&lt;/h2&gt;

&lt;p&gt;It is a process to lazy load only the things that are required by our application causing speeding up the load time of our application. With code splitting the code that is never needed will not be loaded and the code size will be lower at initial build.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dynamic imports
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let sortedString = import('./StringUtils')
    .then(StringUtils=&amp;gt;{
        StringUtils.sort(str)
    })
    .catch(err=&amp;gt;{
    //handles error
   })

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

&lt;/div&gt;



&lt;p&gt;In the example, StringUtils module is not imported before this code and the bundle size is smaller. When webpack comes across this syntax it automatically starts code splitting. &lt;/p&gt;

&lt;h3&gt;
  
  
  React.lazy
&lt;/h3&gt;

&lt;p&gt;Lets you render dynamic imports as regular components. It automatically renders the bundle containing the component when it is first rendered.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let UtilsComponent = React.lazy(()=&amp;gt;import('./StringUtils'))&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;React.lazy takes a function as input that imports a module and returns a promise that resolves into a module with a default export to a component.&lt;/p&gt;

&lt;h3&gt;
  
  
  React.suspense
&lt;/h3&gt;

&lt;p&gt;React.suspense is used to render lazy components which shows fallback component until we are waiting for lazy component to render.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import React, { Component, Suspense } from 'react'

export default class Statics extends Component {
  render() {
    let RandomColor = React.lazy(()=&amp;gt;import('./RandomColor'));
    return (
      &amp;lt;div&amp;gt;
        &amp;lt;Suspense fallback={&amp;lt;div&amp;gt;Loading....&amp;lt;/div&amp;gt;}&amp;gt;
          &amp;lt;RandomColor/&amp;gt;
        &amp;lt;/Suspense&amp;gt;
      &amp;lt;/div&amp;gt;
    )
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;fallback props of React.Suspense takes any component that will be displayed until the lazy component is loaded.&lt;/p&gt;

&lt;p&gt;So here we have solved both of are problem, our bundle size is smaller since we are dynamically importing components only when they are required. Load time is also low as the bundle size is low due to dynamically importing components.&lt;/p&gt;

&lt;p&gt;That's all for today, until then Happy Coding!..&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript : Array Literals</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Mon, 22 Aug 2022 04:49:28 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/javascript-array-literals-3991</link>
      <guid>https://dev.to/deogadkarravina/javascript-array-literals-3991</guid>
      <description>&lt;p&gt;Hi everyone! Today we are going look at a very basic  but very useful concept Array literals. Unlike a number or string element which represents a single element array are collection of similar data type. Arrays can have zero or more elements. In this article we are going to discuss about array literals in JavaScript.&lt;/p&gt;

&lt;p&gt;Array are represented by set of elements enclosed in square brackets.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
let x=[5,6,10,15,25];&lt;br&gt;
console.log(x.length)&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;length property of Arrays will return 5.&lt;/p&gt;

&lt;h3&gt;
  
  
  Arrays and extra commas(,)
&lt;/h3&gt;

&lt;p&gt;Presense of extra commas(,) in arrays affects the array length. Any two adjacent commas in an array leaves an empty slot for unspecified element. Let's look at few examples.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
let x=[5,,6,7,8]&lt;br&gt;
console.log(x.length);&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And when you log x it will be &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
[5, &amp;lt;Empty element&amp;gt;, 6,7,8]&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here although only four elements are there in an array but the four commas (second empty ,) causes array length to be 5.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
let x=[5,6,7,8,]&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
and when you log x it will be&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
[5,6,7,8]&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here again array has four elements and four commas(,) but the array length is 4 and not 5 this is because last comma is ignored.&lt;/p&gt;

&lt;p&gt;Note: While using array iterating methods like Map this empty element is always skip.&lt;/p&gt;

&lt;p&gt;It's always recommended to have extra comma at the end as it improves the readability of code when you are working on big arrays.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
let fruits=["Apple",&lt;br&gt;
            "Banana",&lt;br&gt;
            "Mango",&lt;br&gt;
            "Jack fruit",&lt;br&gt;
           ]&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
And also adding comma at end won't cause any merge conflict if multiple team members are adding elements to same array.&lt;/p&gt;

&lt;p&gt;That's it for today!&lt;br&gt;
Happy Coding.....&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Java executor framework</title>
      <dc:creator>Ravina Deogadkar</dc:creator>
      <pubDate>Sun, 14 Aug 2022 17:09:31 +0000</pubDate>
      <link>https://dev.to/deogadkarravina/java-executor-framework-5h4d</link>
      <guid>https://dev.to/deogadkarravina/java-executor-framework-5h4d</guid>
      <description>&lt;p&gt;ExecutorService is a JDK API that simplifies running tasks in asynchronous mode. It provides a pool of threads and an API for assigning tasks to it. The executor framework is an implementation of the Producer-Consumer pattern. The &lt;strong&gt;java.util.concurrent.Executors&lt;/strong&gt; class provides a set of methods for creating ThreadPools of worker threads. In this article, we will be looking at types of executors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of executor
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Single thread Executor&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The SingleThreadExecutor is a special type of executor that has only a single thread. It is used when we need to execute tasks in sequential order.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExecutorService executor = Executors.newSingleThreadExecutor()&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Fixed thread pool&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;FixedThreadPool is another special type of executor that is a thread pool having a fixed number of threads. By this executor, the submitted task is executed by the n thread.&lt;br&gt;
The tasks are then stored in &lt;strong&gt;LinkedBlockingQueue&lt;/strong&gt; until previous tasks are not completed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExecutorService executor = Executors.newFixedThreadPool(4);&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cached thread pool&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The CachedThreadPool is a special type of thread pool that is used to execute short-lived parallel tasks. The cached thread pool doesn't have a fixed number of threads. When a new task comes at a time and all the threads are busy executing some other tasks, a new thread is created by the pool and added to the executor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ExecutorService executor = Executors.newCachedThreadPool();&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scheduled executor service&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ScheduledExecutorService interface runs tasks after some predefined delay and/or periodically. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;ScheduledExecutorService scheduledExecService = Executors.newScheduledThreadPool(1);  &lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The &lt;strong&gt;scheduleAtFixedRate&lt;/strong&gt; and &lt;strong&gt;scheduleWithFixedDelay&lt;/strong&gt; are the two methods that are used to schedule the task in ScheduledExecutor. &lt;br&gt;
The &lt;strong&gt;scheduleAtFixedRate&lt;/strong&gt; method executes the task with a fixed interval when the previous task ended. &lt;br&gt;
The &lt;strong&gt;scheduleWithFixedDelay&lt;/strong&gt; method starts the delay count after the current task is complete. &lt;br&gt;
The main difference between these two methods is their interpretation of the delay between successive executions of a scheduled job.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;scheduledExecService.scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit)  &lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;scheduledExecService.scheduleWithFixedDelay(Runnable command, long initialDelay, long period, TimeUnit unit) &lt;br&gt;
&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;The best use case for ExecutorService is the processing of independent tasks, such as transactions or requests according to the scheme “one thread for one task” in Oracle’s documentation, fork/join was designed to speed up work that can be broken into smaller pieces recursively.&lt;/p&gt;

&lt;p&gt;That's all for today, Happy Coding!..&lt;/p&gt;

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